@personaai/react 0.7.8 → 0.7.9

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.d.cts CHANGED
@@ -33,6 +33,11 @@ interface PersonaToolCall {
33
33
  seq?: number;
34
34
  /** Nested activity timeline — only present on `task` (subagent) tool calls. */
35
35
  subagentActivity?: PersonaSubagentActivityEntry[];
36
+ /** Present when this tool is backed by an interactive MCP Ext App. */
37
+ mcpApp?: {
38
+ resourceUri: string;
39
+ mcpId: string;
40
+ };
36
41
  }
37
42
  interface PersonaMessage {
38
43
  id: string;
@@ -585,6 +590,19 @@ declare function useMcpConnections(options?: UseMcpConnectionsOptions): {
585
590
  refetch: () => Promise<PersonaMcpConnection[]>;
586
591
  };
587
592
 
593
+ interface UseMcpOptions {
594
+ /** Default MCP server ID for resource reads and tool calls */
595
+ mcpId?: string;
596
+ }
597
+ /**
598
+ * Hook for interacting with MCP servers connected via the Persona runtime.
599
+ * Provides helper functions for reading UI/data resources and calling server tools.
600
+ */
601
+ declare function useMcp(options?: UseMcpOptions): {
602
+ readResource: (uri: string, mcpId?: string) => Promise<any>;
603
+ callTool: (name: string, args?: Record<string, unknown>, mcpId?: string) => Promise<any>;
604
+ };
605
+
588
606
  /**
589
607
  * SSE transport for chat streams, with a React Native fallback.
590
608
  *
@@ -641,6 +659,6 @@ declare function supportsStreamingFetch(): boolean;
641
659
  */
642
660
  declare function openSSEStream(opts: OpenSSEOptions): Promise<SSEStream>;
643
661
 
644
- declare const VERSION = "0.7.3";
662
+ declare const VERSION = "0.7.9";
645
663
 
646
- export { type OpenSSEOptions, type PersonaAgentSummary, type PersonaClarificationQuestion, type PersonaFileItem, type PersonaHealthInfo, type PersonaHitlActionRequest, type PersonaInterrupt, type PersonaMcpConnection, type PersonaMemoryAgentGroup, type PersonaMemoryFile, type PersonaMemoryList, type PersonaMessage, type PersonaPresentedFile, PersonaProvider, type PersonaProviderProps, type PersonaResumeValue, type PersonaRole, type PersonaStreamingEvent, type PersonaSubagentActivityEntry, type PersonaThread, type PersonaTodo, type PersonaToolCall, type PersonaVoiceEndReason, type PersonaVoiceState, type PersonaVoiceToolCall, type PersonaVoiceTranscriptLine, type PersonaWorkspaceFile, type SSEReader, type SSEStream, type SendMessageOverride, type UseChatOptions, type UseMcpConnectionsOptions, type UseVoiceOptions, type UseVoiceResult, VERSION, openSSEStream, supportsStreamingFetch, useAgents, useChat, useConnection, useFiles, useMcpConnections, useMemory, usePersonaContext, useThreads, useVoice };
664
+ export { type OpenSSEOptions, type PersonaAgentSummary, type PersonaClarificationQuestion, type PersonaFileItem, type PersonaHealthInfo, type PersonaHitlActionRequest, type PersonaInterrupt, type PersonaMcpConnection, type PersonaMemoryAgentGroup, type PersonaMemoryFile, type PersonaMemoryList, type PersonaMessage, type PersonaPresentedFile, PersonaProvider, type PersonaProviderProps, type PersonaResumeValue, type PersonaRole, type PersonaStreamingEvent, type PersonaSubagentActivityEntry, type PersonaThread, type PersonaTodo, type PersonaToolCall, type PersonaVoiceEndReason, type PersonaVoiceState, type PersonaVoiceToolCall, type PersonaVoiceTranscriptLine, type PersonaWorkspaceFile, type SSEReader, type SSEStream, type SendMessageOverride, type UseChatOptions, type UseMcpConnectionsOptions, type UseMcpOptions, type UseVoiceOptions, type UseVoiceResult, VERSION, openSSEStream, supportsStreamingFetch, useAgents, useChat, useConnection, useFiles, useMcp, useMcpConnections, useMemory, usePersonaContext, useThreads, useVoice };
package/dist/index.d.ts CHANGED
@@ -33,6 +33,11 @@ interface PersonaToolCall {
33
33
  seq?: number;
34
34
  /** Nested activity timeline — only present on `task` (subagent) tool calls. */
35
35
  subagentActivity?: PersonaSubagentActivityEntry[];
36
+ /** Present when this tool is backed by an interactive MCP Ext App. */
37
+ mcpApp?: {
38
+ resourceUri: string;
39
+ mcpId: string;
40
+ };
36
41
  }
37
42
  interface PersonaMessage {
38
43
  id: string;
@@ -585,6 +590,19 @@ declare function useMcpConnections(options?: UseMcpConnectionsOptions): {
585
590
  refetch: () => Promise<PersonaMcpConnection[]>;
586
591
  };
587
592
 
593
+ interface UseMcpOptions {
594
+ /** Default MCP server ID for resource reads and tool calls */
595
+ mcpId?: string;
596
+ }
597
+ /**
598
+ * Hook for interacting with MCP servers connected via the Persona runtime.
599
+ * Provides helper functions for reading UI/data resources and calling server tools.
600
+ */
601
+ declare function useMcp(options?: UseMcpOptions): {
602
+ readResource: (uri: string, mcpId?: string) => Promise<any>;
603
+ callTool: (name: string, args?: Record<string, unknown>, mcpId?: string) => Promise<any>;
604
+ };
605
+
588
606
  /**
589
607
  * SSE transport for chat streams, with a React Native fallback.
590
608
  *
@@ -641,6 +659,6 @@ declare function supportsStreamingFetch(): boolean;
641
659
  */
642
660
  declare function openSSEStream(opts: OpenSSEOptions): Promise<SSEStream>;
643
661
 
644
- declare const VERSION = "0.7.3";
662
+ declare const VERSION = "0.7.9";
645
663
 
646
- export { type OpenSSEOptions, type PersonaAgentSummary, type PersonaClarificationQuestion, type PersonaFileItem, type PersonaHealthInfo, type PersonaHitlActionRequest, type PersonaInterrupt, type PersonaMcpConnection, type PersonaMemoryAgentGroup, type PersonaMemoryFile, type PersonaMemoryList, type PersonaMessage, type PersonaPresentedFile, PersonaProvider, type PersonaProviderProps, type PersonaResumeValue, type PersonaRole, type PersonaStreamingEvent, type PersonaSubagentActivityEntry, type PersonaThread, type PersonaTodo, type PersonaToolCall, type PersonaVoiceEndReason, type PersonaVoiceState, type PersonaVoiceToolCall, type PersonaVoiceTranscriptLine, type PersonaWorkspaceFile, type SSEReader, type SSEStream, type SendMessageOverride, type UseChatOptions, type UseMcpConnectionsOptions, type UseVoiceOptions, type UseVoiceResult, VERSION, openSSEStream, supportsStreamingFetch, useAgents, useChat, useConnection, useFiles, useMcpConnections, useMemory, usePersonaContext, useThreads, useVoice };
664
+ export { type OpenSSEOptions, type PersonaAgentSummary, type PersonaClarificationQuestion, type PersonaFileItem, type PersonaHealthInfo, type PersonaHitlActionRequest, type PersonaInterrupt, type PersonaMcpConnection, type PersonaMemoryAgentGroup, type PersonaMemoryFile, type PersonaMemoryList, type PersonaMessage, type PersonaPresentedFile, PersonaProvider, type PersonaProviderProps, type PersonaResumeValue, type PersonaRole, type PersonaStreamingEvent, type PersonaSubagentActivityEntry, type PersonaThread, type PersonaTodo, type PersonaToolCall, type PersonaVoiceEndReason, type PersonaVoiceState, type PersonaVoiceToolCall, type PersonaVoiceTranscriptLine, type PersonaWorkspaceFile, type SSEReader, type SSEStream, type SendMessageOverride, type UseChatOptions, type UseMcpConnectionsOptions, type UseMcpOptions, type UseVoiceOptions, type UseVoiceResult, VERSION, openSSEStream, supportsStreamingFetch, useAgents, useChat, useConnection, useFiles, useMcp, useMcpConnections, useMemory, usePersonaContext, useThreads, useVoice };
package/dist/index.js CHANGED
@@ -865,6 +865,18 @@ function useChat(options = {}) {
865
865
  ];
866
866
  patchAssistant({});
867
867
  }
868
+ } else if (event.name === "mcp_app") {
869
+ const val = event.value;
870
+ if (val?.toolCallId && val?.resourceUri && val?.mcpId) {
871
+ const existing = toolCallsMap.get(val.toolCallId);
872
+ if (existing) {
873
+ existing.mcpApp = {
874
+ resourceUri: val.resourceUri,
875
+ mcpId: val.mcpId
876
+ };
877
+ patchAssistant({});
878
+ }
879
+ }
868
880
  }
869
881
  } else if (event.type === "RUN_ERROR") {
870
882
  chatLogger.warn("run error", {
@@ -1975,6 +1987,47 @@ function useMcpConnections(options = {}) {
1975
1987
  };
1976
1988
  }
1977
1989
 
1990
+ // src/hooks/useMcp.ts
1991
+ import { useCallback as useCallback9 } from "react";
1992
+ function useMcp(options = {}) {
1993
+ const { fetchWithAuth } = usePersonaContext();
1994
+ const defaultMcpId = options.mcpId;
1995
+ const readResource = useCallback9(
1996
+ async (uri, mcpId) => {
1997
+ const id = mcpId ?? defaultMcpId;
1998
+ if (!id) throw new Error("MCP server ID is required to read resource");
1999
+ const res = await fetchWithAuth(
2000
+ `/mcps/${id}/resource?uri=${encodeURIComponent(uri)}`
2001
+ );
2002
+ if (!res.ok) {
2003
+ throw new Error(`Failed to read MCP resource: ${res.statusText}`);
2004
+ }
2005
+ return await res.json();
2006
+ },
2007
+ [fetchWithAuth, defaultMcpId]
2008
+ );
2009
+ const callTool = useCallback9(
2010
+ async (name, args, mcpId) => {
2011
+ const id = mcpId ?? defaultMcpId;
2012
+ if (!id) throw new Error("MCP server ID is required to call tool");
2013
+ const res = await fetchWithAuth(`/mcps/${id}/call-tool`, {
2014
+ method: "POST",
2015
+ headers: { "Content-Type": "application/json" },
2016
+ body: JSON.stringify({ name, arguments: args })
2017
+ });
2018
+ if (!res.ok) {
2019
+ throw new Error(`Failed to call MCP tool: ${res.statusText}`);
2020
+ }
2021
+ return await res.json();
2022
+ },
2023
+ [fetchWithAuth, defaultMcpId]
2024
+ );
2025
+ return {
2026
+ readResource,
2027
+ callTool
2028
+ };
2029
+ }
2030
+
1978
2031
  // src/index.ts
1979
2032
  import {
1980
2033
  createLogger as createLogger2,
@@ -1983,7 +2036,7 @@ import {
1983
2036
  getLogLevel,
1984
2037
  isLevelEnabled
1985
2038
  } from "@personaai/logger";
1986
- var VERSION = "0.7.3";
2039
+ var VERSION = "0.7.9";
1987
2040
  export {
1988
2041
  PersonaProvider,
1989
2042
  VERSION,
@@ -1998,6 +2051,7 @@ export {
1998
2051
  useChat,
1999
2052
  useConnection,
2000
2053
  useFiles,
2054
+ useMcp,
2001
2055
  useMcpConnections,
2002
2056
  useMemory,
2003
2057
  usePersonaContext,