@personaai/react 0.18.0 → 0.19.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.d.cts CHANGED
@@ -292,6 +292,12 @@ type PersonaStreamingEvent = {
292
292
  resourceUri: string;
293
293
  mcpId: string;
294
294
  };
295
+ } | {
296
+ type: "CUSTOM";
297
+ name: "mcp_auth_required";
298
+ value: {
299
+ servers: PersonaMcpAuthRequiredServer[];
300
+ };
295
301
  } | {
296
302
  type: "CUSTOM";
297
303
  name: "workflow_node_started";
@@ -332,6 +338,15 @@ interface UseChatOptions {
332
338
  onThreadCreated?: (threadId: string) => void;
333
339
  /** Called when the backend auto-generates a thread title (3-4 word LLM summary of first user message). */
334
340
  onTitle?: (title: string) => void;
341
+ /**
342
+ * Called at the start of a run when the Agent has `authMode: 'user'` MCP
343
+ * connectors this end user hasn't connected — their tools are dropped from
344
+ * the toolset server-side, so the model simply can't use them. Use this to
345
+ * show a "Connect your account" affordance; `useMcpConnections` returns
346
+ * each server's `authorizeUrl` for the actual consent redirect. Not called
347
+ * when every user-mode connector is connected.
348
+ */
349
+ onMcpAuthRequired?: (servers: PersonaMcpAuthRequiredServer[]) => void;
335
350
  /**
336
351
  * Pass the object returned by `useVoice()` (sharing the same `threadId`) to have `useChat`
337
352
  * merge live voice turns into `messages` automatically — one bubble per utterance, deduped
@@ -1163,6 +1178,17 @@ interface PersonaMcpOAuthInput {
1163
1178
  clientSecret: string;
1164
1179
  scopes?: string[];
1165
1180
  }
1181
+ /**
1182
+ * One `authType: 'oauth', authMode: 'user'` MCP an Agent has attached whose
1183
+ * tools were dropped for this end user because they haven't connected (or
1184
+ * their grant was revoked/expired). Emitted as the `mcp_auth_required`
1185
+ * CUSTOM stream event at the start of every run; see `onMcpAuthRequired`.
1186
+ */
1187
+ interface PersonaMcpAuthRequiredServer {
1188
+ mcpId: string;
1189
+ name: string;
1190
+ description?: string;
1191
+ }
1166
1192
  interface CreatePersonaMcpInput {
1167
1193
  name: string;
1168
1194
  transport: PersonaMcpTransport;
@@ -1261,6 +1287,16 @@ interface PersonaContextValue {
1261
1287
  fetchWithAuth: (path: string, init?: RequestInit) => Promise<Response>;
1262
1288
  logger: Logger;
1263
1289
  }
1290
+ /** Structured, trackable details of a non-ok API response. */
1291
+ interface PersonaHttpFailureInfo {
1292
+ status: number;
1293
+ code?: string;
1294
+ message?: string;
1295
+ }
1296
+ /** A Response whose error body has been parsed and attached by fetchWithAuth. */
1297
+ interface PersonaFailureResponse extends Response {
1298
+ personaError?: PersonaHttpFailureInfo;
1299
+ }
1264
1300
  declare function PersonaProvider({ baseUrl, getAuthToken, defaultAgentId, logLevel, logger: loggerProp, children, }: PersonaProviderProps): react__default.JSX.Element;
1265
1301
  declare function usePersonaContext(): PersonaContextValue;
1266
1302
 
@@ -1522,6 +1558,17 @@ declare function useConnection(autoCheck?: boolean): {
1522
1558
  checkHealth: () => Promise<PersonaHealthInfo | null>;
1523
1559
  };
1524
1560
 
1561
+ /**
1562
+ * Why a user-mode MCP isn't usable, in increasing specificity over the bare
1563
+ * `connected` boolean:
1564
+ * - `connected` — a usable token row exists (may still be refreshed soon).
1565
+ * - `expired` — a row exists but its access token is dead and there's no
1566
+ * refresh token to renew it; `authorizeUrl` is populated.
1567
+ * - `needs_auth` — the provider rejected the stored grant (revoked or
1568
+ * expired refresh token); reconnecting is the only fix.
1569
+ * - `not_connected` — this end user has never connected.
1570
+ */
1571
+ type PersonaMcpConnectionStatus = "connected" | "expired" | "needs_auth" | "not_connected";
1525
1572
  /**
1526
1573
  * One `authType: 'oauth', authMode: 'user'` MCP an Agent has attached, and
1527
1574
  * whether the current end user has connected it yet. `authorizeUrl` is only
@@ -1534,6 +1581,17 @@ interface PersonaMcpConnection {
1534
1581
  name: string;
1535
1582
  description: string;
1536
1583
  connected: boolean;
1584
+ /**
1585
+ * Finer-grained than `connected` — tells "never connected" apart from
1586
+ * "token expired" and "grant revoked", so the UI can say "Connect" vs.
1587
+ * "Reconnect". Absent against backends predating this field; treat
1588
+ * `undefined` as `connected ? "connected" : "not_connected"`.
1589
+ */
1590
+ status?: PersonaMcpConnectionStatus;
1591
+ /** When the stored access token expires (ISO string), if the provider returned one. */
1592
+ expiresAt?: string | null;
1593
+ /** The provider's rejection reason when `status` is `needs_auth` (never contains tokens). */
1594
+ lastError?: string | null;
1537
1595
  authorizeUrl: string | null;
1538
1596
  }
1539
1597
  interface UseMcpConnectionsOptions {
@@ -1835,6 +1893,6 @@ declare function supportsStreamingFetch(): boolean;
1835
1893
  */
1836
1894
  declare function openSSEStream(opts: OpenSSEOptions): Promise<SSEStream>;
1837
1895
 
1838
- declare const VERSION = "0.18.0";
1896
+ declare const VERSION = "0.19.0";
1839
1897
 
1840
- export { ARCHITECT_AGENT_ID, type CreatePersonaAgentInput, type CreatePersonaKnowledgeBaseInput, type CreatePersonaMcpInput, type CreatePersonaRcpSourceInput, type CreatePersonaSkillInput, type CreatePersonaWorkflowInput, type OpenSSEOptions, type PersonaAgent, type PersonaAgentCategory, type PersonaAgentMessageDelivery, type PersonaAgentSnapshot, type PersonaAgentSocialLinks, type PersonaAgentVisibility, type PersonaBulkDeleteResult, type PersonaClarificationQuestion, type PersonaDeleteDocumentResult, type PersonaFileItem, type PersonaHealthInfo, type PersonaHitlActionRequest, type PersonaInterrupt, type PersonaKnowledgeBase, type PersonaKnowledgeBaseUsage, type PersonaKnowledgeDocument, type PersonaKnowledgeSearchResult, type PersonaMcp, type PersonaMcpAuthMode, type PersonaMcpAuthType, type PersonaMcpConnection, type PersonaMcpOAuthConfig, type PersonaMcpOAuthInput, type PersonaMcpResourceSummary, type PersonaMcpResourceTemplate, type PersonaMcpTestConnectionResult, type PersonaMcpTool, type PersonaMcpTransport, type PersonaMemoryAgentGroup, type PersonaMemoryFile, type PersonaMemoryList, type PersonaMessage, type PersonaMessageChannel, type PersonaMessageDelivery, type PersonaNodeOnErrorAction, type PersonaNodeRetryPolicy, type PersonaNodeRun, type PersonaNodeRunState, type PersonaNodeRunStatus, type PersonaPagination, type PersonaPresentedFile, PersonaProvider, type PersonaProviderProps, type PersonaRcpParamContextMapEntry, type PersonaRcpSource, type PersonaRcpSourceTestResult, type PersonaRcpSourceToolParamSummary, type PersonaRcpSourceToolSummary, type PersonaResourceUsage, type PersonaResumeValue, type PersonaRole, type PersonaSandboxCommand, type PersonaSkill, type PersonaSkillFile, type PersonaSkillUsage, type PersonaStreamingEvent, type PersonaSubagentActivityEntry, type PersonaThread, type PersonaTodo, type PersonaToolCall, type PersonaUploadDocumentsResult, type PersonaVoiceEndReason, type PersonaVoiceState, type PersonaVoiceToolCall, type PersonaVoiceTranscriptLine, type PersonaWorkflow, type PersonaWorkflowDraft, type PersonaWorkflowEdge, type PersonaWorkflowNode, type PersonaWorkflowNodeData, type PersonaWorkflowNodeType, type PersonaWorkflowOwnerType, type PersonaWorkflowRun, type PersonaWorkflowRunStatus, type PersonaWorkflowTrigger, type PersonaWorkflowTriggerType, type PersonaWorkflowUsage, type PersonaWorkflowVersion, type PersonaWorkflowVisibility, type PersonaWorkspaceFile, type SSEReader, type SSEStream, type SendArchitectMessageOverride, type SendMessageOverride, type SendPersonaAgentMessageInput, type SendPersonaMessageInput, type UpdatePersonaAgentInput, type UpdatePersonaKnowledgeBaseInput, type UpdatePersonaMcpInput, type UpdatePersonaRcpSourceInput, type UpdatePersonaSkillInput, type UpdatePersonaWorkflowInput, type UploadKnowledgeDocumentInput, type UseAgentsOptions, type UseArchitectChatOptions, type UseChatOptions, type UseKnowledgeBasesOptions, type UseMcpAdminOptions, type UseMcpConnectionsOptions, type UseMcpOptions, type UseMessagesResult, type UseRcpSourcesOptions, type UseSkillsOptions, type UseVoiceOptions, type UseVoiceResult, type UseWorkflowOptions, type UseWorkflowRunsOptions, type UseWorkflowStreamOptions, type UseWorkflowStreamResult, type UseWorkflowsOptions, VERSION, type WorkflowsPagination, openSSEStream, supportsStreamingFetch, useAgents, useArchitectChat, useChat, useConnection, useFiles, useKnowledgeBases, useMcp, useMcpAdmin, useMcpConnections, useMemory, useMessages, usePersonaContext, useRcpSources, useSkills, useThreads, useVoice, useWorkflow, useWorkflowRuns, useWorkflowStream, useWorkflows, useWorkspaceFiles };
1898
+ export { ARCHITECT_AGENT_ID, type CreatePersonaAgentInput, type CreatePersonaKnowledgeBaseInput, type CreatePersonaMcpInput, type CreatePersonaRcpSourceInput, type CreatePersonaSkillInput, type CreatePersonaWorkflowInput, type OpenSSEOptions, type PersonaAgent, type PersonaAgentCategory, type PersonaAgentMessageDelivery, type PersonaAgentSnapshot, type PersonaAgentSocialLinks, type PersonaAgentVisibility, type PersonaBulkDeleteResult, type PersonaClarificationQuestion, type PersonaDeleteDocumentResult, type PersonaFailureResponse, type PersonaFileItem, type PersonaHealthInfo, type PersonaHitlActionRequest, type PersonaHttpFailureInfo, type PersonaInterrupt, type PersonaKnowledgeBase, type PersonaKnowledgeBaseUsage, type PersonaKnowledgeDocument, type PersonaKnowledgeSearchResult, type PersonaMcp, type PersonaMcpAuthMode, type PersonaMcpAuthRequiredServer, type PersonaMcpAuthType, type PersonaMcpConnection, type PersonaMcpConnectionStatus, type PersonaMcpOAuthConfig, type PersonaMcpOAuthInput, type PersonaMcpResourceSummary, type PersonaMcpResourceTemplate, type PersonaMcpTestConnectionResult, type PersonaMcpTool, type PersonaMcpTransport, type PersonaMemoryAgentGroup, type PersonaMemoryFile, type PersonaMemoryList, type PersonaMessage, type PersonaMessageChannel, type PersonaMessageDelivery, type PersonaNodeOnErrorAction, type PersonaNodeRetryPolicy, type PersonaNodeRun, type PersonaNodeRunState, type PersonaNodeRunStatus, type PersonaPagination, type PersonaPresentedFile, PersonaProvider, type PersonaProviderProps, type PersonaRcpParamContextMapEntry, type PersonaRcpSource, type PersonaRcpSourceTestResult, type PersonaRcpSourceToolParamSummary, type PersonaRcpSourceToolSummary, type PersonaResourceUsage, type PersonaResumeValue, type PersonaRole, type PersonaSandboxCommand, type PersonaSkill, type PersonaSkillFile, type PersonaSkillUsage, type PersonaStreamingEvent, type PersonaSubagentActivityEntry, type PersonaThread, type PersonaTodo, type PersonaToolCall, type PersonaUploadDocumentsResult, type PersonaVoiceEndReason, type PersonaVoiceState, type PersonaVoiceToolCall, type PersonaVoiceTranscriptLine, type PersonaWorkflow, type PersonaWorkflowDraft, type PersonaWorkflowEdge, type PersonaWorkflowNode, type PersonaWorkflowNodeData, type PersonaWorkflowNodeType, type PersonaWorkflowOwnerType, type PersonaWorkflowRun, type PersonaWorkflowRunStatus, type PersonaWorkflowTrigger, type PersonaWorkflowTriggerType, type PersonaWorkflowUsage, type PersonaWorkflowVersion, type PersonaWorkflowVisibility, type PersonaWorkspaceFile, type SSEReader, type SSEStream, type SendArchitectMessageOverride, type SendMessageOverride, type SendPersonaAgentMessageInput, type SendPersonaMessageInput, type UpdatePersonaAgentInput, type UpdatePersonaKnowledgeBaseInput, type UpdatePersonaMcpInput, type UpdatePersonaRcpSourceInput, type UpdatePersonaSkillInput, type UpdatePersonaWorkflowInput, type UploadKnowledgeDocumentInput, type UseAgentsOptions, type UseArchitectChatOptions, type UseChatOptions, type UseKnowledgeBasesOptions, type UseMcpAdminOptions, type UseMcpConnectionsOptions, type UseMcpOptions, type UseMessagesResult, type UseRcpSourcesOptions, type UseSkillsOptions, type UseVoiceOptions, type UseVoiceResult, type UseWorkflowOptions, type UseWorkflowRunsOptions, type UseWorkflowStreamOptions, type UseWorkflowStreamResult, type UseWorkflowsOptions, VERSION, type WorkflowsPagination, openSSEStream, supportsStreamingFetch, useAgents, useArchitectChat, useChat, useConnection, useFiles, useKnowledgeBases, useMcp, useMcpAdmin, useMcpConnections, useMemory, useMessages, usePersonaContext, useRcpSources, useSkills, useThreads, useVoice, useWorkflow, useWorkflowRuns, useWorkflowStream, useWorkflows, useWorkspaceFiles };
package/dist/index.d.ts CHANGED
@@ -292,6 +292,12 @@ type PersonaStreamingEvent = {
292
292
  resourceUri: string;
293
293
  mcpId: string;
294
294
  };
295
+ } | {
296
+ type: "CUSTOM";
297
+ name: "mcp_auth_required";
298
+ value: {
299
+ servers: PersonaMcpAuthRequiredServer[];
300
+ };
295
301
  } | {
296
302
  type: "CUSTOM";
297
303
  name: "workflow_node_started";
@@ -332,6 +338,15 @@ interface UseChatOptions {
332
338
  onThreadCreated?: (threadId: string) => void;
333
339
  /** Called when the backend auto-generates a thread title (3-4 word LLM summary of first user message). */
334
340
  onTitle?: (title: string) => void;
341
+ /**
342
+ * Called at the start of a run when the Agent has `authMode: 'user'` MCP
343
+ * connectors this end user hasn't connected — their tools are dropped from
344
+ * the toolset server-side, so the model simply can't use them. Use this to
345
+ * show a "Connect your account" affordance; `useMcpConnections` returns
346
+ * each server's `authorizeUrl` for the actual consent redirect. Not called
347
+ * when every user-mode connector is connected.
348
+ */
349
+ onMcpAuthRequired?: (servers: PersonaMcpAuthRequiredServer[]) => void;
335
350
  /**
336
351
  * Pass the object returned by `useVoice()` (sharing the same `threadId`) to have `useChat`
337
352
  * merge live voice turns into `messages` automatically — one bubble per utterance, deduped
@@ -1163,6 +1178,17 @@ interface PersonaMcpOAuthInput {
1163
1178
  clientSecret: string;
1164
1179
  scopes?: string[];
1165
1180
  }
1181
+ /**
1182
+ * One `authType: 'oauth', authMode: 'user'` MCP an Agent has attached whose
1183
+ * tools were dropped for this end user because they haven't connected (or
1184
+ * their grant was revoked/expired). Emitted as the `mcp_auth_required`
1185
+ * CUSTOM stream event at the start of every run; see `onMcpAuthRequired`.
1186
+ */
1187
+ interface PersonaMcpAuthRequiredServer {
1188
+ mcpId: string;
1189
+ name: string;
1190
+ description?: string;
1191
+ }
1166
1192
  interface CreatePersonaMcpInput {
1167
1193
  name: string;
1168
1194
  transport: PersonaMcpTransport;
@@ -1261,6 +1287,16 @@ interface PersonaContextValue {
1261
1287
  fetchWithAuth: (path: string, init?: RequestInit) => Promise<Response>;
1262
1288
  logger: Logger;
1263
1289
  }
1290
+ /** Structured, trackable details of a non-ok API response. */
1291
+ interface PersonaHttpFailureInfo {
1292
+ status: number;
1293
+ code?: string;
1294
+ message?: string;
1295
+ }
1296
+ /** A Response whose error body has been parsed and attached by fetchWithAuth. */
1297
+ interface PersonaFailureResponse extends Response {
1298
+ personaError?: PersonaHttpFailureInfo;
1299
+ }
1264
1300
  declare function PersonaProvider({ baseUrl, getAuthToken, defaultAgentId, logLevel, logger: loggerProp, children, }: PersonaProviderProps): react__default.JSX.Element;
1265
1301
  declare function usePersonaContext(): PersonaContextValue;
1266
1302
 
@@ -1522,6 +1558,17 @@ declare function useConnection(autoCheck?: boolean): {
1522
1558
  checkHealth: () => Promise<PersonaHealthInfo | null>;
1523
1559
  };
1524
1560
 
1561
+ /**
1562
+ * Why a user-mode MCP isn't usable, in increasing specificity over the bare
1563
+ * `connected` boolean:
1564
+ * - `connected` — a usable token row exists (may still be refreshed soon).
1565
+ * - `expired` — a row exists but its access token is dead and there's no
1566
+ * refresh token to renew it; `authorizeUrl` is populated.
1567
+ * - `needs_auth` — the provider rejected the stored grant (revoked or
1568
+ * expired refresh token); reconnecting is the only fix.
1569
+ * - `not_connected` — this end user has never connected.
1570
+ */
1571
+ type PersonaMcpConnectionStatus = "connected" | "expired" | "needs_auth" | "not_connected";
1525
1572
  /**
1526
1573
  * One `authType: 'oauth', authMode: 'user'` MCP an Agent has attached, and
1527
1574
  * whether the current end user has connected it yet. `authorizeUrl` is only
@@ -1534,6 +1581,17 @@ interface PersonaMcpConnection {
1534
1581
  name: string;
1535
1582
  description: string;
1536
1583
  connected: boolean;
1584
+ /**
1585
+ * Finer-grained than `connected` — tells "never connected" apart from
1586
+ * "token expired" and "grant revoked", so the UI can say "Connect" vs.
1587
+ * "Reconnect". Absent against backends predating this field; treat
1588
+ * `undefined` as `connected ? "connected" : "not_connected"`.
1589
+ */
1590
+ status?: PersonaMcpConnectionStatus;
1591
+ /** When the stored access token expires (ISO string), if the provider returned one. */
1592
+ expiresAt?: string | null;
1593
+ /** The provider's rejection reason when `status` is `needs_auth` (never contains tokens). */
1594
+ lastError?: string | null;
1537
1595
  authorizeUrl: string | null;
1538
1596
  }
1539
1597
  interface UseMcpConnectionsOptions {
@@ -1835,6 +1893,6 @@ declare function supportsStreamingFetch(): boolean;
1835
1893
  */
1836
1894
  declare function openSSEStream(opts: OpenSSEOptions): Promise<SSEStream>;
1837
1895
 
1838
- declare const VERSION = "0.18.0";
1896
+ declare const VERSION = "0.19.0";
1839
1897
 
1840
- export { ARCHITECT_AGENT_ID, type CreatePersonaAgentInput, type CreatePersonaKnowledgeBaseInput, type CreatePersonaMcpInput, type CreatePersonaRcpSourceInput, type CreatePersonaSkillInput, type CreatePersonaWorkflowInput, type OpenSSEOptions, type PersonaAgent, type PersonaAgentCategory, type PersonaAgentMessageDelivery, type PersonaAgentSnapshot, type PersonaAgentSocialLinks, type PersonaAgentVisibility, type PersonaBulkDeleteResult, type PersonaClarificationQuestion, type PersonaDeleteDocumentResult, type PersonaFileItem, type PersonaHealthInfo, type PersonaHitlActionRequest, type PersonaInterrupt, type PersonaKnowledgeBase, type PersonaKnowledgeBaseUsage, type PersonaKnowledgeDocument, type PersonaKnowledgeSearchResult, type PersonaMcp, type PersonaMcpAuthMode, type PersonaMcpAuthType, type PersonaMcpConnection, type PersonaMcpOAuthConfig, type PersonaMcpOAuthInput, type PersonaMcpResourceSummary, type PersonaMcpResourceTemplate, type PersonaMcpTestConnectionResult, type PersonaMcpTool, type PersonaMcpTransport, type PersonaMemoryAgentGroup, type PersonaMemoryFile, type PersonaMemoryList, type PersonaMessage, type PersonaMessageChannel, type PersonaMessageDelivery, type PersonaNodeOnErrorAction, type PersonaNodeRetryPolicy, type PersonaNodeRun, type PersonaNodeRunState, type PersonaNodeRunStatus, type PersonaPagination, type PersonaPresentedFile, PersonaProvider, type PersonaProviderProps, type PersonaRcpParamContextMapEntry, type PersonaRcpSource, type PersonaRcpSourceTestResult, type PersonaRcpSourceToolParamSummary, type PersonaRcpSourceToolSummary, type PersonaResourceUsage, type PersonaResumeValue, type PersonaRole, type PersonaSandboxCommand, type PersonaSkill, type PersonaSkillFile, type PersonaSkillUsage, type PersonaStreamingEvent, type PersonaSubagentActivityEntry, type PersonaThread, type PersonaTodo, type PersonaToolCall, type PersonaUploadDocumentsResult, type PersonaVoiceEndReason, type PersonaVoiceState, type PersonaVoiceToolCall, type PersonaVoiceTranscriptLine, type PersonaWorkflow, type PersonaWorkflowDraft, type PersonaWorkflowEdge, type PersonaWorkflowNode, type PersonaWorkflowNodeData, type PersonaWorkflowNodeType, type PersonaWorkflowOwnerType, type PersonaWorkflowRun, type PersonaWorkflowRunStatus, type PersonaWorkflowTrigger, type PersonaWorkflowTriggerType, type PersonaWorkflowUsage, type PersonaWorkflowVersion, type PersonaWorkflowVisibility, type PersonaWorkspaceFile, type SSEReader, type SSEStream, type SendArchitectMessageOverride, type SendMessageOverride, type SendPersonaAgentMessageInput, type SendPersonaMessageInput, type UpdatePersonaAgentInput, type UpdatePersonaKnowledgeBaseInput, type UpdatePersonaMcpInput, type UpdatePersonaRcpSourceInput, type UpdatePersonaSkillInput, type UpdatePersonaWorkflowInput, type UploadKnowledgeDocumentInput, type UseAgentsOptions, type UseArchitectChatOptions, type UseChatOptions, type UseKnowledgeBasesOptions, type UseMcpAdminOptions, type UseMcpConnectionsOptions, type UseMcpOptions, type UseMessagesResult, type UseRcpSourcesOptions, type UseSkillsOptions, type UseVoiceOptions, type UseVoiceResult, type UseWorkflowOptions, type UseWorkflowRunsOptions, type UseWorkflowStreamOptions, type UseWorkflowStreamResult, type UseWorkflowsOptions, VERSION, type WorkflowsPagination, openSSEStream, supportsStreamingFetch, useAgents, useArchitectChat, useChat, useConnection, useFiles, useKnowledgeBases, useMcp, useMcpAdmin, useMcpConnections, useMemory, useMessages, usePersonaContext, useRcpSources, useSkills, useThreads, useVoice, useWorkflow, useWorkflowRuns, useWorkflowStream, useWorkflows, useWorkspaceFiles };
1898
+ export { ARCHITECT_AGENT_ID, type CreatePersonaAgentInput, type CreatePersonaKnowledgeBaseInput, type CreatePersonaMcpInput, type CreatePersonaRcpSourceInput, type CreatePersonaSkillInput, type CreatePersonaWorkflowInput, type OpenSSEOptions, type PersonaAgent, type PersonaAgentCategory, type PersonaAgentMessageDelivery, type PersonaAgentSnapshot, type PersonaAgentSocialLinks, type PersonaAgentVisibility, type PersonaBulkDeleteResult, type PersonaClarificationQuestion, type PersonaDeleteDocumentResult, type PersonaFailureResponse, type PersonaFileItem, type PersonaHealthInfo, type PersonaHitlActionRequest, type PersonaHttpFailureInfo, type PersonaInterrupt, type PersonaKnowledgeBase, type PersonaKnowledgeBaseUsage, type PersonaKnowledgeDocument, type PersonaKnowledgeSearchResult, type PersonaMcp, type PersonaMcpAuthMode, type PersonaMcpAuthRequiredServer, type PersonaMcpAuthType, type PersonaMcpConnection, type PersonaMcpConnectionStatus, type PersonaMcpOAuthConfig, type PersonaMcpOAuthInput, type PersonaMcpResourceSummary, type PersonaMcpResourceTemplate, type PersonaMcpTestConnectionResult, type PersonaMcpTool, type PersonaMcpTransport, type PersonaMemoryAgentGroup, type PersonaMemoryFile, type PersonaMemoryList, type PersonaMessage, type PersonaMessageChannel, type PersonaMessageDelivery, type PersonaNodeOnErrorAction, type PersonaNodeRetryPolicy, type PersonaNodeRun, type PersonaNodeRunState, type PersonaNodeRunStatus, type PersonaPagination, type PersonaPresentedFile, PersonaProvider, type PersonaProviderProps, type PersonaRcpParamContextMapEntry, type PersonaRcpSource, type PersonaRcpSourceTestResult, type PersonaRcpSourceToolParamSummary, type PersonaRcpSourceToolSummary, type PersonaResourceUsage, type PersonaResumeValue, type PersonaRole, type PersonaSandboxCommand, type PersonaSkill, type PersonaSkillFile, type PersonaSkillUsage, type PersonaStreamingEvent, type PersonaSubagentActivityEntry, type PersonaThread, type PersonaTodo, type PersonaToolCall, type PersonaUploadDocumentsResult, type PersonaVoiceEndReason, type PersonaVoiceState, type PersonaVoiceToolCall, type PersonaVoiceTranscriptLine, type PersonaWorkflow, type PersonaWorkflowDraft, type PersonaWorkflowEdge, type PersonaWorkflowNode, type PersonaWorkflowNodeData, type PersonaWorkflowNodeType, type PersonaWorkflowOwnerType, type PersonaWorkflowRun, type PersonaWorkflowRunStatus, type PersonaWorkflowTrigger, type PersonaWorkflowTriggerType, type PersonaWorkflowUsage, type PersonaWorkflowVersion, type PersonaWorkflowVisibility, type PersonaWorkspaceFile, type SSEReader, type SSEStream, type SendArchitectMessageOverride, type SendMessageOverride, type SendPersonaAgentMessageInput, type SendPersonaMessageInput, type UpdatePersonaAgentInput, type UpdatePersonaKnowledgeBaseInput, type UpdatePersonaMcpInput, type UpdatePersonaRcpSourceInput, type UpdatePersonaSkillInput, type UpdatePersonaWorkflowInput, type UploadKnowledgeDocumentInput, type UseAgentsOptions, type UseArchitectChatOptions, type UseChatOptions, type UseKnowledgeBasesOptions, type UseMcpAdminOptions, type UseMcpConnectionsOptions, type UseMcpOptions, type UseMessagesResult, type UseRcpSourcesOptions, type UseSkillsOptions, type UseVoiceOptions, type UseVoiceResult, type UseWorkflowOptions, type UseWorkflowRunsOptions, type UseWorkflowStreamOptions, type UseWorkflowStreamResult, type UseWorkflowsOptions, VERSION, type WorkflowsPagination, openSSEStream, supportsStreamingFetch, useAgents, useArchitectChat, useChat, useConnection, useFiles, useKnowledgeBases, useMcp, useMcpAdmin, useMcpConnections, useMemory, useMessages, usePersonaContext, useRcpSources, useSkills, useThreads, useVoice, useWorkflow, useWorkflowRuns, useWorkflowStream, useWorkflows, useWorkspaceFiles };
package/dist/index.js CHANGED
@@ -65,10 +65,33 @@ function PersonaProvider({
65
65
  ok: res.ok
66
66
  });
67
67
  if (!res.ok) {
68
+ const parsedResult = { isJson: false };
69
+ try {
70
+ const body = await res.clone().json();
71
+ if (body && typeof body === "object") {
72
+ const message = body.error?.message ?? body.message ?? void 0;
73
+ if (body.error?.code ?? message) {
74
+ parsedResult.isJson = true;
75
+ parsedResult.info = {
76
+ status: res.status,
77
+ code: body.error?.code,
78
+ message
79
+ };
80
+ }
81
+ }
82
+ } catch {
83
+ }
68
84
  logger.warn("fetchWithAuth non-ok", {
69
85
  path: cleanPath,
70
- status: res.status
86
+ status: res.status,
87
+ ...parsedResult.info ?? {}
71
88
  });
89
+ if (parsedResult.info) {
90
+ try {
91
+ res.personaError = parsedResult.info;
92
+ } catch {
93
+ }
94
+ }
72
95
  } else {
73
96
  logger.info("fetchWithAuth succeeded", {
74
97
  path: cleanPath,
@@ -364,6 +387,14 @@ function normalizePendingInterrupt(pending) {
364
387
  }
365
388
 
366
389
  // src/hooks/useChat.ts
390
+ function httpFailure(res, what) {
391
+ const info = res.personaError;
392
+ if (!info || !info.code && !info.message) {
393
+ return new Error(`Failed to ${what}: ${res.statusText || res.status}`);
394
+ }
395
+ const parts = [info.status, info.code, info.message].filter(Boolean).join(", ");
396
+ return new Error(`Failed to ${what}: ${parts}`);
397
+ }
367
398
  function parseSandboxCommand(tc) {
368
399
  let command = tc.args ?? "";
369
400
  try {
@@ -496,8 +527,7 @@ function useChat(options = {}) {
496
527
  setError(null);
497
528
  try {
498
529
  const res = await fetchWithAuth(`/threads/${id}/messages`);
499
- if (!res.ok)
500
- throw new Error(`Failed to load thread history: ${res.statusText}`);
530
+ if (!res.ok) throw httpFailure(res, "load thread history");
501
531
  const body = await res.json();
502
532
  const data = body?.data ?? body;
503
533
  const raw = data?.messages ?? [];
@@ -757,7 +787,7 @@ function useChat(options = {}) {
757
787
  headers: { "Content-Type": "application/json" },
758
788
  body: JSON.stringify({ agentId: targetAgentId })
759
789
  });
760
- if (!createRes.ok) throw new Error(`Failed to create thread: ${createRes.statusText}`);
790
+ if (!createRes.ok) throw httpFailure(createRes, "create thread");
761
791
  const createBody = await createRes.json();
762
792
  const created = createBody?.data ?? createBody;
763
793
  resolvedThreadId = created._id ?? created.id;
@@ -933,6 +963,13 @@ function useChat(options = {}) {
933
963
  patchAssistant({});
934
964
  }
935
965
  }
966
+ } else if (event.name === "mcp_auth_required") {
967
+ const val = event.value;
968
+ const servers = val?.servers ?? [];
969
+ if (servers.length > 0) {
970
+ chatLogger.info("mcp auth required", { mcpIds: servers.map((s) => s.mcpId) });
971
+ options.onMcpAuthRequired?.(servers);
972
+ }
936
973
  }
937
974
  } else if (event.type === "title") {
938
975
  const title = event.title;
@@ -2873,7 +2910,7 @@ function useMcpConnections(options = {}) {
2873
2910
  throw new Error(`Failed to disconnect MCP: ${res.statusText}`);
2874
2911
  setConnections(
2875
2912
  (prev) => prev.map(
2876
- (c) => c.mcpId === mcpId ? { ...c, connected: false, authorizeUrl: null } : c
2913
+ (c) => c.mcpId === mcpId ? { ...c, connected: false, status: "not_connected", authorizeUrl: null } : c
2877
2914
  )
2878
2915
  );
2879
2916
  void fetchConnections();
@@ -4372,7 +4409,7 @@ import {
4372
4409
  getLogLevel,
4373
4410
  isLevelEnabled
4374
4411
  } from "@personaai/logger";
4375
- var VERSION = "0.18.0";
4412
+ var VERSION = "0.19.0";
4376
4413
  export {
4377
4414
  ARCHITECT_AGENT_ID,
4378
4415
  PersonaProvider,