@personaai/react 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -48,7 +48,8 @@ __export(index_exports, {
48
48
  useWorkflow: () => useWorkflow,
49
49
  useWorkflowRuns: () => useWorkflowRuns,
50
50
  useWorkflowStream: () => useWorkflowStream,
51
- useWorkflows: () => useWorkflows
51
+ useWorkflows: () => useWorkflows,
52
+ useWorkspaceFiles: () => useWorkspaceFiles
52
53
  });
53
54
  module.exports = __toCommonJS(index_exports);
54
55
 
@@ -1943,8 +1944,110 @@ function useThreads(autoFetch = true) {
1943
1944
  };
1944
1945
  }
1945
1946
 
1946
- // src/hooks/useVoice.ts
1947
+ // src/hooks/useWorkspaceFiles.ts
1947
1948
  var import_react6 = require("react");
1949
+ function useWorkspaceFiles(threadId, autoFetch = true) {
1950
+ const { fetchWithAuth } = usePersonaContext();
1951
+ const [files, setFiles] = (0, import_react6.useState)({});
1952
+ const [isLoading, setIsLoading] = (0, import_react6.useState)(false);
1953
+ const [isSaving, setIsSaving] = (0, import_react6.useState)(false);
1954
+ const [error, setError] = (0, import_react6.useState)(null);
1955
+ const fetchFiles = (0, import_react6.useCallback)(async () => {
1956
+ if (!threadId) return {};
1957
+ setIsLoading(true);
1958
+ setError(null);
1959
+ try {
1960
+ const res = await fetchWithAuth(`/threads/${threadId}/files`);
1961
+ if (!res.ok) throw new Error(`Failed to list workspace files: ${res.statusText}`);
1962
+ const data = await res.json();
1963
+ const normalized = normalizeWorkspaceFiles(data?.data ?? data ?? {});
1964
+ setFiles(normalized);
1965
+ return normalized;
1966
+ } catch (err) {
1967
+ const errorObj = err instanceof Error ? err : new Error(String(err));
1968
+ setError(errorObj);
1969
+ return {};
1970
+ } finally {
1971
+ setIsLoading(false);
1972
+ }
1973
+ }, [fetchWithAuth, threadId]);
1974
+ const getFile = (0, import_react6.useCallback)(
1975
+ async (path) => {
1976
+ if (!threadId) throw new Error("useWorkspaceFiles: no threadId set");
1977
+ const res = await fetchWithAuth(
1978
+ `/threads/${threadId}/file?path=${encodeURIComponent(path)}`
1979
+ );
1980
+ if (!res.ok) throw new Error(`Failed to read workspace file: ${res.statusText}`);
1981
+ const data = await res.json();
1982
+ const raw = data?.data ?? data;
1983
+ return normalizeWorkspaceFiles({ [path]: raw })[path];
1984
+ },
1985
+ [fetchWithAuth, threadId]
1986
+ );
1987
+ const writeFile = (0, import_react6.useCallback)(
1988
+ async (path, content) => {
1989
+ if (!threadId) throw new Error("useWorkspaceFiles: no threadId set");
1990
+ setIsSaving(true);
1991
+ setError(null);
1992
+ try {
1993
+ const res = await fetchWithAuth(`/threads/${threadId}/file`, {
1994
+ method: "PUT",
1995
+ headers: { "Content-Type": "application/json" },
1996
+ body: JSON.stringify({ path, content })
1997
+ });
1998
+ if (!res.ok) throw new Error(`Failed to write workspace file: ${res.statusText}`);
1999
+ const data = await res.json();
2000
+ const raw = data?.data ?? data;
2001
+ const file = normalizeWorkspaceFiles({ [path]: raw })[path];
2002
+ setFiles((prev) => ({ ...prev, [path]: file }));
2003
+ return file;
2004
+ } catch (err) {
2005
+ const errorObj = err instanceof Error ? err : new Error(String(err));
2006
+ setError(errorObj);
2007
+ throw errorObj;
2008
+ } finally {
2009
+ setIsSaving(false);
2010
+ }
2011
+ },
2012
+ [fetchWithAuth, threadId]
2013
+ );
2014
+ const deleteFile = (0, import_react6.useCallback)(
2015
+ async (path) => {
2016
+ if (!threadId) throw new Error("useWorkspaceFiles: no threadId set");
2017
+ const res = await fetchWithAuth(
2018
+ `/threads/${threadId}/file?path=${encodeURIComponent(path)}`,
2019
+ { method: "DELETE" }
2020
+ );
2021
+ if (!res.ok) throw new Error(`Failed to delete workspace file: ${res.statusText}`);
2022
+ setFiles((prev) => {
2023
+ const next = { ...prev };
2024
+ delete next[path];
2025
+ return next;
2026
+ });
2027
+ },
2028
+ [fetchWithAuth, threadId]
2029
+ );
2030
+ (0, import_react6.useEffect)(() => {
2031
+ if (autoFetch && threadId) {
2032
+ void fetchFiles();
2033
+ } else if (!threadId) {
2034
+ setFiles({});
2035
+ }
2036
+ }, [autoFetch, threadId, fetchFiles]);
2037
+ return {
2038
+ files,
2039
+ isLoading,
2040
+ isSaving,
2041
+ error,
2042
+ refetch: fetchFiles,
2043
+ getFile,
2044
+ writeFile,
2045
+ deleteFile
2046
+ };
2047
+ }
2048
+
2049
+ // src/hooks/useVoice.ts
2050
+ var import_react7 = require("react");
1948
2051
 
1949
2052
  // src/hooks/voiceWorklets.ts
1950
2053
  var RECORDER_WORKLET_SOURCE = `
@@ -2047,42 +2150,42 @@ function mergeTranscriptText(prev, next) {
2047
2150
  }
2048
2151
  function useVoice(options = {}) {
2049
2152
  const { defaultAgentId, fetchWithAuth, logger } = usePersonaContext();
2050
- const voiceLogger = (0, import_react6.useMemo)(() => logger.child("voice"), [logger]);
2153
+ const voiceLogger = (0, import_react7.useMemo)(() => logger.child("voice"), [logger]);
2051
2154
  const agentId = options.agentId || defaultAgentId;
2052
2155
  const threadId = options.threadId;
2053
2156
  const contextOverride = options.contextOverride;
2054
2157
  const context = options.context;
2055
- const [state, setState] = (0, import_react6.useState)("idle");
2056
- const [isMuted, setIsMuted] = (0, import_react6.useState)(false);
2057
- const [transcript, setTranscript] = (0, import_react6.useState)(
2158
+ const [state, setState] = (0, import_react7.useState)("idle");
2159
+ const [isMuted, setIsMuted] = (0, import_react7.useState)(false);
2160
+ const [transcript, setTranscript] = (0, import_react7.useState)(
2058
2161
  []
2059
2162
  );
2060
- const [partial, setPartial] = (0, import_react6.useState)(
2163
+ const [partial, setPartial] = (0, import_react7.useState)(
2061
2164
  null
2062
2165
  );
2063
- const [toolCalls, setToolCalls] = (0, import_react6.useState)([]);
2064
- const [error, setError] = (0, import_react6.useState)(null);
2065
- const [endReason, setEndReason] = (0, import_react6.useState)(
2166
+ const [toolCalls, setToolCalls] = (0, import_react7.useState)([]);
2167
+ const [error, setError] = (0, import_react7.useState)(null);
2168
+ const [endReason, setEndReason] = (0, import_react7.useState)(
2066
2169
  null
2067
2170
  );
2068
- const wsRef = (0, import_react6.useRef)(null);
2069
- const streamRef = (0, import_react6.useRef)(null);
2070
- const inputCtxRef = (0, import_react6.useRef)(null);
2071
- const outputCtxRef = (0, import_react6.useRef)(null);
2072
- const recorderNodeRef = (0, import_react6.useRef)(null);
2073
- const playerNodeRef = (0, import_react6.useRef)(null);
2074
- const acceptedTurnSeqRef = (0, import_react6.useRef)(0);
2075
- const mountedRef = (0, import_react6.useRef)(true);
2076
- const lastFinalTurnRef = (0, import_react6.useRef)(
2171
+ const wsRef = (0, import_react7.useRef)(null);
2172
+ const streamRef = (0, import_react7.useRef)(null);
2173
+ const inputCtxRef = (0, import_react7.useRef)(null);
2174
+ const outputCtxRef = (0, import_react7.useRef)(null);
2175
+ const recorderNodeRef = (0, import_react7.useRef)(null);
2176
+ const playerNodeRef = (0, import_react7.useRef)(null);
2177
+ const acceptedTurnSeqRef = (0, import_react7.useRef)(0);
2178
+ const mountedRef = (0, import_react7.useRef)(true);
2179
+ const lastFinalTurnRef = (0, import_react7.useRef)(
2077
2180
  null
2078
2181
  );
2079
- (0, import_react6.useEffect)(() => {
2182
+ (0, import_react7.useEffect)(() => {
2080
2183
  mountedRef.current = true;
2081
2184
  return () => {
2082
2185
  mountedRef.current = false;
2083
2186
  };
2084
2187
  }, []);
2085
- const teardownAudio = (0, import_react6.useCallback)(() => {
2188
+ const teardownAudio = (0, import_react7.useCallback)(() => {
2086
2189
  try {
2087
2190
  streamRef.current?.getTracks().forEach((track) => track.stop());
2088
2191
  } catch {
@@ -2109,7 +2212,7 @@ function useVoice(options = {}) {
2109
2212
  }
2110
2213
  outputCtxRef.current = null;
2111
2214
  }, []);
2112
- const stop = (0, import_react6.useCallback)(() => {
2215
+ const stop = (0, import_react7.useCallback)(() => {
2113
2216
  voiceLogger.debug("stop() called");
2114
2217
  try {
2115
2218
  wsRef.current?.close(1e3, "client_stop");
@@ -2119,8 +2222,8 @@ function useVoice(options = {}) {
2119
2222
  teardownAudio();
2120
2223
  if (mountedRef.current) setState("idle");
2121
2224
  }, [teardownAudio, voiceLogger]);
2122
- (0, import_react6.useEffect)(() => stop, [stop]);
2123
- const startCapture = (0, import_react6.useCallback)(async (inputSampleRate) => {
2225
+ (0, import_react7.useEffect)(() => stop, [stop]);
2226
+ const startCapture = (0, import_react7.useCallback)(async (inputSampleRate) => {
2124
2227
  const stream = await navigator.mediaDevices.getUserMedia({
2125
2228
  audio: {
2126
2229
  echoCancellation: true,
@@ -2146,7 +2249,7 @@ function useVoice(options = {}) {
2146
2249
  recorderNodeRef.current = recorderNode;
2147
2250
  source.connect(recorderNode);
2148
2251
  }, []);
2149
- const setupPlayback = (0, import_react6.useCallback)(async (outputSampleRate) => {
2252
+ const setupPlayback = (0, import_react7.useCallback)(async (outputSampleRate) => {
2150
2253
  const outputCtx = new AudioContext({ sampleRate: outputSampleRate });
2151
2254
  outputCtxRef.current = outputCtx;
2152
2255
  await outputCtx.audioWorklet.addModule(playerWorkletUrl());
@@ -2154,7 +2257,7 @@ function useVoice(options = {}) {
2154
2257
  playerNode.connect(outputCtx.destination);
2155
2258
  playerNodeRef.current = playerNode;
2156
2259
  }, []);
2157
- const upsertToolCall = (0, import_react6.useCallback)(
2260
+ const upsertToolCall = (0, import_react7.useCallback)(
2158
2261
  (id, patch) => {
2159
2262
  setToolCalls((prev) => {
2160
2263
  const idx = prev.findIndex((t) => t.id === id);
@@ -2166,7 +2269,7 @@ function useVoice(options = {}) {
2166
2269
  },
2167
2270
  []
2168
2271
  );
2169
- const handleTranscript = (0, import_react6.useCallback)((value) => {
2272
+ const handleTranscript = (0, import_react7.useCallback)((value) => {
2170
2273
  const { speaker, text, isFinal, turnSeq } = value;
2171
2274
  if (!isFinal) {
2172
2275
  setPartial({ id: "partial", speaker, text });
@@ -2189,7 +2292,7 @@ function useVoice(options = {}) {
2189
2292
  });
2190
2293
  lastFinalTurnRef.current = { speaker, turnSeq };
2191
2294
  }, []);
2192
- const handleCustomEvent = (0, import_react6.useCallback)(
2295
+ const handleCustomEvent = (0, import_react7.useCallback)(
2193
2296
  (name, value) => {
2194
2297
  switch (name) {
2195
2298
  case "voice_session_ready":
@@ -2247,7 +2350,7 @@ function useVoice(options = {}) {
2247
2350
  },
2248
2351
  [handleTranscript, setupPlayback, startCapture, teardownAudio, voiceLogger]
2249
2352
  );
2250
- const handleMessage = (0, import_react6.useCallback)(
2353
+ const handleMessage = (0, import_react7.useCallback)(
2251
2354
  (event) => {
2252
2355
  if (typeof event.data !== "string") {
2253
2356
  const buf = event.data;
@@ -2305,7 +2408,7 @@ function useVoice(options = {}) {
2305
2408
  },
2306
2409
  [handleCustomEvent, upsertToolCall, voiceLogger]
2307
2410
  );
2308
- const start = (0, import_react6.useCallback)(async () => {
2411
+ const start = (0, import_react7.useCallback)(async () => {
2309
2412
  if (!agentId) {
2310
2413
  const err = new Error(
2311
2414
  "useVoice: no agentId provided and no defaultAgentId set on PersonaProvider"
@@ -2372,17 +2475,17 @@ function useVoice(options = {}) {
2372
2475
  teardownAudio();
2373
2476
  }
2374
2477
  }, [agentId, threadId, contextOverride, context, fetchWithAuth, handleMessage, teardownAudio, voiceLogger]);
2375
- const mute = (0, import_react6.useCallback)((muted) => {
2478
+ const mute = (0, import_react7.useCallback)((muted) => {
2376
2479
  setIsMuted(muted);
2377
2480
  streamRef.current?.getAudioTracks().forEach((track) => {
2378
2481
  track.enabled = !muted;
2379
2482
  });
2380
2483
  }, []);
2381
- const sendText = (0, import_react6.useCallback)((text) => {
2484
+ const sendText = (0, import_react7.useCallback)((text) => {
2382
2485
  if (!text?.trim() || wsRef.current?.readyState !== WebSocket.OPEN) return;
2383
2486
  wsRef.current.send(JSON.stringify({ type: "voice.text", text }));
2384
2487
  }, []);
2385
- const updateContext = (0, import_react6.useCallback)((newContext) => {
2488
+ const updateContext = (0, import_react7.useCallback)((newContext) => {
2386
2489
  if (wsRef.current?.readyState !== WebSocket.OPEN) return;
2387
2490
  wsRef.current.send(JSON.stringify({ type: "voice.context", context: newContext }));
2388
2491
  }, []);
@@ -2403,14 +2506,14 @@ function useVoice(options = {}) {
2403
2506
  }
2404
2507
 
2405
2508
  // src/hooks/useFiles.ts
2406
- var import_react7 = require("react");
2509
+ var import_react8 = require("react");
2407
2510
  function useFiles(autoFetch = true) {
2408
2511
  const { fetchWithAuth } = usePersonaContext();
2409
- const [files, setFiles] = (0, import_react7.useState)([]);
2410
- const [isLoading, setIsLoading] = (0, import_react7.useState)(false);
2411
- const [isUploading, setIsUploading] = (0, import_react7.useState)(false);
2412
- const [error, setError] = (0, import_react7.useState)(null);
2413
- const fetchFiles = (0, import_react7.useCallback)(async () => {
2512
+ const [files, setFiles] = (0, import_react8.useState)([]);
2513
+ const [isLoading, setIsLoading] = (0, import_react8.useState)(false);
2514
+ const [isUploading, setIsUploading] = (0, import_react8.useState)(false);
2515
+ const [error, setError] = (0, import_react8.useState)(null);
2516
+ const fetchFiles = (0, import_react8.useCallback)(async () => {
2414
2517
  setIsLoading(true);
2415
2518
  setError(null);
2416
2519
  try {
@@ -2428,7 +2531,7 @@ function useFiles(autoFetch = true) {
2428
2531
  setIsLoading(false);
2429
2532
  }
2430
2533
  }, [fetchWithAuth]);
2431
- const uploadFile = (0, import_react7.useCallback)(
2534
+ const uploadFile = (0, import_react8.useCallback)(
2432
2535
  async (fileOrFormData) => {
2433
2536
  setIsUploading(true);
2434
2537
  setError(null);
@@ -2461,7 +2564,7 @@ function useFiles(autoFetch = true) {
2461
2564
  },
2462
2565
  [fetchWithAuth, fetchFiles]
2463
2566
  );
2464
- const deleteFile = (0, import_react7.useCallback)(
2567
+ const deleteFile = (0, import_react8.useCallback)(
2465
2568
  async (fileId) => {
2466
2569
  const res = await fetchWithAuth(`/files/${fileId}`, { method: "DELETE" });
2467
2570
  if (!res.ok) throw new Error(`Failed to delete file: ${res.statusText}`);
@@ -2469,7 +2572,7 @@ function useFiles(autoFetch = true) {
2469
2572
  },
2470
2573
  [fetchWithAuth]
2471
2574
  );
2472
- const bulkDeleteFiles = (0, import_react7.useCallback)(
2575
+ const bulkDeleteFiles = (0, import_react8.useCallback)(
2473
2576
  async (fileIds) => {
2474
2577
  const res = await fetchWithAuth("/files/bulk-delete", {
2475
2578
  method: "POST",
@@ -2484,10 +2587,10 @@ function useFiles(autoFetch = true) {
2484
2587
  },
2485
2588
  [fetchWithAuth]
2486
2589
  );
2487
- const getDownloadUrl = (0, import_react7.useCallback)((fileId) => {
2590
+ const getDownloadUrl = (0, import_react8.useCallback)((fileId) => {
2488
2591
  return `/files/${fileId}`;
2489
2592
  }, []);
2490
- (0, import_react7.useEffect)(() => {
2593
+ (0, import_react8.useEffect)(() => {
2491
2594
  if (autoFetch) {
2492
2595
  void fetchFiles();
2493
2596
  }
@@ -2506,21 +2609,21 @@ function useFiles(autoFetch = true) {
2506
2609
  }
2507
2610
 
2508
2611
  // src/hooks/useAgents.ts
2509
- var import_react8 = require("react");
2612
+ var import_react9 = require("react");
2510
2613
  function useAgents(options = true) {
2511
2614
  const opts = typeof options === "boolean" ? { autoFetch: options } : options;
2512
2615
  const { autoFetch = true, page, limit, search, category, scope } = opts;
2513
2616
  const { fetchWithAuth } = usePersonaContext();
2514
- const [agents, setAgents] = (0, import_react8.useState)([]);
2515
- const [pagination, setPagination] = (0, import_react8.useState)({
2617
+ const [agents, setAgents] = (0, import_react9.useState)([]);
2618
+ const [pagination, setPagination] = (0, import_react9.useState)({
2516
2619
  total: 0,
2517
2620
  page: page ?? 1,
2518
2621
  limit: limit ?? 20,
2519
2622
  pages: 0
2520
2623
  });
2521
- const [isLoading, setIsLoading] = (0, import_react8.useState)(false);
2522
- const [error, setError] = (0, import_react8.useState)(null);
2523
- const fetchAgents = (0, import_react8.useCallback)(async () => {
2624
+ const [isLoading, setIsLoading] = (0, import_react9.useState)(false);
2625
+ const [error, setError] = (0, import_react9.useState)(null);
2626
+ const fetchAgents = (0, import_react9.useCallback)(async () => {
2524
2627
  setIsLoading(true);
2525
2628
  setError(null);
2526
2629
  try {
@@ -2548,7 +2651,7 @@ function useAgents(options = true) {
2548
2651
  setIsLoading(false);
2549
2652
  }
2550
2653
  }, [fetchWithAuth, page, limit, search, category, scope]);
2551
- const getAgent = (0, import_react8.useCallback)(
2654
+ const getAgent = (0, import_react9.useCallback)(
2552
2655
  async (agentId) => {
2553
2656
  const res = await fetchWithAuth(`/agents/${agentId}`);
2554
2657
  if (!res.ok) throw new Error(`Failed to fetch agent: ${res.statusText}`);
@@ -2556,7 +2659,7 @@ function useAgents(options = true) {
2556
2659
  },
2557
2660
  [fetchWithAuth]
2558
2661
  );
2559
- const createAgent = (0, import_react8.useCallback)(
2662
+ const createAgent = (0, import_react9.useCallback)(
2560
2663
  async (input) => {
2561
2664
  setError(null);
2562
2665
  try {
@@ -2580,7 +2683,7 @@ function useAgents(options = true) {
2580
2683
  },
2581
2684
  [fetchWithAuth]
2582
2685
  );
2583
- const updateAgent = (0, import_react8.useCallback)(
2686
+ const updateAgent = (0, import_react9.useCallback)(
2584
2687
  async (agentId, input) => {
2585
2688
  setError(null);
2586
2689
  try {
@@ -2604,7 +2707,7 @@ function useAgents(options = true) {
2604
2707
  },
2605
2708
  [fetchWithAuth]
2606
2709
  );
2607
- const deleteAgent = (0, import_react8.useCallback)(
2710
+ const deleteAgent = (0, import_react9.useCallback)(
2608
2711
  async (agentId) => {
2609
2712
  setError(null);
2610
2713
  try {
@@ -2622,7 +2725,7 @@ function useAgents(options = true) {
2622
2725
  },
2623
2726
  [fetchWithAuth]
2624
2727
  );
2625
- const bulkDeleteAgents = (0, import_react8.useCallback)(
2728
+ const bulkDeleteAgents = (0, import_react9.useCallback)(
2626
2729
  async (ids) => {
2627
2730
  setError(null);
2628
2731
  try {
@@ -2647,7 +2750,7 @@ function useAgents(options = true) {
2647
2750
  },
2648
2751
  [fetchWithAuth]
2649
2752
  );
2650
- (0, import_react8.useEffect)(() => {
2753
+ (0, import_react9.useEffect)(() => {
2651
2754
  if (autoFetch) void fetchAgents();
2652
2755
  }, [autoFetch, fetchAgents]);
2653
2756
  return {
@@ -2665,13 +2768,13 @@ function useAgents(options = true) {
2665
2768
  }
2666
2769
 
2667
2770
  // src/hooks/useConnection.ts
2668
- var import_react9 = require("react");
2771
+ var import_react10 = require("react");
2669
2772
  function useConnection(autoCheck = true) {
2670
2773
  const { fetchWithAuth } = usePersonaContext();
2671
- const [health, setHealth] = (0, import_react9.useState)(null);
2672
- const [isConnected, setIsConnected] = (0, import_react9.useState)(false);
2673
- const [isLoading, setIsLoading] = (0, import_react9.useState)(false);
2674
- const checkHealth = (0, import_react9.useCallback)(async () => {
2774
+ const [health, setHealth] = (0, import_react10.useState)(null);
2775
+ const [isConnected, setIsConnected] = (0, import_react10.useState)(false);
2776
+ const [isLoading, setIsLoading] = (0, import_react10.useState)(false);
2777
+ const checkHealth = (0, import_react10.useCallback)(async () => {
2675
2778
  setIsLoading(true);
2676
2779
  try {
2677
2780
  const res = await fetchWithAuth("/health");
@@ -2690,7 +2793,7 @@ function useConnection(autoCheck = true) {
2690
2793
  setIsLoading(false);
2691
2794
  }
2692
2795
  }, [fetchWithAuth]);
2693
- (0, import_react9.useEffect)(() => {
2796
+ (0, import_react10.useEffect)(() => {
2694
2797
  if (autoCheck) {
2695
2798
  void checkHealth();
2696
2799
  }
@@ -2704,15 +2807,15 @@ function useConnection(autoCheck = true) {
2704
2807
  }
2705
2808
 
2706
2809
  // src/hooks/useMcpConnections.ts
2707
- var import_react10 = require("react");
2810
+ var import_react11 = require("react");
2708
2811
  function useMcpConnections(options = {}) {
2709
2812
  const { defaultAgentId, fetchWithAuth } = usePersonaContext();
2710
2813
  const agentId = options.agentId ?? defaultAgentId;
2711
2814
  const autoFetch = options.autoFetch ?? true;
2712
- const [connections, setConnections] = (0, import_react10.useState)([]);
2713
- const [isLoading, setIsLoading] = (0, import_react10.useState)(false);
2714
- const [error, setError] = (0, import_react10.useState)(null);
2715
- const fetchConnections = (0, import_react10.useCallback)(async () => {
2815
+ const [connections, setConnections] = (0, import_react11.useState)([]);
2816
+ const [isLoading, setIsLoading] = (0, import_react11.useState)(false);
2817
+ const [error, setError] = (0, import_react11.useState)(null);
2818
+ const fetchConnections = (0, import_react11.useCallback)(async () => {
2716
2819
  if (!agentId) return [];
2717
2820
  setIsLoading(true);
2718
2821
  setError(null);
@@ -2736,8 +2839,8 @@ function useMcpConnections(options = {}) {
2736
2839
  setIsLoading(false);
2737
2840
  }
2738
2841
  }, [agentId, fetchWithAuth, options.returnTo]);
2739
- const [isDisconnecting, setIsDisconnecting] = (0, import_react10.useState)(false);
2740
- const disconnect = (0, import_react10.useCallback)(
2842
+ const [isDisconnecting, setIsDisconnecting] = (0, import_react11.useState)(false);
2843
+ const disconnect = (0, import_react11.useCallback)(
2741
2844
  async (mcpId) => {
2742
2845
  setIsDisconnecting(true);
2743
2846
  setError(null);
@@ -2763,7 +2866,7 @@ function useMcpConnections(options = {}) {
2763
2866
  },
2764
2867
  [fetchWithAuth, fetchConnections]
2765
2868
  );
2766
- (0, import_react10.useEffect)(() => {
2869
+ (0, import_react11.useEffect)(() => {
2767
2870
  if (autoFetch) void fetchConnections();
2768
2871
  }, [autoFetch, fetchConnections]);
2769
2872
  return {
@@ -2779,11 +2882,11 @@ function useMcpConnections(options = {}) {
2779
2882
  }
2780
2883
 
2781
2884
  // src/hooks/useMcp.ts
2782
- var import_react11 = require("react");
2885
+ var import_react12 = require("react");
2783
2886
  function useMcp(options = {}) {
2784
2887
  const { fetchWithAuth } = usePersonaContext();
2785
2888
  const defaultMcpId = options.mcpId;
2786
- const readResource = (0, import_react11.useCallback)(
2889
+ const readResource = (0, import_react12.useCallback)(
2787
2890
  async (uri, mcpId) => {
2788
2891
  const id = mcpId ?? defaultMcpId;
2789
2892
  if (!id) throw new Error("MCP server ID is required to read resource");
@@ -2797,7 +2900,7 @@ function useMcp(options = {}) {
2797
2900
  },
2798
2901
  [fetchWithAuth, defaultMcpId]
2799
2902
  );
2800
- const callTool = (0, import_react11.useCallback)(
2903
+ const callTool = (0, import_react12.useCallback)(
2801
2904
  async (name, args, mcpId) => {
2802
2905
  const id = mcpId ?? defaultMcpId;
2803
2906
  if (!id) throw new Error("MCP server ID is required to call tool");
@@ -2820,20 +2923,20 @@ function useMcp(options = {}) {
2820
2923
  }
2821
2924
 
2822
2925
  // src/hooks/useSkills.ts
2823
- var import_react12 = require("react");
2926
+ var import_react13 = require("react");
2824
2927
  function useSkills(options = {}) {
2825
2928
  const { autoFetch = true, page, limit, search, scope } = options;
2826
2929
  const { fetchWithAuth } = usePersonaContext();
2827
- const [skills, setSkills] = (0, import_react12.useState)([]);
2828
- const [pagination, setPagination] = (0, import_react12.useState)({
2930
+ const [skills, setSkills] = (0, import_react13.useState)([]);
2931
+ const [pagination, setPagination] = (0, import_react13.useState)({
2829
2932
  total: 0,
2830
2933
  page: page ?? 1,
2831
2934
  limit: limit ?? 20,
2832
2935
  pages: 0
2833
2936
  });
2834
- const [isLoading, setIsLoading] = (0, import_react12.useState)(false);
2835
- const [error, setError] = (0, import_react12.useState)(null);
2836
- const fetchSkills = (0, import_react12.useCallback)(async () => {
2937
+ const [isLoading, setIsLoading] = (0, import_react13.useState)(false);
2938
+ const [error, setError] = (0, import_react13.useState)(null);
2939
+ const fetchSkills = (0, import_react13.useCallback)(async () => {
2837
2940
  setIsLoading(true);
2838
2941
  setError(null);
2839
2942
  try {
@@ -2860,7 +2963,7 @@ function useSkills(options = {}) {
2860
2963
  setIsLoading(false);
2861
2964
  }
2862
2965
  }, [fetchWithAuth, page, limit, search, scope]);
2863
- const getSkill = (0, import_react12.useCallback)(
2966
+ const getSkill = (0, import_react13.useCallback)(
2864
2967
  async (skillId) => {
2865
2968
  const res = await fetchWithAuth(`/skills/${skillId}`);
2866
2969
  if (!res.ok) throw new Error(`Failed to fetch skill: ${res.statusText}`);
@@ -2868,7 +2971,7 @@ function useSkills(options = {}) {
2868
2971
  },
2869
2972
  [fetchWithAuth]
2870
2973
  );
2871
- const createSkill = (0, import_react12.useCallback)(
2974
+ const createSkill = (0, import_react13.useCallback)(
2872
2975
  async (input) => {
2873
2976
  setError(null);
2874
2977
  try {
@@ -2892,7 +2995,7 @@ function useSkills(options = {}) {
2892
2995
  },
2893
2996
  [fetchWithAuth]
2894
2997
  );
2895
- const updateSkill = (0, import_react12.useCallback)(
2998
+ const updateSkill = (0, import_react13.useCallback)(
2896
2999
  async (skillId, input) => {
2897
3000
  setError(null);
2898
3001
  try {
@@ -2916,7 +3019,7 @@ function useSkills(options = {}) {
2916
3019
  },
2917
3020
  [fetchWithAuth]
2918
3021
  );
2919
- const deleteSkill = (0, import_react12.useCallback)(
3022
+ const deleteSkill = (0, import_react13.useCallback)(
2920
3023
  async (skillId) => {
2921
3024
  setError(null);
2922
3025
  try {
@@ -2934,7 +3037,7 @@ function useSkills(options = {}) {
2934
3037
  },
2935
3038
  [fetchWithAuth]
2936
3039
  );
2937
- const bulkDeleteSkills = (0, import_react12.useCallback)(
3040
+ const bulkDeleteSkills = (0, import_react13.useCallback)(
2938
3041
  async (ids) => {
2939
3042
  setError(null);
2940
3043
  try {
@@ -2959,7 +3062,7 @@ function useSkills(options = {}) {
2959
3062
  },
2960
3063
  [fetchWithAuth]
2961
3064
  );
2962
- const getSkillUsage = (0, import_react12.useCallback)(
3065
+ const getSkillUsage = (0, import_react13.useCallback)(
2963
3066
  async (skillId) => {
2964
3067
  const res = await fetchWithAuth(`/skills/${skillId}/usage`);
2965
3068
  if (!res.ok) throw new Error(`Failed to fetch skill usage: ${res.statusText}`);
@@ -2967,7 +3070,7 @@ function useSkills(options = {}) {
2967
3070
  },
2968
3071
  [fetchWithAuth]
2969
3072
  );
2970
- (0, import_react12.useEffect)(() => {
3073
+ (0, import_react13.useEffect)(() => {
2971
3074
  if (autoFetch) void fetchSkills();
2972
3075
  }, [autoFetch, fetchSkills]);
2973
3076
  return {
@@ -2986,20 +3089,20 @@ function useSkills(options = {}) {
2986
3089
  }
2987
3090
 
2988
3091
  // src/hooks/useRcpSources.ts
2989
- var import_react13 = require("react");
3092
+ var import_react14 = require("react");
2990
3093
  function useRcpSources(options = {}) {
2991
3094
  const { autoFetch = true, page, limit, search } = options;
2992
3095
  const { fetchWithAuth } = usePersonaContext();
2993
- const [rcpSources, setRcpSources] = (0, import_react13.useState)([]);
2994
- const [pagination, setPagination] = (0, import_react13.useState)({
3096
+ const [rcpSources, setRcpSources] = (0, import_react14.useState)([]);
3097
+ const [pagination, setPagination] = (0, import_react14.useState)({
2995
3098
  total: 0,
2996
3099
  page: page ?? 1,
2997
3100
  limit: limit ?? 20,
2998
3101
  pages: 0
2999
3102
  });
3000
- const [isLoading, setIsLoading] = (0, import_react13.useState)(false);
3001
- const [error, setError] = (0, import_react13.useState)(null);
3002
- const fetchRcpSources = (0, import_react13.useCallback)(async () => {
3103
+ const [isLoading, setIsLoading] = (0, import_react14.useState)(false);
3104
+ const [error, setError] = (0, import_react14.useState)(null);
3105
+ const fetchRcpSources = (0, import_react14.useCallback)(async () => {
3003
3106
  setIsLoading(true);
3004
3107
  setError(null);
3005
3108
  try {
@@ -3025,7 +3128,7 @@ function useRcpSources(options = {}) {
3025
3128
  setIsLoading(false);
3026
3129
  }
3027
3130
  }, [fetchWithAuth, page, limit, search]);
3028
- const getRcpSource = (0, import_react13.useCallback)(
3131
+ const getRcpSource = (0, import_react14.useCallback)(
3029
3132
  async (sourceId) => {
3030
3133
  const res = await fetchWithAuth(`/rcp-sources/${sourceId}`);
3031
3134
  if (!res.ok) throw new Error(`Failed to fetch RCP source: ${res.statusText}`);
@@ -3033,7 +3136,7 @@ function useRcpSources(options = {}) {
3033
3136
  },
3034
3137
  [fetchWithAuth]
3035
3138
  );
3036
- const createRcpSource = (0, import_react13.useCallback)(
3139
+ const createRcpSource = (0, import_react14.useCallback)(
3037
3140
  async (input) => {
3038
3141
  setError(null);
3039
3142
  try {
@@ -3057,7 +3160,7 @@ function useRcpSources(options = {}) {
3057
3160
  },
3058
3161
  [fetchWithAuth]
3059
3162
  );
3060
- const updateRcpSource = (0, import_react13.useCallback)(
3163
+ const updateRcpSource = (0, import_react14.useCallback)(
3061
3164
  async (sourceId, input) => {
3062
3165
  setError(null);
3063
3166
  try {
@@ -3081,7 +3184,7 @@ function useRcpSources(options = {}) {
3081
3184
  },
3082
3185
  [fetchWithAuth]
3083
3186
  );
3084
- const deleteRcpSource = (0, import_react13.useCallback)(
3187
+ const deleteRcpSource = (0, import_react14.useCallback)(
3085
3188
  async (sourceId) => {
3086
3189
  setError(null);
3087
3190
  try {
@@ -3099,7 +3202,7 @@ function useRcpSources(options = {}) {
3099
3202
  },
3100
3203
  [fetchWithAuth]
3101
3204
  );
3102
- const bulkDeleteRcpSources = (0, import_react13.useCallback)(
3205
+ const bulkDeleteRcpSources = (0, import_react14.useCallback)(
3103
3206
  async (ids) => {
3104
3207
  setError(null);
3105
3208
  try {
@@ -3124,7 +3227,7 @@ function useRcpSources(options = {}) {
3124
3227
  },
3125
3228
  [fetchWithAuth]
3126
3229
  );
3127
- const getRcpSourceUsage = (0, import_react13.useCallback)(
3230
+ const getRcpSourceUsage = (0, import_react14.useCallback)(
3128
3231
  async (sourceId) => {
3129
3232
  const res = await fetchWithAuth(`/rcp-sources/${sourceId}/usage`);
3130
3233
  if (!res.ok) throw new Error(`Failed to fetch RCP source usage: ${res.statusText}`);
@@ -3132,7 +3235,7 @@ function useRcpSources(options = {}) {
3132
3235
  },
3133
3236
  [fetchWithAuth]
3134
3237
  );
3135
- const testRcpSourceConnection = (0, import_react13.useCallback)(
3238
+ const testRcpSourceConnection = (0, import_react14.useCallback)(
3136
3239
  async (sourceId) => {
3137
3240
  setError(null);
3138
3241
  try {
@@ -3156,7 +3259,7 @@ function useRcpSources(options = {}) {
3156
3259
  },
3157
3260
  [fetchWithAuth]
3158
3261
  );
3159
- (0, import_react13.useEffect)(() => {
3262
+ (0, import_react14.useEffect)(() => {
3160
3263
  if (autoFetch) void fetchRcpSources();
3161
3264
  }, [autoFetch, fetchRcpSources]);
3162
3265
  return {
@@ -3176,21 +3279,21 @@ function useRcpSources(options = {}) {
3176
3279
  }
3177
3280
 
3178
3281
  // src/hooks/useKnowledgeBases.ts
3179
- var import_react14 = require("react");
3282
+ var import_react15 = require("react");
3180
3283
  function useKnowledgeBases(options = {}) {
3181
3284
  const { autoFetch = true, page, limit, search, scope } = options;
3182
3285
  const { fetchWithAuth } = usePersonaContext();
3183
- const [knowledgeBases, setKnowledgeBases] = (0, import_react14.useState)([]);
3184
- const [pagination, setPagination] = (0, import_react14.useState)({
3286
+ const [knowledgeBases, setKnowledgeBases] = (0, import_react15.useState)([]);
3287
+ const [pagination, setPagination] = (0, import_react15.useState)({
3185
3288
  total: 0,
3186
3289
  page: page ?? 1,
3187
3290
  limit: limit ?? 20,
3188
3291
  pages: 0
3189
3292
  });
3190
- const [isLoading, setIsLoading] = (0, import_react14.useState)(false);
3191
- const [isUploading, setIsUploading] = (0, import_react14.useState)(false);
3192
- const [error, setError] = (0, import_react14.useState)(null);
3193
- const fetchKnowledgeBases = (0, import_react14.useCallback)(async () => {
3293
+ const [isLoading, setIsLoading] = (0, import_react15.useState)(false);
3294
+ const [isUploading, setIsUploading] = (0, import_react15.useState)(false);
3295
+ const [error, setError] = (0, import_react15.useState)(null);
3296
+ const fetchKnowledgeBases = (0, import_react15.useCallback)(async () => {
3194
3297
  setIsLoading(true);
3195
3298
  setError(null);
3196
3299
  try {
@@ -3217,7 +3320,7 @@ function useKnowledgeBases(options = {}) {
3217
3320
  setIsLoading(false);
3218
3321
  }
3219
3322
  }, [fetchWithAuth, page, limit, search, scope]);
3220
- const getKnowledgeBase = (0, import_react14.useCallback)(
3323
+ const getKnowledgeBase = (0, import_react15.useCallback)(
3221
3324
  async (kbId) => {
3222
3325
  const res = await fetchWithAuth(`/knowledge/${kbId}`);
3223
3326
  if (!res.ok) throw new Error(`Failed to fetch knowledge base: ${res.statusText}`);
@@ -3225,7 +3328,7 @@ function useKnowledgeBases(options = {}) {
3225
3328
  },
3226
3329
  [fetchWithAuth]
3227
3330
  );
3228
- const createKnowledgeBase = (0, import_react14.useCallback)(
3331
+ const createKnowledgeBase = (0, import_react15.useCallback)(
3229
3332
  async (input) => {
3230
3333
  setError(null);
3231
3334
  try {
@@ -3249,7 +3352,7 @@ function useKnowledgeBases(options = {}) {
3249
3352
  },
3250
3353
  [fetchWithAuth]
3251
3354
  );
3252
- const updateKnowledgeBase = (0, import_react14.useCallback)(
3355
+ const updateKnowledgeBase = (0, import_react15.useCallback)(
3253
3356
  async (kbId, input) => {
3254
3357
  setError(null);
3255
3358
  try {
@@ -3273,7 +3376,7 @@ function useKnowledgeBases(options = {}) {
3273
3376
  },
3274
3377
  [fetchWithAuth]
3275
3378
  );
3276
- const deleteKnowledgeBase = (0, import_react14.useCallback)(
3379
+ const deleteKnowledgeBase = (0, import_react15.useCallback)(
3277
3380
  async (kbId) => {
3278
3381
  setError(null);
3279
3382
  try {
@@ -3291,7 +3394,7 @@ function useKnowledgeBases(options = {}) {
3291
3394
  },
3292
3395
  [fetchWithAuth]
3293
3396
  );
3294
- const bulkDeleteKnowledgeBases = (0, import_react14.useCallback)(
3397
+ const bulkDeleteKnowledgeBases = (0, import_react15.useCallback)(
3295
3398
  async (ids) => {
3296
3399
  setError(null);
3297
3400
  try {
@@ -3316,7 +3419,7 @@ function useKnowledgeBases(options = {}) {
3316
3419
  },
3317
3420
  [fetchWithAuth]
3318
3421
  );
3319
- const getKnowledgeBaseUsage = (0, import_react14.useCallback)(
3422
+ const getKnowledgeBaseUsage = (0, import_react15.useCallback)(
3320
3423
  async (kbId) => {
3321
3424
  const res = await fetchWithAuth(`/knowledge/${kbId}/usage`);
3322
3425
  if (!res.ok) throw new Error(`Failed to fetch knowledge base usage: ${res.statusText}`);
@@ -3324,7 +3427,7 @@ function useKnowledgeBases(options = {}) {
3324
3427
  },
3325
3428
  [fetchWithAuth]
3326
3429
  );
3327
- const uploadDocuments = (0, import_react14.useCallback)(
3430
+ const uploadDocuments = (0, import_react15.useCallback)(
3328
3431
  async (kbId, files) => {
3329
3432
  setIsUploading(true);
3330
3433
  setError(null);
@@ -3366,7 +3469,7 @@ function useKnowledgeBases(options = {}) {
3366
3469
  },
3367
3470
  [fetchWithAuth]
3368
3471
  );
3369
- const listDocuments = (0, import_react14.useCallback)(
3472
+ const listDocuments = (0, import_react15.useCallback)(
3370
3473
  async (kbId) => {
3371
3474
  const res = await fetchWithAuth(`/knowledge/${kbId}/documents`);
3372
3475
  if (!res.ok) throw new Error(`Failed to list documents: ${res.statusText}`);
@@ -3374,7 +3477,7 @@ function useKnowledgeBases(options = {}) {
3374
3477
  },
3375
3478
  [fetchWithAuth]
3376
3479
  );
3377
- const deleteDocument = (0, import_react14.useCallback)(
3480
+ const deleteDocument = (0, import_react15.useCallback)(
3378
3481
  async (kbId, sourceName) => {
3379
3482
  setError(null);
3380
3483
  try {
@@ -3401,7 +3504,7 @@ function useKnowledgeBases(options = {}) {
3401
3504
  },
3402
3505
  [fetchWithAuth]
3403
3506
  );
3404
- const searchKnowledgeBase = (0, import_react14.useCallback)(
3507
+ const searchKnowledgeBase = (0, import_react15.useCallback)(
3405
3508
  async (kbId, query, opts) => {
3406
3509
  const res = await fetchWithAuth(`/knowledge/${kbId}/search`, {
3407
3510
  method: "POST",
@@ -3416,7 +3519,7 @@ function useKnowledgeBases(options = {}) {
3416
3519
  },
3417
3520
  [fetchWithAuth]
3418
3521
  );
3419
- (0, import_react14.useEffect)(() => {
3522
+ (0, import_react15.useEffect)(() => {
3420
3523
  if (autoFetch) void fetchKnowledgeBases();
3421
3524
  }, [autoFetch, fetchKnowledgeBases]);
3422
3525
  return {
@@ -3440,20 +3543,20 @@ function useKnowledgeBases(options = {}) {
3440
3543
  }
3441
3544
 
3442
3545
  // src/hooks/useMcpAdmin.ts
3443
- var import_react15 = require("react");
3546
+ var import_react16 = require("react");
3444
3547
  function useMcpAdmin(options = {}) {
3445
3548
  const { autoFetch = true, page, limit, search } = options;
3446
3549
  const { fetchWithAuth } = usePersonaContext();
3447
- const [mcps, setMcps] = (0, import_react15.useState)([]);
3448
- const [pagination, setPagination] = (0, import_react15.useState)({
3550
+ const [mcps, setMcps] = (0, import_react16.useState)([]);
3551
+ const [pagination, setPagination] = (0, import_react16.useState)({
3449
3552
  total: 0,
3450
3553
  page: page ?? 1,
3451
3554
  limit: limit ?? 20,
3452
3555
  pages: 0
3453
3556
  });
3454
- const [isLoading, setIsLoading] = (0, import_react15.useState)(false);
3455
- const [error, setError] = (0, import_react15.useState)(null);
3456
- const fetchMcps = (0, import_react15.useCallback)(async () => {
3557
+ const [isLoading, setIsLoading] = (0, import_react16.useState)(false);
3558
+ const [error, setError] = (0, import_react16.useState)(null);
3559
+ const fetchMcps = (0, import_react16.useCallback)(async () => {
3457
3560
  setIsLoading(true);
3458
3561
  setError(null);
3459
3562
  try {
@@ -3479,7 +3582,7 @@ function useMcpAdmin(options = {}) {
3479
3582
  setIsLoading(false);
3480
3583
  }
3481
3584
  }, [fetchWithAuth, page, limit, search]);
3482
- const getMcp = (0, import_react15.useCallback)(
3585
+ const getMcp = (0, import_react16.useCallback)(
3483
3586
  async (mcpId) => {
3484
3587
  const res = await fetchWithAuth(`/mcps/${mcpId}`);
3485
3588
  if (!res.ok) throw new Error(`Failed to fetch MCP: ${res.statusText}`);
@@ -3487,7 +3590,7 @@ function useMcpAdmin(options = {}) {
3487
3590
  },
3488
3591
  [fetchWithAuth]
3489
3592
  );
3490
- const createMcp = (0, import_react15.useCallback)(
3593
+ const createMcp = (0, import_react16.useCallback)(
3491
3594
  async (input) => {
3492
3595
  setError(null);
3493
3596
  try {
@@ -3511,7 +3614,7 @@ function useMcpAdmin(options = {}) {
3511
3614
  },
3512
3615
  [fetchWithAuth]
3513
3616
  );
3514
- const updateMcp = (0, import_react15.useCallback)(
3617
+ const updateMcp = (0, import_react16.useCallback)(
3515
3618
  async (mcpId, input) => {
3516
3619
  setError(null);
3517
3620
  try {
@@ -3535,7 +3638,7 @@ function useMcpAdmin(options = {}) {
3535
3638
  },
3536
3639
  [fetchWithAuth]
3537
3640
  );
3538
- const deleteMcp = (0, import_react15.useCallback)(
3641
+ const deleteMcp = (0, import_react16.useCallback)(
3539
3642
  async (mcpId) => {
3540
3643
  setError(null);
3541
3644
  try {
@@ -3553,7 +3656,7 @@ function useMcpAdmin(options = {}) {
3553
3656
  },
3554
3657
  [fetchWithAuth]
3555
3658
  );
3556
- const bulkDeleteMcps = (0, import_react15.useCallback)(
3659
+ const bulkDeleteMcps = (0, import_react16.useCallback)(
3557
3660
  async (ids) => {
3558
3661
  setError(null);
3559
3662
  try {
@@ -3578,7 +3681,7 @@ function useMcpAdmin(options = {}) {
3578
3681
  },
3579
3682
  [fetchWithAuth]
3580
3683
  );
3581
- const testConnection = (0, import_react15.useCallback)(
3684
+ const testConnection = (0, import_react16.useCallback)(
3582
3685
  async (mcpId) => {
3583
3686
  setError(null);
3584
3687
  try {
@@ -3602,7 +3705,7 @@ function useMcpAdmin(options = {}) {
3602
3705
  },
3603
3706
  [fetchWithAuth]
3604
3707
  );
3605
- (0, import_react15.useEffect)(() => {
3708
+ (0, import_react16.useEffect)(() => {
3606
3709
  if (autoFetch) void fetchMcps();
3607
3710
  }, [autoFetch, fetchMcps]);
3608
3711
  return {
@@ -3621,21 +3724,21 @@ function useMcpAdmin(options = {}) {
3621
3724
  }
3622
3725
 
3623
3726
  // src/hooks/useWorkflows.ts
3624
- var import_react16 = require("react");
3727
+ var import_react17 = require("react");
3625
3728
  function useWorkflows(options) {
3626
3729
  const opts = typeof options === "boolean" ? { autoFetch: options } : options ?? {};
3627
3730
  const { autoFetch = true, search, scope, visibility, isEnabled, page, limit } = opts;
3628
3731
  const { fetchWithAuth } = usePersonaContext();
3629
- const [workflows, setWorkflows] = (0, import_react16.useState)([]);
3630
- const [pagination, setPagination] = (0, import_react16.useState)({
3732
+ const [workflows, setWorkflows] = (0, import_react17.useState)([]);
3733
+ const [pagination, setPagination] = (0, import_react17.useState)({
3631
3734
  page: page ?? 1,
3632
3735
  limit: limit ?? 20,
3633
3736
  total: 0,
3634
3737
  totalPages: 0
3635
3738
  });
3636
- const [isLoading, setIsLoading] = (0, import_react16.useState)(false);
3637
- const [error, setError] = (0, import_react16.useState)(null);
3638
- const fetchWorkflows = (0, import_react16.useCallback)(async () => {
3739
+ const [isLoading, setIsLoading] = (0, import_react17.useState)(false);
3740
+ const [error, setError] = (0, import_react17.useState)(null);
3741
+ const fetchWorkflows = (0, import_react17.useCallback)(async () => {
3639
3742
  setIsLoading(true);
3640
3743
  setError(null);
3641
3744
  try {
@@ -3681,7 +3784,7 @@ function useWorkflows(options) {
3681
3784
  setIsLoading(false);
3682
3785
  }
3683
3786
  }, [fetchWithAuth, search, scope, visibility, isEnabled, page, limit]);
3684
- const createWorkflow = (0, import_react16.useCallback)(
3787
+ const createWorkflow = (0, import_react17.useCallback)(
3685
3788
  async (input) => {
3686
3789
  setError(null);
3687
3790
  try {
@@ -3705,7 +3808,7 @@ function useWorkflows(options) {
3705
3808
  },
3706
3809
  [fetchWithAuth]
3707
3810
  );
3708
- (0, import_react16.useEffect)(() => {
3811
+ (0, import_react17.useEffect)(() => {
3709
3812
  if (autoFetch) {
3710
3813
  void fetchWorkflows();
3711
3814
  }
@@ -3721,17 +3824,17 @@ function useWorkflows(options) {
3721
3824
  }
3722
3825
 
3723
3826
  // src/hooks/useWorkflow.ts
3724
- var import_react17 = require("react");
3827
+ var import_react18 = require("react");
3725
3828
  function useWorkflow(workflowId, options) {
3726
3829
  const opts = typeof options === "boolean" ? { autoFetch: options } : options ?? {};
3727
3830
  const { autoFetch = true } = opts;
3728
3831
  const { fetchWithAuth } = usePersonaContext();
3729
- const [workflow, setWorkflow] = (0, import_react17.useState)(null);
3730
- const [versions, setVersions] = (0, import_react17.useState)([]);
3731
- const [mermaid, setMermaid] = (0, import_react17.useState)(null);
3732
- const [isLoading, setIsLoading] = (0, import_react17.useState)(false);
3733
- const [error, setError] = (0, import_react17.useState)(null);
3734
- const fetchWorkflow = (0, import_react17.useCallback)(async () => {
3832
+ const [workflow, setWorkflow] = (0, import_react18.useState)(null);
3833
+ const [versions, setVersions] = (0, import_react18.useState)([]);
3834
+ const [mermaid, setMermaid] = (0, import_react18.useState)(null);
3835
+ const [isLoading, setIsLoading] = (0, import_react18.useState)(false);
3836
+ const [error, setError] = (0, import_react18.useState)(null);
3837
+ const fetchWorkflow = (0, import_react18.useCallback)(async () => {
3735
3838
  if (!workflowId) return null;
3736
3839
  setIsLoading(true);
3737
3840
  setError(null);
@@ -3751,7 +3854,7 @@ function useWorkflow(workflowId, options) {
3751
3854
  setIsLoading(false);
3752
3855
  }
3753
3856
  }, [fetchWithAuth, workflowId]);
3754
- const fetchVersions = (0, import_react17.useCallback)(async () => {
3857
+ const fetchVersions = (0, import_react18.useCallback)(async () => {
3755
3858
  if (!workflowId) return [];
3756
3859
  try {
3757
3860
  const res = await fetchWithAuth(`/workflows/${workflowId}/versions`);
@@ -3764,7 +3867,7 @@ function useWorkflow(workflowId, options) {
3764
3867
  return [];
3765
3868
  }
3766
3869
  }, [fetchWithAuth, workflowId]);
3767
- const getVersion = (0, import_react17.useCallback)(
3870
+ const getVersion = (0, import_react18.useCallback)(
3768
3871
  async (version) => {
3769
3872
  if (!workflowId) throw new Error("Workflow ID is required");
3770
3873
  const res = await fetchWithAuth(`/workflows/${workflowId}/versions/${version}`);
@@ -3775,7 +3878,7 @@ function useWorkflow(workflowId, options) {
3775
3878
  },
3776
3879
  [fetchWithAuth, workflowId]
3777
3880
  );
3778
- const fetchMermaid = (0, import_react17.useCallback)(async () => {
3881
+ const fetchMermaid = (0, import_react18.useCallback)(async () => {
3779
3882
  if (!workflowId) return "";
3780
3883
  try {
3781
3884
  const res = await fetchWithAuth(`/workflows/${workflowId}/mermaid`);
@@ -3788,7 +3891,7 @@ function useWorkflow(workflowId, options) {
3788
3891
  return "";
3789
3892
  }
3790
3893
  }, [fetchWithAuth, workflowId]);
3791
- const updateWorkflow = (0, import_react17.useCallback)(
3894
+ const updateWorkflow = (0, import_react18.useCallback)(
3792
3895
  async (input) => {
3793
3896
  if (!workflowId) throw new Error("Workflow ID is required");
3794
3897
  setError(null);
@@ -3807,7 +3910,7 @@ function useWorkflow(workflowId, options) {
3807
3910
  },
3808
3911
  [fetchWithAuth, workflowId]
3809
3912
  );
3810
- const saveDraft = (0, import_react17.useCallback)(
3913
+ const saveDraft = (0, import_react18.useCallback)(
3811
3914
  async (draft) => {
3812
3915
  if (!workflowId) throw new Error("Workflow ID is required");
3813
3916
  setError(null);
@@ -3826,7 +3929,7 @@ function useWorkflow(workflowId, options) {
3826
3929
  },
3827
3930
  [fetchWithAuth, workflowId]
3828
3931
  );
3829
- const publish = (0, import_react17.useCallback)(async () => {
3932
+ const publish = (0, import_react18.useCallback)(async () => {
3830
3933
  if (!workflowId) throw new Error("Workflow ID is required");
3831
3934
  setError(null);
3832
3935
  const res = await fetchWithAuth(`/workflows/${workflowId}/publish`, {
@@ -3841,7 +3944,7 @@ function useWorkflow(workflowId, options) {
3841
3944
  void fetchVersions();
3842
3945
  return versionResult;
3843
3946
  }, [fetchWithAuth, workflowId, fetchWorkflow, fetchVersions]);
3844
- const deleteWorkflow = (0, import_react17.useCallback)(async () => {
3947
+ const deleteWorkflow = (0, import_react18.useCallback)(async () => {
3845
3948
  if (!workflowId) throw new Error("Workflow ID is required");
3846
3949
  setError(null);
3847
3950
  const res = await fetchWithAuth(`/workflows/${workflowId}`, {
@@ -3852,7 +3955,7 @@ function useWorkflow(workflowId, options) {
3852
3955
  }
3853
3956
  setWorkflow(null);
3854
3957
  }, [fetchWithAuth, workflowId]);
3855
- (0, import_react17.useEffect)(() => {
3958
+ (0, import_react18.useEffect)(() => {
3856
3959
  if (autoFetch && workflowId) {
3857
3960
  void fetchWorkflow();
3858
3961
  }
@@ -3875,25 +3978,25 @@ function useWorkflow(workflowId, options) {
3875
3978
  }
3876
3979
 
3877
3980
  // src/hooks/useWorkflowStream.ts
3878
- var import_react18 = require("react");
3981
+ var import_react19 = require("react");
3879
3982
  function useWorkflowStream(workflowId, options) {
3880
3983
  const { baseUrl, getAuthToken, fetchWithAuth, logger } = usePersonaContext();
3881
- const [status, setStatus] = (0, import_react18.useState)("idle");
3882
- const [runId, setRunId] = (0, import_react18.useState)(null);
3883
- const [activeNodeId, setActiveNodeId] = (0, import_react18.useState)(null);
3884
- const [nodeRuns, setNodeRuns] = (0, import_react18.useState)(
3984
+ const [status, setStatus] = (0, import_react19.useState)("idle");
3985
+ const [runId, setRunId] = (0, import_react19.useState)(null);
3986
+ const [activeNodeId, setActiveNodeId] = (0, import_react19.useState)(null);
3987
+ const [nodeRuns, setNodeRuns] = (0, import_react19.useState)(
3885
3988
  {}
3886
3989
  );
3887
- const [text, setText] = (0, import_react18.useState)("");
3888
- const [output, setOutput] = (0, import_react18.useState)(null);
3889
- const [error, setError] = (0, import_react18.useState)(null);
3890
- const [events, setEvents] = (0, import_react18.useState)([]);
3891
- const abortControllerRef = (0, import_react18.useRef)(null);
3892
- const currentRunIdRef = (0, import_react18.useRef)(null);
3990
+ const [text, setText] = (0, import_react19.useState)("");
3991
+ const [output, setOutput] = (0, import_react19.useState)(null);
3992
+ const [error, setError] = (0, import_react19.useState)(null);
3993
+ const [events, setEvents] = (0, import_react19.useState)([]);
3994
+ const abortControllerRef = (0, import_react19.useRef)(null);
3995
+ const currentRunIdRef = (0, import_react19.useRef)(null);
3893
3996
  currentRunIdRef.current = runId;
3894
- const optionsRef = (0, import_react18.useRef)(options);
3997
+ const optionsRef = (0, import_react19.useRef)(options);
3895
3998
  optionsRef.current = options;
3896
- const cancel = (0, import_react18.useCallback)(async () => {
3999
+ const cancel = (0, import_react19.useCallback)(async () => {
3897
4000
  if (abortControllerRef.current) {
3898
4001
  abortControllerRef.current.abort();
3899
4002
  abortControllerRef.current = null;
@@ -3914,7 +4017,7 @@ function useWorkflowStream(workflowId, options) {
3914
4017
  setStatus("cancelled");
3915
4018
  setActiveNodeId(null);
3916
4019
  }, [fetchWithAuth, logger]);
3917
- const reset = (0, import_react18.useCallback)(() => {
4020
+ const reset = (0, import_react19.useCallback)(() => {
3918
4021
  if (abortControllerRef.current) {
3919
4022
  abortControllerRef.current.abort();
3920
4023
  abortControllerRef.current = null;
@@ -3928,7 +4031,7 @@ function useWorkflowStream(workflowId, options) {
3928
4031
  setError(null);
3929
4032
  setEvents([]);
3930
4033
  }, []);
3931
- const processStream = (0, import_react18.useCallback)(
4034
+ const processStream = (0, import_react19.useCallback)(
3932
4035
  async (url, method, body, targetRunId) => {
3933
4036
  if (abortControllerRef.current) {
3934
4037
  abortControllerRef.current.abort();
@@ -4093,7 +4196,7 @@ function useWorkflowStream(workflowId, options) {
4093
4196
  },
4094
4197
  [getAuthToken]
4095
4198
  );
4096
- const start = (0, import_react18.useCallback)(
4199
+ const start = (0, import_react19.useCallback)(
4097
4200
  async (input, opts) => {
4098
4201
  const targetWfId = opts?.workflowId || workflowId;
4099
4202
  if (!targetWfId) {
@@ -4114,7 +4217,7 @@ function useWorkflowStream(workflowId, options) {
4114
4217
  },
4115
4218
  [workflowId, baseUrl, processStream]
4116
4219
  );
4117
- const resume = (0, import_react18.useCallback)(
4220
+ const resume = (0, import_react19.useCallback)(
4118
4221
  async (targetRunId, sinceSeq) => {
4119
4222
  if (!targetRunId) {
4120
4223
  throw new Error("Run ID is required to resume stream");
@@ -4127,7 +4230,7 @@ function useWorkflowStream(workflowId, options) {
4127
4230
  },
4128
4231
  [baseUrl, processStream]
4129
4232
  );
4130
- (0, import_react18.useEffect)(() => {
4233
+ (0, import_react19.useEffect)(() => {
4131
4234
  return () => {
4132
4235
  if (abortControllerRef.current) {
4133
4236
  abortControllerRef.current.abort();
@@ -4152,21 +4255,21 @@ function useWorkflowStream(workflowId, options) {
4152
4255
  }
4153
4256
 
4154
4257
  // src/hooks/useWorkflowRuns.ts
4155
- var import_react19 = require("react");
4258
+ var import_react20 = require("react");
4156
4259
  function useWorkflowRuns(workflowId, options) {
4157
4260
  const opts = typeof options === "boolean" ? { autoFetch: options } : options ?? {};
4158
4261
  const { autoFetch = true, page = 1, limit = 20 } = opts;
4159
4262
  const { fetchWithAuth } = usePersonaContext();
4160
- const [runs, setRuns] = (0, import_react19.useState)([]);
4161
- const [pagination, setPagination] = (0, import_react19.useState)({
4263
+ const [runs, setRuns] = (0, import_react20.useState)([]);
4264
+ const [pagination, setPagination] = (0, import_react20.useState)({
4162
4265
  page,
4163
4266
  limit,
4164
4267
  total: 0,
4165
4268
  totalPages: 0
4166
4269
  });
4167
- const [isLoading, setIsLoading] = (0, import_react19.useState)(false);
4168
- const [error, setError] = (0, import_react19.useState)(null);
4169
- const fetchRuns = (0, import_react19.useCallback)(async () => {
4270
+ const [isLoading, setIsLoading] = (0, import_react20.useState)(false);
4271
+ const [error, setError] = (0, import_react20.useState)(null);
4272
+ const fetchRuns = (0, import_react20.useCallback)(async () => {
4170
4273
  if (!workflowId) return [];
4171
4274
  setIsLoading(true);
4172
4275
  setError(null);
@@ -4198,7 +4301,7 @@ function useWorkflowRuns(workflowId, options) {
4198
4301
  setIsLoading(false);
4199
4302
  }
4200
4303
  }, [fetchWithAuth, workflowId, page, limit]);
4201
- const getRun = (0, import_react19.useCallback)(
4304
+ const getRun = (0, import_react20.useCallback)(
4202
4305
  async (runId) => {
4203
4306
  if (!runId) throw new Error("Run ID is required");
4204
4307
  const res = await fetchWithAuth(`/workflows/runs/${runId}`);
@@ -4209,7 +4312,7 @@ function useWorkflowRuns(workflowId, options) {
4209
4312
  },
4210
4313
  [fetchWithAuth]
4211
4314
  );
4212
- const cancelRun = (0, import_react19.useCallback)(
4315
+ const cancelRun = (0, import_react20.useCallback)(
4213
4316
  async (runId) => {
4214
4317
  if (!runId) throw new Error("Run ID is required");
4215
4318
  const res = await fetchWithAuth(`/workflows/runs/${runId}/cancel`, {
@@ -4224,7 +4327,7 @@ function useWorkflowRuns(workflowId, options) {
4224
4327
  },
4225
4328
  [fetchWithAuth]
4226
4329
  );
4227
- (0, import_react19.useEffect)(() => {
4330
+ (0, import_react20.useEffect)(() => {
4228
4331
  if (autoFetch && workflowId) {
4229
4332
  void fetchRuns();
4230
4333
  }
@@ -4273,6 +4376,7 @@ var VERSION = "0.10.0";
4273
4376
  useWorkflow,
4274
4377
  useWorkflowRuns,
4275
4378
  useWorkflowStream,
4276
- useWorkflows
4379
+ useWorkflows,
4380
+ useWorkspaceFiles
4277
4381
  });
4278
4382
  //# sourceMappingURL=index.cjs.map