@personaai/react 0.5.1 → 0.5.4

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
@@ -1,7 +1,9 @@
1
1
  import * as react from 'react';
2
2
  import react__default, { ReactNode } from 'react';
3
+ import { LogLevel, Logger } from '@personaai/logger';
4
+ export { CreateLoggerOptions, LogLevel, LogTransport, Logger, createLogger, createNoopLogger, getLogLevel, isLevelEnabled, setLogLevel } from '@personaai/logger';
3
5
 
4
- type PersonaRole = 'user' | 'assistant' | 'system' | 'reasoning';
6
+ type PersonaRole = "user" | "assistant" | "system" | "reasoning";
5
7
  /**
6
8
  * A reasoning (chain-of-thought) message, streamed ahead of the assistant's
7
9
  * answer. Each provider reasoning phase is its OWN message — the SDK never
@@ -10,7 +12,7 @@ type PersonaRole = 'user' | 'assistant' | 'system' | 'reasoning';
10
12
  */
11
13
  /** One live update on a running `task` (subagent) tool call's timeline. */
12
14
  interface PersonaSubagentActivityEntry {
13
- kind: 'text' | 'tool_start' | 'tool_result';
15
+ kind: "text" | "tool_start" | "tool_result";
14
16
  toolName?: string;
15
17
  args?: string;
16
18
  result?: string;
@@ -22,6 +24,13 @@ interface PersonaToolCall {
22
24
  args?: string;
23
25
  result?: string;
24
26
  isError?: boolean;
27
+ /**
28
+ * Monotonic stream-order index, assigned when the call's first chunk
29
+ * arrives. Reasoning phases and tool calls share the same counter, so a
30
+ * client can interleave them chronologically (thought → tool → thought →
31
+ * tool → answer). Absent on calls loaded from history.
32
+ */
33
+ seq?: number;
25
34
  /** Nested activity timeline — only present on `task` (subagent) tool calls. */
26
35
  subagentActivity?: PersonaSubagentActivityEntry[];
27
36
  }
@@ -32,6 +41,12 @@ interface PersonaMessage {
32
41
  createdAt: Date;
33
42
  isStreaming?: boolean;
34
43
  toolCalls?: PersonaToolCall[];
44
+ /**
45
+ * Monotonic stream-order index for `role: 'reasoning'` messages, from the
46
+ * same counter as `PersonaToolCall.seq` — lets clients place each reasoning
47
+ * phase in its chronological spot relative to the tool calls that bracket it.
48
+ */
49
+ seq?: number;
35
50
  /**
36
51
  * @deprecated Model reasoning now streams as its own `role: 'reasoning'`
37
52
  * messages (one per phase, never merged). These fields are retained for
@@ -53,17 +68,17 @@ interface PersonaClarificationQuestion {
53
68
  }
54
69
  /** A paused human-in-the-loop tool approval, or a paused clarification question. */
55
70
  type PersonaInterrupt = {
56
- kind: 'hitl';
71
+ kind: "hitl";
57
72
  actionRequests: PersonaHitlActionRequest[];
58
73
  reviewConfigs: unknown[];
59
74
  } | {
60
- kind: 'clarification';
75
+ kind: "clarification";
61
76
  questions: PersonaClarificationQuestion[];
62
77
  };
63
78
  /** What to send back in `sendMessage(content, { resume })` to unpause a paused run. */
64
79
  type PersonaResumeValue = {
65
80
  decisions: Array<{
66
- type: 'approve' | 'reject';
81
+ type: "approve" | "reject";
67
82
  message?: string;
68
83
  }>;
69
84
  } | {
@@ -99,6 +114,10 @@ interface PersonaProviderProps {
99
114
  getAuthToken?: () => Promise<string | null | undefined> | string | null | undefined;
100
115
  /** Default Agent ID to direct chat conversations to */
101
116
  defaultAgentId?: string;
117
+ /** Log level for the React SDK — off by default. */
118
+ logLevel?: LogLevel;
119
+ /** Custom logger instance — when provided, `logLevel` is ignored. */
120
+ logger?: Logger;
102
121
  children: ReactNode;
103
122
  }
104
123
  interface PersonaThread {
@@ -127,7 +146,7 @@ interface PersonaFileItem {
127
146
  createdAt: string;
128
147
  }
129
148
  interface PersonaMemoryFile {
130
- scope?: 'user' | 'agent';
149
+ scope?: "user" | "agent";
131
150
  agentId?: string;
132
151
  path: string;
133
152
  content: string;
@@ -154,34 +173,34 @@ interface PersonaMemoryList {
154
173
  * and `REASONING_END` rather than `REASONING_MESSAGE_END`).
155
174
  */
156
175
  type PersonaStreamingEvent = {
157
- type: 'TEXT_MESSAGE_CHUNK';
176
+ type: "TEXT_MESSAGE_CHUNK";
158
177
  delta: string;
159
178
  messageId?: string;
160
- role?: 'assistant';
179
+ role?: "assistant";
161
180
  } | {
162
- type: 'TOOL_CALL_CHUNK';
181
+ type: "TOOL_CALL_CHUNK";
163
182
  toolCallId?: string;
164
183
  toolCallName?: string;
165
184
  delta?: string;
166
185
  parentMessageId?: string;
167
186
  } | {
168
- type: 'TOOL_CALL_RESULT';
187
+ type: "TOOL_CALL_RESULT";
169
188
  toolCallId: string;
170
189
  content: string;
171
190
  messageId?: string;
172
- role?: 'tool';
191
+ role?: "tool";
173
192
  structuredContent?: unknown;
174
193
  } | {
175
- type: 'REASONING_MESSAGE_START';
194
+ type: "REASONING_MESSAGE_START";
176
195
  messageId: string;
177
196
  } | {
178
- type: 'REASONING_MESSAGE_CONTENT';
197
+ type: "REASONING_MESSAGE_CONTENT";
179
198
  messageId: string;
180
199
  delta: string;
181
200
  } | {
182
- type: 'REASONING_END';
201
+ type: "REASONING_END";
183
202
  } | {
184
- type: 'STATE_SNAPSHOT';
203
+ type: "STATE_SNAPSHOT";
185
204
  /** Raw wire shape (snake_case timestamps) — useChat normalizes this into `files`/`todos`. */
186
205
  snapshot: {
187
206
  files: Record<string, {
@@ -193,41 +212,41 @@ type PersonaStreamingEvent = {
193
212
  todos: PersonaTodo[];
194
213
  };
195
214
  } | {
196
- type: 'RUN_ERROR';
215
+ type: "RUN_ERROR";
197
216
  code: string;
198
217
  message: string;
199
218
  retryable?: boolean;
200
219
  providerName?: string;
201
220
  } | {
202
- type: 'CUSTOM';
203
- name: 'hitl_request';
221
+ type: "CUSTOM";
222
+ name: "hitl_request";
204
223
  value: {
205
224
  actionRequests: PersonaHitlActionRequest[];
206
225
  reviewConfigs: unknown[];
207
226
  };
208
227
  } | {
209
- type: 'CUSTOM';
210
- name: 'clarification_request';
228
+ type: "CUSTOM";
229
+ name: "clarification_request";
211
230
  value: {
212
231
  questions: PersonaClarificationQuestion[];
213
232
  currentIndex: number;
214
233
  };
215
234
  } | {
216
- type: 'CUSTOM';
217
- name: 'subagent_activity';
235
+ type: "CUSTOM";
236
+ name: "subagent_activity";
218
237
  value: {
219
238
  toolCallId: string;
220
239
  } & PersonaSubagentActivityEntry;
221
240
  } | {
222
- type: 'CUSTOM';
223
- name: 'mcp_app';
241
+ type: "CUSTOM";
242
+ name: "mcp_app";
224
243
  value: {
225
244
  toolCallId: string;
226
245
  resourceUri: string;
227
246
  mcpId: string;
228
247
  };
229
248
  } | {
230
- type: 'CUSTOM';
249
+ type: "CUSTOM";
231
250
  name: string & {};
232
251
  value: unknown;
233
252
  };
@@ -262,8 +281,9 @@ interface PersonaContextValue {
262
281
  getAuthToken?: () => Promise<string | null | undefined> | string | null | undefined;
263
282
  defaultAgentId?: string;
264
283
  fetchWithAuth: (path: string, init?: RequestInit) => Promise<Response>;
284
+ logger: Logger;
265
285
  }
266
- declare function PersonaProvider({ baseUrl, getAuthToken, defaultAgentId, children, }: PersonaProviderProps): react__default.JSX.Element;
286
+ declare function PersonaProvider({ baseUrl, getAuthToken, defaultAgentId, logLevel, logger: loggerProp, children, }: PersonaProviderProps): react__default.JSX.Element;
267
287
  declare function usePersonaContext(): PersonaContextValue;
268
288
 
269
289
  declare function useChat(options?: UseChatOptions): {
@@ -481,6 +501,6 @@ declare function supportsStreamingFetch(): boolean;
481
501
  */
482
502
  declare function openSSEStream(opts: OpenSSEOptions): Promise<SSEStream>;
483
503
 
484
- declare const VERSION = "0.4.0";
504
+ declare const VERSION = "0.5.4";
485
505
 
486
506
  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 PersonaWorkspaceFile, type SSEReader, type SSEStream, type SendMessageOverride, type UseChatOptions, type UseMcpConnectionsOptions, VERSION, openSSEStream, supportsStreamingFetch, useAgents, useChat, useConnection, useFiles, useMcpConnections, useMemory, usePersonaContext, useThreads };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import * as react from 'react';
2
2
  import react__default, { ReactNode } from 'react';
3
+ import { LogLevel, Logger } from '@personaai/logger';
4
+ export { CreateLoggerOptions, LogLevel, LogTransport, Logger, createLogger, createNoopLogger, getLogLevel, isLevelEnabled, setLogLevel } from '@personaai/logger';
3
5
 
4
- type PersonaRole = 'user' | 'assistant' | 'system' | 'reasoning';
6
+ type PersonaRole = "user" | "assistant" | "system" | "reasoning";
5
7
  /**
6
8
  * A reasoning (chain-of-thought) message, streamed ahead of the assistant's
7
9
  * answer. Each provider reasoning phase is its OWN message — the SDK never
@@ -10,7 +12,7 @@ type PersonaRole = 'user' | 'assistant' | 'system' | 'reasoning';
10
12
  */
11
13
  /** One live update on a running `task` (subagent) tool call's timeline. */
12
14
  interface PersonaSubagentActivityEntry {
13
- kind: 'text' | 'tool_start' | 'tool_result';
15
+ kind: "text" | "tool_start" | "tool_result";
14
16
  toolName?: string;
15
17
  args?: string;
16
18
  result?: string;
@@ -22,6 +24,13 @@ interface PersonaToolCall {
22
24
  args?: string;
23
25
  result?: string;
24
26
  isError?: boolean;
27
+ /**
28
+ * Monotonic stream-order index, assigned when the call's first chunk
29
+ * arrives. Reasoning phases and tool calls share the same counter, so a
30
+ * client can interleave them chronologically (thought → tool → thought →
31
+ * tool → answer). Absent on calls loaded from history.
32
+ */
33
+ seq?: number;
25
34
  /** Nested activity timeline — only present on `task` (subagent) tool calls. */
26
35
  subagentActivity?: PersonaSubagentActivityEntry[];
27
36
  }
@@ -32,6 +41,12 @@ interface PersonaMessage {
32
41
  createdAt: Date;
33
42
  isStreaming?: boolean;
34
43
  toolCalls?: PersonaToolCall[];
44
+ /**
45
+ * Monotonic stream-order index for `role: 'reasoning'` messages, from the
46
+ * same counter as `PersonaToolCall.seq` — lets clients place each reasoning
47
+ * phase in its chronological spot relative to the tool calls that bracket it.
48
+ */
49
+ seq?: number;
35
50
  /**
36
51
  * @deprecated Model reasoning now streams as its own `role: 'reasoning'`
37
52
  * messages (one per phase, never merged). These fields are retained for
@@ -53,17 +68,17 @@ interface PersonaClarificationQuestion {
53
68
  }
54
69
  /** A paused human-in-the-loop tool approval, or a paused clarification question. */
55
70
  type PersonaInterrupt = {
56
- kind: 'hitl';
71
+ kind: "hitl";
57
72
  actionRequests: PersonaHitlActionRequest[];
58
73
  reviewConfigs: unknown[];
59
74
  } | {
60
- kind: 'clarification';
75
+ kind: "clarification";
61
76
  questions: PersonaClarificationQuestion[];
62
77
  };
63
78
  /** What to send back in `sendMessage(content, { resume })` to unpause a paused run. */
64
79
  type PersonaResumeValue = {
65
80
  decisions: Array<{
66
- type: 'approve' | 'reject';
81
+ type: "approve" | "reject";
67
82
  message?: string;
68
83
  }>;
69
84
  } | {
@@ -99,6 +114,10 @@ interface PersonaProviderProps {
99
114
  getAuthToken?: () => Promise<string | null | undefined> | string | null | undefined;
100
115
  /** Default Agent ID to direct chat conversations to */
101
116
  defaultAgentId?: string;
117
+ /** Log level for the React SDK — off by default. */
118
+ logLevel?: LogLevel;
119
+ /** Custom logger instance — when provided, `logLevel` is ignored. */
120
+ logger?: Logger;
102
121
  children: ReactNode;
103
122
  }
104
123
  interface PersonaThread {
@@ -127,7 +146,7 @@ interface PersonaFileItem {
127
146
  createdAt: string;
128
147
  }
129
148
  interface PersonaMemoryFile {
130
- scope?: 'user' | 'agent';
149
+ scope?: "user" | "agent";
131
150
  agentId?: string;
132
151
  path: string;
133
152
  content: string;
@@ -154,34 +173,34 @@ interface PersonaMemoryList {
154
173
  * and `REASONING_END` rather than `REASONING_MESSAGE_END`).
155
174
  */
156
175
  type PersonaStreamingEvent = {
157
- type: 'TEXT_MESSAGE_CHUNK';
176
+ type: "TEXT_MESSAGE_CHUNK";
158
177
  delta: string;
159
178
  messageId?: string;
160
- role?: 'assistant';
179
+ role?: "assistant";
161
180
  } | {
162
- type: 'TOOL_CALL_CHUNK';
181
+ type: "TOOL_CALL_CHUNK";
163
182
  toolCallId?: string;
164
183
  toolCallName?: string;
165
184
  delta?: string;
166
185
  parentMessageId?: string;
167
186
  } | {
168
- type: 'TOOL_CALL_RESULT';
187
+ type: "TOOL_CALL_RESULT";
169
188
  toolCallId: string;
170
189
  content: string;
171
190
  messageId?: string;
172
- role?: 'tool';
191
+ role?: "tool";
173
192
  structuredContent?: unknown;
174
193
  } | {
175
- type: 'REASONING_MESSAGE_START';
194
+ type: "REASONING_MESSAGE_START";
176
195
  messageId: string;
177
196
  } | {
178
- type: 'REASONING_MESSAGE_CONTENT';
197
+ type: "REASONING_MESSAGE_CONTENT";
179
198
  messageId: string;
180
199
  delta: string;
181
200
  } | {
182
- type: 'REASONING_END';
201
+ type: "REASONING_END";
183
202
  } | {
184
- type: 'STATE_SNAPSHOT';
203
+ type: "STATE_SNAPSHOT";
185
204
  /** Raw wire shape (snake_case timestamps) — useChat normalizes this into `files`/`todos`. */
186
205
  snapshot: {
187
206
  files: Record<string, {
@@ -193,41 +212,41 @@ type PersonaStreamingEvent = {
193
212
  todos: PersonaTodo[];
194
213
  };
195
214
  } | {
196
- type: 'RUN_ERROR';
215
+ type: "RUN_ERROR";
197
216
  code: string;
198
217
  message: string;
199
218
  retryable?: boolean;
200
219
  providerName?: string;
201
220
  } | {
202
- type: 'CUSTOM';
203
- name: 'hitl_request';
221
+ type: "CUSTOM";
222
+ name: "hitl_request";
204
223
  value: {
205
224
  actionRequests: PersonaHitlActionRequest[];
206
225
  reviewConfigs: unknown[];
207
226
  };
208
227
  } | {
209
- type: 'CUSTOM';
210
- name: 'clarification_request';
228
+ type: "CUSTOM";
229
+ name: "clarification_request";
211
230
  value: {
212
231
  questions: PersonaClarificationQuestion[];
213
232
  currentIndex: number;
214
233
  };
215
234
  } | {
216
- type: 'CUSTOM';
217
- name: 'subagent_activity';
235
+ type: "CUSTOM";
236
+ name: "subagent_activity";
218
237
  value: {
219
238
  toolCallId: string;
220
239
  } & PersonaSubagentActivityEntry;
221
240
  } | {
222
- type: 'CUSTOM';
223
- name: 'mcp_app';
241
+ type: "CUSTOM";
242
+ name: "mcp_app";
224
243
  value: {
225
244
  toolCallId: string;
226
245
  resourceUri: string;
227
246
  mcpId: string;
228
247
  };
229
248
  } | {
230
- type: 'CUSTOM';
249
+ type: "CUSTOM";
231
250
  name: string & {};
232
251
  value: unknown;
233
252
  };
@@ -262,8 +281,9 @@ interface PersonaContextValue {
262
281
  getAuthToken?: () => Promise<string | null | undefined> | string | null | undefined;
263
282
  defaultAgentId?: string;
264
283
  fetchWithAuth: (path: string, init?: RequestInit) => Promise<Response>;
284
+ logger: Logger;
265
285
  }
266
- declare function PersonaProvider({ baseUrl, getAuthToken, defaultAgentId, children, }: PersonaProviderProps): react__default.JSX.Element;
286
+ declare function PersonaProvider({ baseUrl, getAuthToken, defaultAgentId, logLevel, logger: loggerProp, children, }: PersonaProviderProps): react__default.JSX.Element;
267
287
  declare function usePersonaContext(): PersonaContextValue;
268
288
 
269
289
  declare function useChat(options?: UseChatOptions): {
@@ -481,6 +501,6 @@ declare function supportsStreamingFetch(): boolean;
481
501
  */
482
502
  declare function openSSEStream(opts: OpenSSEOptions): Promise<SSEStream>;
483
503
 
484
- declare const VERSION = "0.4.0";
504
+ declare const VERSION = "0.5.4";
485
505
 
486
506
  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 PersonaWorkspaceFile, type SSEReader, type SSEStream, type SendMessageOverride, type UseChatOptions, type UseMcpConnectionsOptions, VERSION, openSSEStream, supportsStreamingFetch, useAgents, useChat, useConnection, useFiles, useMcpConnections, useMemory, usePersonaContext, useThreads };