@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/dist/index.js CHANGED
@@ -2463,15 +2463,78 @@ function useVoice(options = {}) {
2463
2463
  };
2464
2464
  }
2465
2465
 
2466
+ // src/hooks/useMessages.ts
2467
+ import { useCallback as useCallback7, useMemo as useMemo5, useRef as useRef4, useState as useState7 } from "react";
2468
+ async function readErrorMessage(res, fallback) {
2469
+ try {
2470
+ const body = await res.json();
2471
+ const message = body?.error?.message ?? body?.message;
2472
+ if (typeof message === "string" && message) return message;
2473
+ } catch {
2474
+ }
2475
+ return `${fallback}: ${res.statusText}`;
2476
+ }
2477
+ function useMessages() {
2478
+ const { fetchWithAuth, logger } = usePersonaContext();
2479
+ const messagesLogger = useMemo5(() => logger.child("messages"), [logger]);
2480
+ const [isSending, setIsSending] = useState7(false);
2481
+ const [error, setError] = useState7(null);
2482
+ const [lastDelivery, setLastDelivery] = useState7(null);
2483
+ const inFlightRef = useRef4(0);
2484
+ const post = useCallback7(
2485
+ async (path, input) => {
2486
+ inFlightRef.current += 1;
2487
+ setIsSending(true);
2488
+ setError(null);
2489
+ try {
2490
+ const res = await fetchWithAuth(path, {
2491
+ method: "POST",
2492
+ headers: { "Content-Type": "application/json" },
2493
+ body: JSON.stringify(input)
2494
+ });
2495
+ if (!res.ok) {
2496
+ throw new Error(await readErrorMessage(res, "Failed to send message"));
2497
+ }
2498
+ const payload = await res.json();
2499
+ const delivery = payload?.data ?? payload;
2500
+ setLastDelivery(delivery);
2501
+ messagesLogger.info("message sent", { path });
2502
+ return delivery;
2503
+ } catch (err) {
2504
+ const errorObj = err instanceof Error ? err : new Error(String(err));
2505
+ messagesLogger.warn("message send failed", {
2506
+ path,
2507
+ error: errorObj.message
2508
+ });
2509
+ setError(errorObj);
2510
+ throw errorObj;
2511
+ } finally {
2512
+ inFlightRef.current -= 1;
2513
+ if (inFlightRef.current === 0) setIsSending(false);
2514
+ }
2515
+ },
2516
+ [fetchWithAuth, messagesLogger]
2517
+ );
2518
+ const send = useCallback7(
2519
+ (input) => post("/messages", input),
2520
+ [post]
2521
+ );
2522
+ const sendFromAgent = useCallback7(
2523
+ (input) => post("/messages/agent", input),
2524
+ [post]
2525
+ );
2526
+ return { isSending, error, lastDelivery, send, sendFromAgent };
2527
+ }
2528
+
2466
2529
  // src/hooks/useFiles.ts
2467
- import { useCallback as useCallback7, useEffect as useEffect7, useState as useState7 } from "react";
2530
+ import { useCallback as useCallback8, useEffect as useEffect7, useState as useState8 } from "react";
2468
2531
  function useFiles(autoFetch = true) {
2469
2532
  const { fetchWithAuth } = usePersonaContext();
2470
- const [files, setFiles] = useState7([]);
2471
- const [isLoading, setIsLoading] = useState7(false);
2472
- const [isUploading, setIsUploading] = useState7(false);
2473
- const [error, setError] = useState7(null);
2474
- const fetchFiles = useCallback7(async () => {
2533
+ const [files, setFiles] = useState8([]);
2534
+ const [isLoading, setIsLoading] = useState8(false);
2535
+ const [isUploading, setIsUploading] = useState8(false);
2536
+ const [error, setError] = useState8(null);
2537
+ const fetchFiles = useCallback8(async () => {
2475
2538
  setIsLoading(true);
2476
2539
  setError(null);
2477
2540
  try {
@@ -2489,7 +2552,7 @@ function useFiles(autoFetch = true) {
2489
2552
  setIsLoading(false);
2490
2553
  }
2491
2554
  }, [fetchWithAuth]);
2492
- const uploadFile = useCallback7(
2555
+ const uploadFile = useCallback8(
2493
2556
  async (fileOrFormData) => {
2494
2557
  setIsUploading(true);
2495
2558
  setError(null);
@@ -2522,7 +2585,7 @@ function useFiles(autoFetch = true) {
2522
2585
  },
2523
2586
  [fetchWithAuth, fetchFiles]
2524
2587
  );
2525
- const deleteFile = useCallback7(
2588
+ const deleteFile = useCallback8(
2526
2589
  async (fileId) => {
2527
2590
  const res = await fetchWithAuth(`/files/${fileId}`, { method: "DELETE" });
2528
2591
  if (!res.ok) throw new Error(`Failed to delete file: ${res.statusText}`);
@@ -2530,7 +2593,7 @@ function useFiles(autoFetch = true) {
2530
2593
  },
2531
2594
  [fetchWithAuth]
2532
2595
  );
2533
- const bulkDeleteFiles = useCallback7(
2596
+ const bulkDeleteFiles = useCallback8(
2534
2597
  async (fileIds) => {
2535
2598
  const res = await fetchWithAuth("/files/bulk-delete", {
2536
2599
  method: "POST",
@@ -2545,7 +2608,7 @@ function useFiles(autoFetch = true) {
2545
2608
  },
2546
2609
  [fetchWithAuth]
2547
2610
  );
2548
- const getDownloadUrl = useCallback7((fileId) => {
2611
+ const getDownloadUrl = useCallback8((fileId) => {
2549
2612
  return `/files/${fileId}`;
2550
2613
  }, []);
2551
2614
  useEffect7(() => {
@@ -2567,21 +2630,21 @@ function useFiles(autoFetch = true) {
2567
2630
  }
2568
2631
 
2569
2632
  // src/hooks/useAgents.ts
2570
- import { useCallback as useCallback8, useEffect as useEffect8, useState as useState8 } from "react";
2633
+ import { useCallback as useCallback9, useEffect as useEffect8, useState as useState9 } from "react";
2571
2634
  function useAgents(options = true) {
2572
2635
  const opts = typeof options === "boolean" ? { autoFetch: options } : options;
2573
2636
  const { autoFetch = true, page, limit, search, category, scope } = opts;
2574
2637
  const { fetchWithAuth } = usePersonaContext();
2575
- const [agents, setAgents] = useState8([]);
2576
- const [pagination, setPagination] = useState8({
2638
+ const [agents, setAgents] = useState9([]);
2639
+ const [pagination, setPagination] = useState9({
2577
2640
  total: 0,
2578
2641
  page: page ?? 1,
2579
2642
  limit: limit ?? 20,
2580
2643
  pages: 0
2581
2644
  });
2582
- const [isLoading, setIsLoading] = useState8(false);
2583
- const [error, setError] = useState8(null);
2584
- const fetchAgents = useCallback8(async () => {
2645
+ const [isLoading, setIsLoading] = useState9(false);
2646
+ const [error, setError] = useState9(null);
2647
+ const fetchAgents = useCallback9(async () => {
2585
2648
  setIsLoading(true);
2586
2649
  setError(null);
2587
2650
  try {
@@ -2609,7 +2672,7 @@ function useAgents(options = true) {
2609
2672
  setIsLoading(false);
2610
2673
  }
2611
2674
  }, [fetchWithAuth, page, limit, search, category, scope]);
2612
- const getAgent = useCallback8(
2675
+ const getAgent = useCallback9(
2613
2676
  async (agentId) => {
2614
2677
  const res = await fetchWithAuth(`/agents/${agentId}`);
2615
2678
  if (!res.ok) throw new Error(`Failed to fetch agent: ${res.statusText}`);
@@ -2617,7 +2680,7 @@ function useAgents(options = true) {
2617
2680
  },
2618
2681
  [fetchWithAuth]
2619
2682
  );
2620
- const createAgent = useCallback8(
2683
+ const createAgent = useCallback9(
2621
2684
  async (input) => {
2622
2685
  setError(null);
2623
2686
  try {
@@ -2641,7 +2704,7 @@ function useAgents(options = true) {
2641
2704
  },
2642
2705
  [fetchWithAuth]
2643
2706
  );
2644
- const updateAgent = useCallback8(
2707
+ const updateAgent = useCallback9(
2645
2708
  async (agentId, input) => {
2646
2709
  setError(null);
2647
2710
  try {
@@ -2665,7 +2728,7 @@ function useAgents(options = true) {
2665
2728
  },
2666
2729
  [fetchWithAuth]
2667
2730
  );
2668
- const deleteAgent = useCallback8(
2731
+ const deleteAgent = useCallback9(
2669
2732
  async (agentId) => {
2670
2733
  setError(null);
2671
2734
  try {
@@ -2683,7 +2746,7 @@ function useAgents(options = true) {
2683
2746
  },
2684
2747
  [fetchWithAuth]
2685
2748
  );
2686
- const bulkDeleteAgents = useCallback8(
2749
+ const bulkDeleteAgents = useCallback9(
2687
2750
  async (ids) => {
2688
2751
  setError(null);
2689
2752
  try {
@@ -2726,13 +2789,13 @@ function useAgents(options = true) {
2726
2789
  }
2727
2790
 
2728
2791
  // src/hooks/useConnection.ts
2729
- import { useCallback as useCallback9, useEffect as useEffect9, useState as useState9 } from "react";
2792
+ import { useCallback as useCallback10, useEffect as useEffect9, useState as useState10 } from "react";
2730
2793
  function useConnection(autoCheck = true) {
2731
2794
  const { fetchWithAuth } = usePersonaContext();
2732
- const [health, setHealth] = useState9(null);
2733
- const [isConnected, setIsConnected] = useState9(false);
2734
- const [isLoading, setIsLoading] = useState9(false);
2735
- const checkHealth = useCallback9(async () => {
2795
+ const [health, setHealth] = useState10(null);
2796
+ const [isConnected, setIsConnected] = useState10(false);
2797
+ const [isLoading, setIsLoading] = useState10(false);
2798
+ const checkHealth = useCallback10(async () => {
2736
2799
  setIsLoading(true);
2737
2800
  try {
2738
2801
  const res = await fetchWithAuth("/health");
@@ -2765,15 +2828,15 @@ function useConnection(autoCheck = true) {
2765
2828
  }
2766
2829
 
2767
2830
  // src/hooks/useMcpConnections.ts
2768
- import { useCallback as useCallback10, useEffect as useEffect10, useState as useState10 } from "react";
2831
+ import { useCallback as useCallback11, useEffect as useEffect10, useState as useState11 } from "react";
2769
2832
  function useMcpConnections(options = {}) {
2770
2833
  const { defaultAgentId, fetchWithAuth } = usePersonaContext();
2771
2834
  const agentId = options.agentId ?? defaultAgentId;
2772
2835
  const autoFetch = options.autoFetch ?? true;
2773
- const [connections, setConnections] = useState10([]);
2774
- const [isLoading, setIsLoading] = useState10(false);
2775
- const [error, setError] = useState10(null);
2776
- const fetchConnections = useCallback10(async () => {
2836
+ const [connections, setConnections] = useState11([]);
2837
+ const [isLoading, setIsLoading] = useState11(false);
2838
+ const [error, setError] = useState11(null);
2839
+ const fetchConnections = useCallback11(async () => {
2777
2840
  if (!agentId) return [];
2778
2841
  setIsLoading(true);
2779
2842
  setError(null);
@@ -2797,8 +2860,8 @@ function useMcpConnections(options = {}) {
2797
2860
  setIsLoading(false);
2798
2861
  }
2799
2862
  }, [agentId, fetchWithAuth, options.returnTo]);
2800
- const [isDisconnecting, setIsDisconnecting] = useState10(false);
2801
- const disconnect = useCallback10(
2863
+ const [isDisconnecting, setIsDisconnecting] = useState11(false);
2864
+ const disconnect = useCallback11(
2802
2865
  async (mcpId) => {
2803
2866
  setIsDisconnecting(true);
2804
2867
  setError(null);
@@ -2840,11 +2903,11 @@ function useMcpConnections(options = {}) {
2840
2903
  }
2841
2904
 
2842
2905
  // src/hooks/useMcp.ts
2843
- import { useCallback as useCallback11 } from "react";
2906
+ import { useCallback as useCallback12 } from "react";
2844
2907
  function useMcp(options = {}) {
2845
2908
  const { fetchWithAuth } = usePersonaContext();
2846
2909
  const defaultMcpId = options.mcpId;
2847
- const readResource = useCallback11(
2910
+ const readResource = useCallback12(
2848
2911
  async (uri, mcpId) => {
2849
2912
  const id = mcpId ?? defaultMcpId;
2850
2913
  if (!id) throw new Error("MCP server ID is required to read resource");
@@ -2858,7 +2921,7 @@ function useMcp(options = {}) {
2858
2921
  },
2859
2922
  [fetchWithAuth, defaultMcpId]
2860
2923
  );
2861
- const callTool = useCallback11(
2924
+ const callTool = useCallback12(
2862
2925
  async (name, args, mcpId) => {
2863
2926
  const id = mcpId ?? defaultMcpId;
2864
2927
  if (!id) throw new Error("MCP server ID is required to call tool");
@@ -2881,20 +2944,20 @@ function useMcp(options = {}) {
2881
2944
  }
2882
2945
 
2883
2946
  // src/hooks/useSkills.ts
2884
- import { useCallback as useCallback12, useEffect as useEffect11, useState as useState11 } from "react";
2947
+ import { useCallback as useCallback13, useEffect as useEffect11, useState as useState12 } from "react";
2885
2948
  function useSkills(options = {}) {
2886
2949
  const { autoFetch = true, page, limit, search, scope } = options;
2887
2950
  const { fetchWithAuth } = usePersonaContext();
2888
- const [skills, setSkills] = useState11([]);
2889
- const [pagination, setPagination] = useState11({
2951
+ const [skills, setSkills] = useState12([]);
2952
+ const [pagination, setPagination] = useState12({
2890
2953
  total: 0,
2891
2954
  page: page ?? 1,
2892
2955
  limit: limit ?? 20,
2893
2956
  pages: 0
2894
2957
  });
2895
- const [isLoading, setIsLoading] = useState11(false);
2896
- const [error, setError] = useState11(null);
2897
- const fetchSkills = useCallback12(async () => {
2958
+ const [isLoading, setIsLoading] = useState12(false);
2959
+ const [error, setError] = useState12(null);
2960
+ const fetchSkills = useCallback13(async () => {
2898
2961
  setIsLoading(true);
2899
2962
  setError(null);
2900
2963
  try {
@@ -2921,7 +2984,7 @@ function useSkills(options = {}) {
2921
2984
  setIsLoading(false);
2922
2985
  }
2923
2986
  }, [fetchWithAuth, page, limit, search, scope]);
2924
- const getSkill = useCallback12(
2987
+ const getSkill = useCallback13(
2925
2988
  async (skillId) => {
2926
2989
  const res = await fetchWithAuth(`/skills/${skillId}`);
2927
2990
  if (!res.ok) throw new Error(`Failed to fetch skill: ${res.statusText}`);
@@ -2929,7 +2992,7 @@ function useSkills(options = {}) {
2929
2992
  },
2930
2993
  [fetchWithAuth]
2931
2994
  );
2932
- const createSkill = useCallback12(
2995
+ const createSkill = useCallback13(
2933
2996
  async (input) => {
2934
2997
  setError(null);
2935
2998
  try {
@@ -2953,7 +3016,7 @@ function useSkills(options = {}) {
2953
3016
  },
2954
3017
  [fetchWithAuth]
2955
3018
  );
2956
- const updateSkill = useCallback12(
3019
+ const updateSkill = useCallback13(
2957
3020
  async (skillId, input) => {
2958
3021
  setError(null);
2959
3022
  try {
@@ -2977,7 +3040,7 @@ function useSkills(options = {}) {
2977
3040
  },
2978
3041
  [fetchWithAuth]
2979
3042
  );
2980
- const deleteSkill = useCallback12(
3043
+ const deleteSkill = useCallback13(
2981
3044
  async (skillId) => {
2982
3045
  setError(null);
2983
3046
  try {
@@ -2995,7 +3058,7 @@ function useSkills(options = {}) {
2995
3058
  },
2996
3059
  [fetchWithAuth]
2997
3060
  );
2998
- const bulkDeleteSkills = useCallback12(
3061
+ const bulkDeleteSkills = useCallback13(
2999
3062
  async (ids) => {
3000
3063
  setError(null);
3001
3064
  try {
@@ -3020,7 +3083,7 @@ function useSkills(options = {}) {
3020
3083
  },
3021
3084
  [fetchWithAuth]
3022
3085
  );
3023
- const getSkillUsage = useCallback12(
3086
+ const getSkillUsage = useCallback13(
3024
3087
  async (skillId) => {
3025
3088
  const res = await fetchWithAuth(`/skills/${skillId}/usage`);
3026
3089
  if (!res.ok) throw new Error(`Failed to fetch skill usage: ${res.statusText}`);
@@ -3047,20 +3110,20 @@ function useSkills(options = {}) {
3047
3110
  }
3048
3111
 
3049
3112
  // src/hooks/useRcpSources.ts
3050
- import { useCallback as useCallback13, useEffect as useEffect12, useState as useState12 } from "react";
3113
+ import { useCallback as useCallback14, useEffect as useEffect12, useState as useState13 } from "react";
3051
3114
  function useRcpSources(options = {}) {
3052
3115
  const { autoFetch = true, page, limit, search } = options;
3053
3116
  const { fetchWithAuth } = usePersonaContext();
3054
- const [rcpSources, setRcpSources] = useState12([]);
3055
- const [pagination, setPagination] = useState12({
3117
+ const [rcpSources, setRcpSources] = useState13([]);
3118
+ const [pagination, setPagination] = useState13({
3056
3119
  total: 0,
3057
3120
  page: page ?? 1,
3058
3121
  limit: limit ?? 20,
3059
3122
  pages: 0
3060
3123
  });
3061
- const [isLoading, setIsLoading] = useState12(false);
3062
- const [error, setError] = useState12(null);
3063
- const fetchRcpSources = useCallback13(async () => {
3124
+ const [isLoading, setIsLoading] = useState13(false);
3125
+ const [error, setError] = useState13(null);
3126
+ const fetchRcpSources = useCallback14(async () => {
3064
3127
  setIsLoading(true);
3065
3128
  setError(null);
3066
3129
  try {
@@ -3086,7 +3149,7 @@ function useRcpSources(options = {}) {
3086
3149
  setIsLoading(false);
3087
3150
  }
3088
3151
  }, [fetchWithAuth, page, limit, search]);
3089
- const getRcpSource = useCallback13(
3152
+ const getRcpSource = useCallback14(
3090
3153
  async (sourceId) => {
3091
3154
  const res = await fetchWithAuth(`/rcp-sources/${sourceId}`);
3092
3155
  if (!res.ok) throw new Error(`Failed to fetch RCP source: ${res.statusText}`);
@@ -3094,7 +3157,7 @@ function useRcpSources(options = {}) {
3094
3157
  },
3095
3158
  [fetchWithAuth]
3096
3159
  );
3097
- const createRcpSource = useCallback13(
3160
+ const createRcpSource = useCallback14(
3098
3161
  async (input) => {
3099
3162
  setError(null);
3100
3163
  try {
@@ -3118,7 +3181,7 @@ function useRcpSources(options = {}) {
3118
3181
  },
3119
3182
  [fetchWithAuth]
3120
3183
  );
3121
- const updateRcpSource = useCallback13(
3184
+ const updateRcpSource = useCallback14(
3122
3185
  async (sourceId, input) => {
3123
3186
  setError(null);
3124
3187
  try {
@@ -3142,7 +3205,7 @@ function useRcpSources(options = {}) {
3142
3205
  },
3143
3206
  [fetchWithAuth]
3144
3207
  );
3145
- const deleteRcpSource = useCallback13(
3208
+ const deleteRcpSource = useCallback14(
3146
3209
  async (sourceId) => {
3147
3210
  setError(null);
3148
3211
  try {
@@ -3160,7 +3223,7 @@ function useRcpSources(options = {}) {
3160
3223
  },
3161
3224
  [fetchWithAuth]
3162
3225
  );
3163
- const bulkDeleteRcpSources = useCallback13(
3226
+ const bulkDeleteRcpSources = useCallback14(
3164
3227
  async (ids) => {
3165
3228
  setError(null);
3166
3229
  try {
@@ -3185,7 +3248,7 @@ function useRcpSources(options = {}) {
3185
3248
  },
3186
3249
  [fetchWithAuth]
3187
3250
  );
3188
- const getRcpSourceUsage = useCallback13(
3251
+ const getRcpSourceUsage = useCallback14(
3189
3252
  async (sourceId) => {
3190
3253
  const res = await fetchWithAuth(`/rcp-sources/${sourceId}/usage`);
3191
3254
  if (!res.ok) throw new Error(`Failed to fetch RCP source usage: ${res.statusText}`);
@@ -3193,7 +3256,7 @@ function useRcpSources(options = {}) {
3193
3256
  },
3194
3257
  [fetchWithAuth]
3195
3258
  );
3196
- const testRcpSourceConnection = useCallback13(
3259
+ const testRcpSourceConnection = useCallback14(
3197
3260
  async (sourceId) => {
3198
3261
  setError(null);
3199
3262
  try {
@@ -3237,21 +3300,21 @@ function useRcpSources(options = {}) {
3237
3300
  }
3238
3301
 
3239
3302
  // src/hooks/useKnowledgeBases.ts
3240
- import { useCallback as useCallback14, useEffect as useEffect13, useState as useState13 } from "react";
3303
+ import { useCallback as useCallback15, useEffect as useEffect13, useState as useState14 } from "react";
3241
3304
  function useKnowledgeBases(options = {}) {
3242
3305
  const { autoFetch = true, page, limit, search, scope } = options;
3243
3306
  const { fetchWithAuth } = usePersonaContext();
3244
- const [knowledgeBases, setKnowledgeBases] = useState13([]);
3245
- const [pagination, setPagination] = useState13({
3307
+ const [knowledgeBases, setKnowledgeBases] = useState14([]);
3308
+ const [pagination, setPagination] = useState14({
3246
3309
  total: 0,
3247
3310
  page: page ?? 1,
3248
3311
  limit: limit ?? 20,
3249
3312
  pages: 0
3250
3313
  });
3251
- const [isLoading, setIsLoading] = useState13(false);
3252
- const [isUploading, setIsUploading] = useState13(false);
3253
- const [error, setError] = useState13(null);
3254
- const fetchKnowledgeBases = useCallback14(async () => {
3314
+ const [isLoading, setIsLoading] = useState14(false);
3315
+ const [isUploading, setIsUploading] = useState14(false);
3316
+ const [error, setError] = useState14(null);
3317
+ const fetchKnowledgeBases = useCallback15(async () => {
3255
3318
  setIsLoading(true);
3256
3319
  setError(null);
3257
3320
  try {
@@ -3278,7 +3341,7 @@ function useKnowledgeBases(options = {}) {
3278
3341
  setIsLoading(false);
3279
3342
  }
3280
3343
  }, [fetchWithAuth, page, limit, search, scope]);
3281
- const getKnowledgeBase = useCallback14(
3344
+ const getKnowledgeBase = useCallback15(
3282
3345
  async (kbId) => {
3283
3346
  const res = await fetchWithAuth(`/knowledge/${kbId}`);
3284
3347
  if (!res.ok) throw new Error(`Failed to fetch knowledge base: ${res.statusText}`);
@@ -3286,7 +3349,7 @@ function useKnowledgeBases(options = {}) {
3286
3349
  },
3287
3350
  [fetchWithAuth]
3288
3351
  );
3289
- const createKnowledgeBase = useCallback14(
3352
+ const createKnowledgeBase = useCallback15(
3290
3353
  async (input) => {
3291
3354
  setError(null);
3292
3355
  try {
@@ -3310,7 +3373,7 @@ function useKnowledgeBases(options = {}) {
3310
3373
  },
3311
3374
  [fetchWithAuth]
3312
3375
  );
3313
- const updateKnowledgeBase = useCallback14(
3376
+ const updateKnowledgeBase = useCallback15(
3314
3377
  async (kbId, input) => {
3315
3378
  setError(null);
3316
3379
  try {
@@ -3334,7 +3397,7 @@ function useKnowledgeBases(options = {}) {
3334
3397
  },
3335
3398
  [fetchWithAuth]
3336
3399
  );
3337
- const deleteKnowledgeBase = useCallback14(
3400
+ const deleteKnowledgeBase = useCallback15(
3338
3401
  async (kbId) => {
3339
3402
  setError(null);
3340
3403
  try {
@@ -3352,7 +3415,7 @@ function useKnowledgeBases(options = {}) {
3352
3415
  },
3353
3416
  [fetchWithAuth]
3354
3417
  );
3355
- const bulkDeleteKnowledgeBases = useCallback14(
3418
+ const bulkDeleteKnowledgeBases = useCallback15(
3356
3419
  async (ids) => {
3357
3420
  setError(null);
3358
3421
  try {
@@ -3377,7 +3440,7 @@ function useKnowledgeBases(options = {}) {
3377
3440
  },
3378
3441
  [fetchWithAuth]
3379
3442
  );
3380
- const getKnowledgeBaseUsage = useCallback14(
3443
+ const getKnowledgeBaseUsage = useCallback15(
3381
3444
  async (kbId) => {
3382
3445
  const res = await fetchWithAuth(`/knowledge/${kbId}/usage`);
3383
3446
  if (!res.ok) throw new Error(`Failed to fetch knowledge base usage: ${res.statusText}`);
@@ -3385,7 +3448,7 @@ function useKnowledgeBases(options = {}) {
3385
3448
  },
3386
3449
  [fetchWithAuth]
3387
3450
  );
3388
- const uploadDocuments = useCallback14(
3451
+ const uploadDocuments = useCallback15(
3389
3452
  async (kbId, files) => {
3390
3453
  setIsUploading(true);
3391
3454
  setError(null);
@@ -3427,7 +3490,7 @@ function useKnowledgeBases(options = {}) {
3427
3490
  },
3428
3491
  [fetchWithAuth]
3429
3492
  );
3430
- const listDocuments = useCallback14(
3493
+ const listDocuments = useCallback15(
3431
3494
  async (kbId) => {
3432
3495
  const res = await fetchWithAuth(`/knowledge/${kbId}/documents`);
3433
3496
  if (!res.ok) throw new Error(`Failed to list documents: ${res.statusText}`);
@@ -3435,7 +3498,7 @@ function useKnowledgeBases(options = {}) {
3435
3498
  },
3436
3499
  [fetchWithAuth]
3437
3500
  );
3438
- const deleteDocument = useCallback14(
3501
+ const deleteDocument = useCallback15(
3439
3502
  async (kbId, sourceName) => {
3440
3503
  setError(null);
3441
3504
  try {
@@ -3462,7 +3525,7 @@ function useKnowledgeBases(options = {}) {
3462
3525
  },
3463
3526
  [fetchWithAuth]
3464
3527
  );
3465
- const searchKnowledgeBase = useCallback14(
3528
+ const searchKnowledgeBase = useCallback15(
3466
3529
  async (kbId, query, opts) => {
3467
3530
  const res = await fetchWithAuth(`/knowledge/${kbId}/search`, {
3468
3531
  method: "POST",
@@ -3501,20 +3564,20 @@ function useKnowledgeBases(options = {}) {
3501
3564
  }
3502
3565
 
3503
3566
  // src/hooks/useMcpAdmin.ts
3504
- import { useCallback as useCallback15, useEffect as useEffect14, useState as useState14 } from "react";
3567
+ import { useCallback as useCallback16, useEffect as useEffect14, useState as useState15 } from "react";
3505
3568
  function useMcpAdmin(options = {}) {
3506
3569
  const { autoFetch = true, page, limit, search } = options;
3507
3570
  const { fetchWithAuth } = usePersonaContext();
3508
- const [mcps, setMcps] = useState14([]);
3509
- const [pagination, setPagination] = useState14({
3571
+ const [mcps, setMcps] = useState15([]);
3572
+ const [pagination, setPagination] = useState15({
3510
3573
  total: 0,
3511
3574
  page: page ?? 1,
3512
3575
  limit: limit ?? 20,
3513
3576
  pages: 0
3514
3577
  });
3515
- const [isLoading, setIsLoading] = useState14(false);
3516
- const [error, setError] = useState14(null);
3517
- const fetchMcps = useCallback15(async () => {
3578
+ const [isLoading, setIsLoading] = useState15(false);
3579
+ const [error, setError] = useState15(null);
3580
+ const fetchMcps = useCallback16(async () => {
3518
3581
  setIsLoading(true);
3519
3582
  setError(null);
3520
3583
  try {
@@ -3540,7 +3603,7 @@ function useMcpAdmin(options = {}) {
3540
3603
  setIsLoading(false);
3541
3604
  }
3542
3605
  }, [fetchWithAuth, page, limit, search]);
3543
- const getMcp = useCallback15(
3606
+ const getMcp = useCallback16(
3544
3607
  async (mcpId) => {
3545
3608
  const res = await fetchWithAuth(`/mcps/${mcpId}`);
3546
3609
  if (!res.ok) throw new Error(`Failed to fetch MCP: ${res.statusText}`);
@@ -3548,7 +3611,7 @@ function useMcpAdmin(options = {}) {
3548
3611
  },
3549
3612
  [fetchWithAuth]
3550
3613
  );
3551
- const createMcp = useCallback15(
3614
+ const createMcp = useCallback16(
3552
3615
  async (input) => {
3553
3616
  setError(null);
3554
3617
  try {
@@ -3572,7 +3635,7 @@ function useMcpAdmin(options = {}) {
3572
3635
  },
3573
3636
  [fetchWithAuth]
3574
3637
  );
3575
- const updateMcp = useCallback15(
3638
+ const updateMcp = useCallback16(
3576
3639
  async (mcpId, input) => {
3577
3640
  setError(null);
3578
3641
  try {
@@ -3596,7 +3659,7 @@ function useMcpAdmin(options = {}) {
3596
3659
  },
3597
3660
  [fetchWithAuth]
3598
3661
  );
3599
- const deleteMcp = useCallback15(
3662
+ const deleteMcp = useCallback16(
3600
3663
  async (mcpId) => {
3601
3664
  setError(null);
3602
3665
  try {
@@ -3614,7 +3677,7 @@ function useMcpAdmin(options = {}) {
3614
3677
  },
3615
3678
  [fetchWithAuth]
3616
3679
  );
3617
- const bulkDeleteMcps = useCallback15(
3680
+ const bulkDeleteMcps = useCallback16(
3618
3681
  async (ids) => {
3619
3682
  setError(null);
3620
3683
  try {
@@ -3639,7 +3702,7 @@ function useMcpAdmin(options = {}) {
3639
3702
  },
3640
3703
  [fetchWithAuth]
3641
3704
  );
3642
- const testConnection = useCallback15(
3705
+ const testConnection = useCallback16(
3643
3706
  async (mcpId) => {
3644
3707
  setError(null);
3645
3708
  try {
@@ -3682,21 +3745,21 @@ function useMcpAdmin(options = {}) {
3682
3745
  }
3683
3746
 
3684
3747
  // src/hooks/useWorkflows.ts
3685
- import { useCallback as useCallback16, useEffect as useEffect15, useState as useState15 } from "react";
3748
+ import { useCallback as useCallback17, useEffect as useEffect15, useState as useState16 } from "react";
3686
3749
  function useWorkflows(options) {
3687
3750
  const opts = typeof options === "boolean" ? { autoFetch: options } : options ?? {};
3688
3751
  const { autoFetch = true, search, scope, visibility, isEnabled, page, limit } = opts;
3689
3752
  const { fetchWithAuth } = usePersonaContext();
3690
- const [workflows, setWorkflows] = useState15([]);
3691
- const [pagination, setPagination] = useState15({
3753
+ const [workflows, setWorkflows] = useState16([]);
3754
+ const [pagination, setPagination] = useState16({
3692
3755
  page: page ?? 1,
3693
3756
  limit: limit ?? 20,
3694
3757
  total: 0,
3695
3758
  totalPages: 0
3696
3759
  });
3697
- const [isLoading, setIsLoading] = useState15(false);
3698
- const [error, setError] = useState15(null);
3699
- const fetchWorkflows = useCallback16(async () => {
3760
+ const [isLoading, setIsLoading] = useState16(false);
3761
+ const [error, setError] = useState16(null);
3762
+ const fetchWorkflows = useCallback17(async () => {
3700
3763
  setIsLoading(true);
3701
3764
  setError(null);
3702
3765
  try {
@@ -3742,7 +3805,7 @@ function useWorkflows(options) {
3742
3805
  setIsLoading(false);
3743
3806
  }
3744
3807
  }, [fetchWithAuth, search, scope, visibility, isEnabled, page, limit]);
3745
- const createWorkflow = useCallback16(
3808
+ const createWorkflow = useCallback17(
3746
3809
  async (input) => {
3747
3810
  setError(null);
3748
3811
  try {
@@ -3782,17 +3845,17 @@ function useWorkflows(options) {
3782
3845
  }
3783
3846
 
3784
3847
  // src/hooks/useWorkflow.ts
3785
- import { useCallback as useCallback17, useEffect as useEffect16, useState as useState16 } from "react";
3848
+ import { useCallback as useCallback18, useEffect as useEffect16, useState as useState17 } from "react";
3786
3849
  function useWorkflow(workflowId, options) {
3787
3850
  const opts = typeof options === "boolean" ? { autoFetch: options } : options ?? {};
3788
3851
  const { autoFetch = true } = opts;
3789
3852
  const { fetchWithAuth } = usePersonaContext();
3790
- const [workflow, setWorkflow] = useState16(null);
3791
- const [versions, setVersions] = useState16([]);
3792
- const [mermaid, setMermaid] = useState16(null);
3793
- const [isLoading, setIsLoading] = useState16(false);
3794
- const [error, setError] = useState16(null);
3795
- const fetchWorkflow = useCallback17(async () => {
3853
+ const [workflow, setWorkflow] = useState17(null);
3854
+ const [versions, setVersions] = useState17([]);
3855
+ const [mermaid, setMermaid] = useState17(null);
3856
+ const [isLoading, setIsLoading] = useState17(false);
3857
+ const [error, setError] = useState17(null);
3858
+ const fetchWorkflow = useCallback18(async () => {
3796
3859
  if (!workflowId) return null;
3797
3860
  setIsLoading(true);
3798
3861
  setError(null);
@@ -3812,7 +3875,7 @@ function useWorkflow(workflowId, options) {
3812
3875
  setIsLoading(false);
3813
3876
  }
3814
3877
  }, [fetchWithAuth, workflowId]);
3815
- const fetchVersions = useCallback17(async () => {
3878
+ const fetchVersions = useCallback18(async () => {
3816
3879
  if (!workflowId) return [];
3817
3880
  try {
3818
3881
  const res = await fetchWithAuth(`/workflows/${workflowId}/versions`);
@@ -3825,7 +3888,7 @@ function useWorkflow(workflowId, options) {
3825
3888
  return [];
3826
3889
  }
3827
3890
  }, [fetchWithAuth, workflowId]);
3828
- const getVersion = useCallback17(
3891
+ const getVersion = useCallback18(
3829
3892
  async (version) => {
3830
3893
  if (!workflowId) throw new Error("Workflow ID is required");
3831
3894
  const res = await fetchWithAuth(`/workflows/${workflowId}/versions/${version}`);
@@ -3836,7 +3899,7 @@ function useWorkflow(workflowId, options) {
3836
3899
  },
3837
3900
  [fetchWithAuth, workflowId]
3838
3901
  );
3839
- const fetchMermaid = useCallback17(async () => {
3902
+ const fetchMermaid = useCallback18(async () => {
3840
3903
  if (!workflowId) return "";
3841
3904
  try {
3842
3905
  const res = await fetchWithAuth(`/workflows/${workflowId}/mermaid`);
@@ -3849,7 +3912,7 @@ function useWorkflow(workflowId, options) {
3849
3912
  return "";
3850
3913
  }
3851
3914
  }, [fetchWithAuth, workflowId]);
3852
- const updateWorkflow = useCallback17(
3915
+ const updateWorkflow = useCallback18(
3853
3916
  async (input) => {
3854
3917
  if (!workflowId) throw new Error("Workflow ID is required");
3855
3918
  setError(null);
@@ -3868,7 +3931,7 @@ function useWorkflow(workflowId, options) {
3868
3931
  },
3869
3932
  [fetchWithAuth, workflowId]
3870
3933
  );
3871
- const saveDraft = useCallback17(
3934
+ const saveDraft = useCallback18(
3872
3935
  async (draft) => {
3873
3936
  if (!workflowId) throw new Error("Workflow ID is required");
3874
3937
  setError(null);
@@ -3887,7 +3950,7 @@ function useWorkflow(workflowId, options) {
3887
3950
  },
3888
3951
  [fetchWithAuth, workflowId]
3889
3952
  );
3890
- const publish = useCallback17(async () => {
3953
+ const publish = useCallback18(async () => {
3891
3954
  if (!workflowId) throw new Error("Workflow ID is required");
3892
3955
  setError(null);
3893
3956
  const res = await fetchWithAuth(`/workflows/${workflowId}/publish`, {
@@ -3902,7 +3965,7 @@ function useWorkflow(workflowId, options) {
3902
3965
  void fetchVersions();
3903
3966
  return versionResult;
3904
3967
  }, [fetchWithAuth, workflowId, fetchWorkflow, fetchVersions]);
3905
- const deleteWorkflow = useCallback17(async () => {
3968
+ const deleteWorkflow = useCallback18(async () => {
3906
3969
  if (!workflowId) throw new Error("Workflow ID is required");
3907
3970
  setError(null);
3908
3971
  const res = await fetchWithAuth(`/workflows/${workflowId}`, {
@@ -3936,25 +3999,25 @@ function useWorkflow(workflowId, options) {
3936
3999
  }
3937
4000
 
3938
4001
  // src/hooks/useWorkflowStream.ts
3939
- import { useCallback as useCallback18, useEffect as useEffect17, useRef as useRef4, useState as useState17 } from "react";
4002
+ import { useCallback as useCallback19, useEffect as useEffect17, useRef as useRef5, useState as useState18 } from "react";
3940
4003
  function useWorkflowStream(workflowId, options) {
3941
4004
  const { baseUrl, getAuthToken, fetchWithAuth, logger } = usePersonaContext();
3942
- const [status, setStatus] = useState17("idle");
3943
- const [runId, setRunId] = useState17(null);
3944
- const [activeNodeId, setActiveNodeId] = useState17(null);
3945
- const [nodeRuns, setNodeRuns] = useState17(
4005
+ const [status, setStatus] = useState18("idle");
4006
+ const [runId, setRunId] = useState18(null);
4007
+ const [activeNodeId, setActiveNodeId] = useState18(null);
4008
+ const [nodeRuns, setNodeRuns] = useState18(
3946
4009
  {}
3947
4010
  );
3948
- const [text, setText] = useState17("");
3949
- const [output, setOutput] = useState17(null);
3950
- const [error, setError] = useState17(null);
3951
- const [events, setEvents] = useState17([]);
3952
- const abortControllerRef = useRef4(null);
3953
- const currentRunIdRef = useRef4(null);
4011
+ const [text, setText] = useState18("");
4012
+ const [output, setOutput] = useState18(null);
4013
+ const [error, setError] = useState18(null);
4014
+ const [events, setEvents] = useState18([]);
4015
+ const abortControllerRef = useRef5(null);
4016
+ const currentRunIdRef = useRef5(null);
3954
4017
  currentRunIdRef.current = runId;
3955
- const optionsRef = useRef4(options);
4018
+ const optionsRef = useRef5(options);
3956
4019
  optionsRef.current = options;
3957
- const cancel = useCallback18(async () => {
4020
+ const cancel = useCallback19(async () => {
3958
4021
  if (abortControllerRef.current) {
3959
4022
  abortControllerRef.current.abort();
3960
4023
  abortControllerRef.current = null;
@@ -3975,7 +4038,7 @@ function useWorkflowStream(workflowId, options) {
3975
4038
  setStatus("cancelled");
3976
4039
  setActiveNodeId(null);
3977
4040
  }, [fetchWithAuth, logger]);
3978
- const reset = useCallback18(() => {
4041
+ const reset = useCallback19(() => {
3979
4042
  if (abortControllerRef.current) {
3980
4043
  abortControllerRef.current.abort();
3981
4044
  abortControllerRef.current = null;
@@ -3989,7 +4052,7 @@ function useWorkflowStream(workflowId, options) {
3989
4052
  setError(null);
3990
4053
  setEvents([]);
3991
4054
  }, []);
3992
- const processStream = useCallback18(
4055
+ const processStream = useCallback19(
3993
4056
  async (url, method, body, targetRunId) => {
3994
4057
  if (abortControllerRef.current) {
3995
4058
  abortControllerRef.current.abort();
@@ -4154,7 +4217,7 @@ function useWorkflowStream(workflowId, options) {
4154
4217
  },
4155
4218
  [getAuthToken]
4156
4219
  );
4157
- const start = useCallback18(
4220
+ const start = useCallback19(
4158
4221
  async (input, opts) => {
4159
4222
  const targetWfId = opts?.workflowId || workflowId;
4160
4223
  if (!targetWfId) {
@@ -4175,7 +4238,7 @@ function useWorkflowStream(workflowId, options) {
4175
4238
  },
4176
4239
  [workflowId, baseUrl, processStream]
4177
4240
  );
4178
- const resume = useCallback18(
4241
+ const resume = useCallback19(
4179
4242
  async (targetRunId, sinceSeq) => {
4180
4243
  if (!targetRunId) {
4181
4244
  throw new Error("Run ID is required to resume stream");
@@ -4213,21 +4276,21 @@ function useWorkflowStream(workflowId, options) {
4213
4276
  }
4214
4277
 
4215
4278
  // src/hooks/useWorkflowRuns.ts
4216
- import { useCallback as useCallback19, useEffect as useEffect18, useState as useState18 } from "react";
4279
+ import { useCallback as useCallback20, useEffect as useEffect18, useState as useState19 } from "react";
4217
4280
  function useWorkflowRuns(workflowId, options) {
4218
4281
  const opts = typeof options === "boolean" ? { autoFetch: options } : options ?? {};
4219
4282
  const { autoFetch = true, page = 1, limit = 20 } = opts;
4220
4283
  const { fetchWithAuth } = usePersonaContext();
4221
- const [runs, setRuns] = useState18([]);
4222
- const [pagination, setPagination] = useState18({
4284
+ const [runs, setRuns] = useState19([]);
4285
+ const [pagination, setPagination] = useState19({
4223
4286
  page,
4224
4287
  limit,
4225
4288
  total: 0,
4226
4289
  totalPages: 0
4227
4290
  });
4228
- const [isLoading, setIsLoading] = useState18(false);
4229
- const [error, setError] = useState18(null);
4230
- const fetchRuns = useCallback19(async () => {
4291
+ const [isLoading, setIsLoading] = useState19(false);
4292
+ const [error, setError] = useState19(null);
4293
+ const fetchRuns = useCallback20(async () => {
4231
4294
  if (!workflowId) return [];
4232
4295
  setIsLoading(true);
4233
4296
  setError(null);
@@ -4259,7 +4322,7 @@ function useWorkflowRuns(workflowId, options) {
4259
4322
  setIsLoading(false);
4260
4323
  }
4261
4324
  }, [fetchWithAuth, workflowId, page, limit]);
4262
- const getRun = useCallback19(
4325
+ const getRun = useCallback20(
4263
4326
  async (runId) => {
4264
4327
  if (!runId) throw new Error("Run ID is required");
4265
4328
  const res = await fetchWithAuth(`/workflows/runs/${runId}`);
@@ -4270,7 +4333,7 @@ function useWorkflowRuns(workflowId, options) {
4270
4333
  },
4271
4334
  [fetchWithAuth]
4272
4335
  );
4273
- const cancelRun = useCallback19(
4336
+ const cancelRun = useCallback20(
4274
4337
  async (runId) => {
4275
4338
  if (!runId) throw new Error("Run ID is required");
4276
4339
  const res = await fetchWithAuth(`/workflows/runs/${runId}/cancel`, {
@@ -4309,7 +4372,7 @@ import {
4309
4372
  getLogLevel,
4310
4373
  isLevelEnabled
4311
4374
  } from "@personaai/logger";
4312
- var VERSION = "0.10.0";
4375
+ var VERSION = "0.18.0";
4313
4376
  export {
4314
4377
  ARCHITECT_AGENT_ID,
4315
4378
  PersonaProvider,
@@ -4331,6 +4394,7 @@ export {
4331
4394
  useMcpAdmin,
4332
4395
  useMcpConnections,
4333
4396
  useMemory,
4397
+ useMessages,
4334
4398
  usePersonaContext,
4335
4399
  useRcpSources,
4336
4400
  useSkills,