@personaai/react 0.5.2 → 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.cjs +420 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -27
- package/dist/index.d.ts +34 -27
- package/dist/index.js +422 -66
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
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 =
|
|
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:
|
|
15
|
+
kind: "text" | "tool_start" | "tool_result";
|
|
14
16
|
toolName?: string;
|
|
15
17
|
args?: string;
|
|
16
18
|
result?: string;
|
|
@@ -66,17 +68,17 @@ interface PersonaClarificationQuestion {
|
|
|
66
68
|
}
|
|
67
69
|
/** A paused human-in-the-loop tool approval, or a paused clarification question. */
|
|
68
70
|
type PersonaInterrupt = {
|
|
69
|
-
kind:
|
|
71
|
+
kind: "hitl";
|
|
70
72
|
actionRequests: PersonaHitlActionRequest[];
|
|
71
73
|
reviewConfigs: unknown[];
|
|
72
74
|
} | {
|
|
73
|
-
kind:
|
|
75
|
+
kind: "clarification";
|
|
74
76
|
questions: PersonaClarificationQuestion[];
|
|
75
77
|
};
|
|
76
78
|
/** What to send back in `sendMessage(content, { resume })` to unpause a paused run. */
|
|
77
79
|
type PersonaResumeValue = {
|
|
78
80
|
decisions: Array<{
|
|
79
|
-
type:
|
|
81
|
+
type: "approve" | "reject";
|
|
80
82
|
message?: string;
|
|
81
83
|
}>;
|
|
82
84
|
} | {
|
|
@@ -112,6 +114,10 @@ interface PersonaProviderProps {
|
|
|
112
114
|
getAuthToken?: () => Promise<string | null | undefined> | string | null | undefined;
|
|
113
115
|
/** Default Agent ID to direct chat conversations to */
|
|
114
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;
|
|
115
121
|
children: ReactNode;
|
|
116
122
|
}
|
|
117
123
|
interface PersonaThread {
|
|
@@ -140,7 +146,7 @@ interface PersonaFileItem {
|
|
|
140
146
|
createdAt: string;
|
|
141
147
|
}
|
|
142
148
|
interface PersonaMemoryFile {
|
|
143
|
-
scope?:
|
|
149
|
+
scope?: "user" | "agent";
|
|
144
150
|
agentId?: string;
|
|
145
151
|
path: string;
|
|
146
152
|
content: string;
|
|
@@ -167,34 +173,34 @@ interface PersonaMemoryList {
|
|
|
167
173
|
* and `REASONING_END` rather than `REASONING_MESSAGE_END`).
|
|
168
174
|
*/
|
|
169
175
|
type PersonaStreamingEvent = {
|
|
170
|
-
type:
|
|
176
|
+
type: "TEXT_MESSAGE_CHUNK";
|
|
171
177
|
delta: string;
|
|
172
178
|
messageId?: string;
|
|
173
|
-
role?:
|
|
179
|
+
role?: "assistant";
|
|
174
180
|
} | {
|
|
175
|
-
type:
|
|
181
|
+
type: "TOOL_CALL_CHUNK";
|
|
176
182
|
toolCallId?: string;
|
|
177
183
|
toolCallName?: string;
|
|
178
184
|
delta?: string;
|
|
179
185
|
parentMessageId?: string;
|
|
180
186
|
} | {
|
|
181
|
-
type:
|
|
187
|
+
type: "TOOL_CALL_RESULT";
|
|
182
188
|
toolCallId: string;
|
|
183
189
|
content: string;
|
|
184
190
|
messageId?: string;
|
|
185
|
-
role?:
|
|
191
|
+
role?: "tool";
|
|
186
192
|
structuredContent?: unknown;
|
|
187
193
|
} | {
|
|
188
|
-
type:
|
|
194
|
+
type: "REASONING_MESSAGE_START";
|
|
189
195
|
messageId: string;
|
|
190
196
|
} | {
|
|
191
|
-
type:
|
|
197
|
+
type: "REASONING_MESSAGE_CONTENT";
|
|
192
198
|
messageId: string;
|
|
193
199
|
delta: string;
|
|
194
200
|
} | {
|
|
195
|
-
type:
|
|
201
|
+
type: "REASONING_END";
|
|
196
202
|
} | {
|
|
197
|
-
type:
|
|
203
|
+
type: "STATE_SNAPSHOT";
|
|
198
204
|
/** Raw wire shape (snake_case timestamps) — useChat normalizes this into `files`/`todos`. */
|
|
199
205
|
snapshot: {
|
|
200
206
|
files: Record<string, {
|
|
@@ -206,41 +212,41 @@ type PersonaStreamingEvent = {
|
|
|
206
212
|
todos: PersonaTodo[];
|
|
207
213
|
};
|
|
208
214
|
} | {
|
|
209
|
-
type:
|
|
215
|
+
type: "RUN_ERROR";
|
|
210
216
|
code: string;
|
|
211
217
|
message: string;
|
|
212
218
|
retryable?: boolean;
|
|
213
219
|
providerName?: string;
|
|
214
220
|
} | {
|
|
215
|
-
type:
|
|
216
|
-
name:
|
|
221
|
+
type: "CUSTOM";
|
|
222
|
+
name: "hitl_request";
|
|
217
223
|
value: {
|
|
218
224
|
actionRequests: PersonaHitlActionRequest[];
|
|
219
225
|
reviewConfigs: unknown[];
|
|
220
226
|
};
|
|
221
227
|
} | {
|
|
222
|
-
type:
|
|
223
|
-
name:
|
|
228
|
+
type: "CUSTOM";
|
|
229
|
+
name: "clarification_request";
|
|
224
230
|
value: {
|
|
225
231
|
questions: PersonaClarificationQuestion[];
|
|
226
232
|
currentIndex: number;
|
|
227
233
|
};
|
|
228
234
|
} | {
|
|
229
|
-
type:
|
|
230
|
-
name:
|
|
235
|
+
type: "CUSTOM";
|
|
236
|
+
name: "subagent_activity";
|
|
231
237
|
value: {
|
|
232
238
|
toolCallId: string;
|
|
233
239
|
} & PersonaSubagentActivityEntry;
|
|
234
240
|
} | {
|
|
235
|
-
type:
|
|
236
|
-
name:
|
|
241
|
+
type: "CUSTOM";
|
|
242
|
+
name: "mcp_app";
|
|
237
243
|
value: {
|
|
238
244
|
toolCallId: string;
|
|
239
245
|
resourceUri: string;
|
|
240
246
|
mcpId: string;
|
|
241
247
|
};
|
|
242
248
|
} | {
|
|
243
|
-
type:
|
|
249
|
+
type: "CUSTOM";
|
|
244
250
|
name: string & {};
|
|
245
251
|
value: unknown;
|
|
246
252
|
};
|
|
@@ -275,8 +281,9 @@ interface PersonaContextValue {
|
|
|
275
281
|
getAuthToken?: () => Promise<string | null | undefined> | string | null | undefined;
|
|
276
282
|
defaultAgentId?: string;
|
|
277
283
|
fetchWithAuth: (path: string, init?: RequestInit) => Promise<Response>;
|
|
284
|
+
logger: Logger;
|
|
278
285
|
}
|
|
279
|
-
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;
|
|
280
287
|
declare function usePersonaContext(): PersonaContextValue;
|
|
281
288
|
|
|
282
289
|
declare function useChat(options?: UseChatOptions): {
|
|
@@ -494,6 +501,6 @@ declare function supportsStreamingFetch(): boolean;
|
|
|
494
501
|
*/
|
|
495
502
|
declare function openSSEStream(opts: OpenSSEOptions): Promise<SSEStream>;
|
|
496
503
|
|
|
497
|
-
declare const VERSION = "0.4
|
|
504
|
+
declare const VERSION = "0.5.4";
|
|
498
505
|
|
|
499
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 =
|
|
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:
|
|
15
|
+
kind: "text" | "tool_start" | "tool_result";
|
|
14
16
|
toolName?: string;
|
|
15
17
|
args?: string;
|
|
16
18
|
result?: string;
|
|
@@ -66,17 +68,17 @@ interface PersonaClarificationQuestion {
|
|
|
66
68
|
}
|
|
67
69
|
/** A paused human-in-the-loop tool approval, or a paused clarification question. */
|
|
68
70
|
type PersonaInterrupt = {
|
|
69
|
-
kind:
|
|
71
|
+
kind: "hitl";
|
|
70
72
|
actionRequests: PersonaHitlActionRequest[];
|
|
71
73
|
reviewConfigs: unknown[];
|
|
72
74
|
} | {
|
|
73
|
-
kind:
|
|
75
|
+
kind: "clarification";
|
|
74
76
|
questions: PersonaClarificationQuestion[];
|
|
75
77
|
};
|
|
76
78
|
/** What to send back in `sendMessage(content, { resume })` to unpause a paused run. */
|
|
77
79
|
type PersonaResumeValue = {
|
|
78
80
|
decisions: Array<{
|
|
79
|
-
type:
|
|
81
|
+
type: "approve" | "reject";
|
|
80
82
|
message?: string;
|
|
81
83
|
}>;
|
|
82
84
|
} | {
|
|
@@ -112,6 +114,10 @@ interface PersonaProviderProps {
|
|
|
112
114
|
getAuthToken?: () => Promise<string | null | undefined> | string | null | undefined;
|
|
113
115
|
/** Default Agent ID to direct chat conversations to */
|
|
114
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;
|
|
115
121
|
children: ReactNode;
|
|
116
122
|
}
|
|
117
123
|
interface PersonaThread {
|
|
@@ -140,7 +146,7 @@ interface PersonaFileItem {
|
|
|
140
146
|
createdAt: string;
|
|
141
147
|
}
|
|
142
148
|
interface PersonaMemoryFile {
|
|
143
|
-
scope?:
|
|
149
|
+
scope?: "user" | "agent";
|
|
144
150
|
agentId?: string;
|
|
145
151
|
path: string;
|
|
146
152
|
content: string;
|
|
@@ -167,34 +173,34 @@ interface PersonaMemoryList {
|
|
|
167
173
|
* and `REASONING_END` rather than `REASONING_MESSAGE_END`).
|
|
168
174
|
*/
|
|
169
175
|
type PersonaStreamingEvent = {
|
|
170
|
-
type:
|
|
176
|
+
type: "TEXT_MESSAGE_CHUNK";
|
|
171
177
|
delta: string;
|
|
172
178
|
messageId?: string;
|
|
173
|
-
role?:
|
|
179
|
+
role?: "assistant";
|
|
174
180
|
} | {
|
|
175
|
-
type:
|
|
181
|
+
type: "TOOL_CALL_CHUNK";
|
|
176
182
|
toolCallId?: string;
|
|
177
183
|
toolCallName?: string;
|
|
178
184
|
delta?: string;
|
|
179
185
|
parentMessageId?: string;
|
|
180
186
|
} | {
|
|
181
|
-
type:
|
|
187
|
+
type: "TOOL_CALL_RESULT";
|
|
182
188
|
toolCallId: string;
|
|
183
189
|
content: string;
|
|
184
190
|
messageId?: string;
|
|
185
|
-
role?:
|
|
191
|
+
role?: "tool";
|
|
186
192
|
structuredContent?: unknown;
|
|
187
193
|
} | {
|
|
188
|
-
type:
|
|
194
|
+
type: "REASONING_MESSAGE_START";
|
|
189
195
|
messageId: string;
|
|
190
196
|
} | {
|
|
191
|
-
type:
|
|
197
|
+
type: "REASONING_MESSAGE_CONTENT";
|
|
192
198
|
messageId: string;
|
|
193
199
|
delta: string;
|
|
194
200
|
} | {
|
|
195
|
-
type:
|
|
201
|
+
type: "REASONING_END";
|
|
196
202
|
} | {
|
|
197
|
-
type:
|
|
203
|
+
type: "STATE_SNAPSHOT";
|
|
198
204
|
/** Raw wire shape (snake_case timestamps) — useChat normalizes this into `files`/`todos`. */
|
|
199
205
|
snapshot: {
|
|
200
206
|
files: Record<string, {
|
|
@@ -206,41 +212,41 @@ type PersonaStreamingEvent = {
|
|
|
206
212
|
todos: PersonaTodo[];
|
|
207
213
|
};
|
|
208
214
|
} | {
|
|
209
|
-
type:
|
|
215
|
+
type: "RUN_ERROR";
|
|
210
216
|
code: string;
|
|
211
217
|
message: string;
|
|
212
218
|
retryable?: boolean;
|
|
213
219
|
providerName?: string;
|
|
214
220
|
} | {
|
|
215
|
-
type:
|
|
216
|
-
name:
|
|
221
|
+
type: "CUSTOM";
|
|
222
|
+
name: "hitl_request";
|
|
217
223
|
value: {
|
|
218
224
|
actionRequests: PersonaHitlActionRequest[];
|
|
219
225
|
reviewConfigs: unknown[];
|
|
220
226
|
};
|
|
221
227
|
} | {
|
|
222
|
-
type:
|
|
223
|
-
name:
|
|
228
|
+
type: "CUSTOM";
|
|
229
|
+
name: "clarification_request";
|
|
224
230
|
value: {
|
|
225
231
|
questions: PersonaClarificationQuestion[];
|
|
226
232
|
currentIndex: number;
|
|
227
233
|
};
|
|
228
234
|
} | {
|
|
229
|
-
type:
|
|
230
|
-
name:
|
|
235
|
+
type: "CUSTOM";
|
|
236
|
+
name: "subagent_activity";
|
|
231
237
|
value: {
|
|
232
238
|
toolCallId: string;
|
|
233
239
|
} & PersonaSubagentActivityEntry;
|
|
234
240
|
} | {
|
|
235
|
-
type:
|
|
236
|
-
name:
|
|
241
|
+
type: "CUSTOM";
|
|
242
|
+
name: "mcp_app";
|
|
237
243
|
value: {
|
|
238
244
|
toolCallId: string;
|
|
239
245
|
resourceUri: string;
|
|
240
246
|
mcpId: string;
|
|
241
247
|
};
|
|
242
248
|
} | {
|
|
243
|
-
type:
|
|
249
|
+
type: "CUSTOM";
|
|
244
250
|
name: string & {};
|
|
245
251
|
value: unknown;
|
|
246
252
|
};
|
|
@@ -275,8 +281,9 @@ interface PersonaContextValue {
|
|
|
275
281
|
getAuthToken?: () => Promise<string | null | undefined> | string | null | undefined;
|
|
276
282
|
defaultAgentId?: string;
|
|
277
283
|
fetchWithAuth: (path: string, init?: RequestInit) => Promise<Response>;
|
|
284
|
+
logger: Logger;
|
|
278
285
|
}
|
|
279
|
-
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;
|
|
280
287
|
declare function usePersonaContext(): PersonaContextValue;
|
|
281
288
|
|
|
282
289
|
declare function useChat(options?: UseChatOptions): {
|
|
@@ -494,6 +501,6 @@ declare function supportsStreamingFetch(): boolean;
|
|
|
494
501
|
*/
|
|
495
502
|
declare function openSSEStream(opts: OpenSSEOptions): Promise<SSEStream>;
|
|
496
503
|
|
|
497
|
-
declare const VERSION = "0.4
|
|
504
|
+
declare const VERSION = "0.5.4";
|
|
498
505
|
|
|
499
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 };
|