@personaai/react 0.1.2 → 0.3.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 +240 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +198 -52
- package/dist/index.d.ts +198 -52
- package/dist/index.js +251 -58
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,12 +2,22 @@ import * as react from 'react';
|
|
|
2
2
|
import react__default, { ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
type PersonaRole = 'user' | 'assistant' | 'system';
|
|
5
|
+
/** One live update on a running `task` (subagent) tool call's timeline. */
|
|
6
|
+
interface PersonaSubagentActivityEntry {
|
|
7
|
+
kind: 'text' | 'tool_start' | 'tool_result';
|
|
8
|
+
toolName?: string;
|
|
9
|
+
args?: string;
|
|
10
|
+
result?: string;
|
|
11
|
+
delta?: string;
|
|
12
|
+
}
|
|
5
13
|
interface PersonaToolCall {
|
|
6
14
|
toolCallId: string;
|
|
7
15
|
toolName: string;
|
|
8
16
|
args?: string;
|
|
9
17
|
result?: string;
|
|
10
18
|
isError?: boolean;
|
|
19
|
+
/** Nested activity timeline — only present on `task` (subagent) tool calls. */
|
|
20
|
+
subagentActivity?: PersonaSubagentActivityEntry[];
|
|
11
21
|
}
|
|
12
22
|
interface PersonaMessage {
|
|
13
23
|
id: string;
|
|
@@ -16,6 +26,61 @@ interface PersonaMessage {
|
|
|
16
26
|
createdAt: Date;
|
|
17
27
|
isStreaming?: boolean;
|
|
18
28
|
toolCalls?: PersonaToolCall[];
|
|
29
|
+
/** Model reasoning/thinking text streamed ahead of the final answer, when the provider exposes it. */
|
|
30
|
+
reasoning?: string;
|
|
31
|
+
isReasoning?: boolean;
|
|
32
|
+
}
|
|
33
|
+
interface PersonaHitlActionRequest {
|
|
34
|
+
name: string;
|
|
35
|
+
args?: unknown;
|
|
36
|
+
}
|
|
37
|
+
interface PersonaClarificationQuestion {
|
|
38
|
+
id: string;
|
|
39
|
+
text: string;
|
|
40
|
+
options: string[];
|
|
41
|
+
required: boolean;
|
|
42
|
+
allowCustom: boolean;
|
|
43
|
+
}
|
|
44
|
+
/** A paused human-in-the-loop tool approval, or a paused clarification question. */
|
|
45
|
+
type PersonaInterrupt = {
|
|
46
|
+
kind: 'hitl';
|
|
47
|
+
actionRequests: PersonaHitlActionRequest[];
|
|
48
|
+
reviewConfigs: unknown[];
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'clarification';
|
|
51
|
+
questions: PersonaClarificationQuestion[];
|
|
52
|
+
};
|
|
53
|
+
/** What to send back in `sendMessage(content, { resume })` to unpause a paused run. */
|
|
54
|
+
type PersonaResumeValue = {
|
|
55
|
+
decisions: Array<{
|
|
56
|
+
type: 'approve' | 'reject';
|
|
57
|
+
message?: string;
|
|
58
|
+
}>;
|
|
59
|
+
} | {
|
|
60
|
+
answers: unknown[];
|
|
61
|
+
text?: string;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* A file in the agent's own virtual workspace (deepagents' state-backed
|
|
65
|
+
* filesystem — `write_file`/`read_file` tool calls, distinct from
|
|
66
|
+
* `PersonaFileItem` uploads). Populated from `STATE_SNAPSHOT` events, or
|
|
67
|
+
* from a reloaded thread's persisted state.
|
|
68
|
+
*/
|
|
69
|
+
interface PersonaWorkspaceFile {
|
|
70
|
+
content: string;
|
|
71
|
+
size: number;
|
|
72
|
+
createdAt: string | null;
|
|
73
|
+
modifiedAt: string | null;
|
|
74
|
+
}
|
|
75
|
+
interface PersonaTodo {
|
|
76
|
+
content: string;
|
|
77
|
+
status: string;
|
|
78
|
+
}
|
|
79
|
+
/** Set when the agent calls `present_file` to highlight a workspace file. */
|
|
80
|
+
interface PersonaPresentedFile {
|
|
81
|
+
path: string;
|
|
82
|
+
title: string;
|
|
83
|
+
description: string;
|
|
19
84
|
}
|
|
20
85
|
interface PersonaProviderProps {
|
|
21
86
|
/** Base URL where the Persona runtime / adapter is mounted, e.g. "http://localhost:4000/api/persona" */
|
|
@@ -28,73 +93,127 @@ interface PersonaProviderProps {
|
|
|
28
93
|
}
|
|
29
94
|
interface PersonaThread {
|
|
30
95
|
_id: string;
|
|
31
|
-
|
|
96
|
+
/** A bare id string on create()/get(); populated as an object on list(). */
|
|
97
|
+
agentId: string | {
|
|
98
|
+
_id: string;
|
|
99
|
+
name: string;
|
|
100
|
+
avatar?: string;
|
|
101
|
+
slug: string;
|
|
102
|
+
};
|
|
32
103
|
title?: string;
|
|
33
104
|
isArchived?: boolean;
|
|
34
105
|
createdAt: string;
|
|
35
106
|
updatedAt: string;
|
|
36
107
|
}
|
|
108
|
+
/** Mirrors the wire shape of `GET/POST /files` — `id`, not `_id`. */
|
|
109
|
+
interface PersonaFileItem {
|
|
110
|
+
id: string;
|
|
111
|
+
originalName: string;
|
|
112
|
+
mimeType: string;
|
|
113
|
+
/** Bytes. */
|
|
114
|
+
size: number;
|
|
115
|
+
agentId: string | null;
|
|
116
|
+
threadId: string | null;
|
|
117
|
+
createdAt: string;
|
|
118
|
+
}
|
|
37
119
|
interface PersonaMemoryFile {
|
|
120
|
+
scope?: 'user' | 'agent';
|
|
121
|
+
agentId?: string;
|
|
38
122
|
path: string;
|
|
39
123
|
content: string;
|
|
124
|
+
mimeType?: string;
|
|
125
|
+
createdAt?: string;
|
|
40
126
|
updatedAt?: string;
|
|
41
127
|
}
|
|
128
|
+
/** One agent's group of agent-scoped memory files, as returned by `GET /memory`. */
|
|
129
|
+
interface PersonaMemoryAgentGroup {
|
|
130
|
+
agentId: string;
|
|
131
|
+
/** `null` if the agent no longer exists. */
|
|
132
|
+
agentName: string | null;
|
|
133
|
+
files: PersonaMemoryFile[];
|
|
134
|
+
}
|
|
42
135
|
interface PersonaMemoryList {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
size?: number;
|
|
46
|
-
updatedAt?: string;
|
|
47
|
-
}>;
|
|
48
|
-
agents: Record<string, Array<{
|
|
49
|
-
path: string;
|
|
50
|
-
size?: number;
|
|
51
|
-
updatedAt?: string;
|
|
52
|
-
}>>;
|
|
136
|
+
userFiles: PersonaMemoryFile[];
|
|
137
|
+
agentMemories: PersonaMemoryAgentGroup[];
|
|
53
138
|
}
|
|
54
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* AG-UI protocol events emitted during streaming — mirrors exactly what
|
|
141
|
+
* `aguiTranslator.js` produces server-side (verified against that file, not
|
|
142
|
+
* guessed from the AG-UI spec: this backend only emits a subset, and uses
|
|
143
|
+
* `TOOL_CALL_CHUNK` rather than separate START/ARGS events for tool calls,
|
|
144
|
+
* and `REASONING_END` rather than `REASONING_MESSAGE_END`).
|
|
145
|
+
*/
|
|
55
146
|
type PersonaStreamingEvent = {
|
|
56
147
|
type: 'TEXT_MESSAGE_CHUNK';
|
|
57
148
|
delta: string;
|
|
58
149
|
messageId?: string;
|
|
150
|
+
role?: 'assistant';
|
|
59
151
|
} | {
|
|
60
|
-
type: '
|
|
61
|
-
toolCallId
|
|
62
|
-
|
|
152
|
+
type: 'TOOL_CALL_CHUNK';
|
|
153
|
+
toolCallId?: string;
|
|
154
|
+
toolCallName?: string;
|
|
155
|
+
delta?: string;
|
|
63
156
|
parentMessageId?: string;
|
|
64
|
-
} | {
|
|
65
|
-
type: 'TOOL_CALL_ARGS';
|
|
66
|
-
toolCallId: string;
|
|
67
|
-
delta: string;
|
|
68
157
|
} | {
|
|
69
158
|
type: 'TOOL_CALL_RESULT';
|
|
70
159
|
toolCallId: string;
|
|
71
|
-
|
|
72
|
-
|
|
160
|
+
content: string;
|
|
161
|
+
messageId?: string;
|
|
162
|
+
role?: 'tool';
|
|
163
|
+
structuredContent?: unknown;
|
|
73
164
|
} | {
|
|
74
|
-
type: '
|
|
75
|
-
|
|
76
|
-
threadId?: string;
|
|
165
|
+
type: 'REASONING_MESSAGE_START';
|
|
166
|
+
messageId: string;
|
|
77
167
|
} | {
|
|
78
|
-
type: '
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
168
|
+
type: 'REASONING_MESSAGE_CONTENT';
|
|
169
|
+
messageId: string;
|
|
170
|
+
delta: string;
|
|
171
|
+
} | {
|
|
172
|
+
type: 'REASONING_END';
|
|
173
|
+
} | {
|
|
174
|
+
type: 'STATE_SNAPSHOT';
|
|
175
|
+
snapshot: {
|
|
176
|
+
files: Record<string, PersonaWorkspaceFile>;
|
|
177
|
+
todos: PersonaTodo[];
|
|
83
178
|
};
|
|
84
179
|
} | {
|
|
85
180
|
type: 'RUN_ERROR';
|
|
86
181
|
code: string;
|
|
87
182
|
message: string;
|
|
183
|
+
retryable?: boolean;
|
|
184
|
+
providerName?: string;
|
|
88
185
|
} | {
|
|
89
|
-
type: '
|
|
90
|
-
|
|
186
|
+
type: 'CUSTOM';
|
|
187
|
+
name: 'hitl_request';
|
|
188
|
+
value: {
|
|
189
|
+
actionRequests: PersonaHitlActionRequest[];
|
|
190
|
+
reviewConfigs: unknown[];
|
|
191
|
+
};
|
|
91
192
|
} | {
|
|
92
|
-
type: '
|
|
93
|
-
|
|
193
|
+
type: 'CUSTOM';
|
|
194
|
+
name: 'clarification_request';
|
|
195
|
+
value: {
|
|
196
|
+
questions: PersonaClarificationQuestion[];
|
|
197
|
+
currentIndex: number;
|
|
198
|
+
};
|
|
94
199
|
} | {
|
|
95
200
|
type: 'CUSTOM';
|
|
96
|
-
name:
|
|
97
|
-
|
|
201
|
+
name: 'subagent_activity';
|
|
202
|
+
value: {
|
|
203
|
+
toolCallId: string;
|
|
204
|
+
} & PersonaSubagentActivityEntry;
|
|
205
|
+
} | {
|
|
206
|
+
type: 'CUSTOM';
|
|
207
|
+
name: 'mcp_app';
|
|
208
|
+
value: {
|
|
209
|
+
toolCallId: string;
|
|
210
|
+
resourceUri: string;
|
|
211
|
+
mcpId: string;
|
|
212
|
+
};
|
|
213
|
+
} | {
|
|
214
|
+
type: 'CUSTOM';
|
|
215
|
+
name: string & {};
|
|
216
|
+
value: unknown;
|
|
98
217
|
};
|
|
99
218
|
interface UseChatOptions {
|
|
100
219
|
agentId?: string;
|
|
@@ -105,6 +224,12 @@ interface UseChatOptions {
|
|
|
105
224
|
/** Hook for receiving every low-level AG-UI streaming event (tool calls, steps, subagents) */
|
|
106
225
|
onEvent?: (event: PersonaStreamingEvent) => void;
|
|
107
226
|
}
|
|
227
|
+
interface SendMessageOverride {
|
|
228
|
+
agentId?: string;
|
|
229
|
+
threadId?: string;
|
|
230
|
+
/** Answers/approves a paused interrupt from a previous turn instead of starting a fresh one. */
|
|
231
|
+
resume?: PersonaResumeValue;
|
|
232
|
+
}
|
|
108
233
|
|
|
109
234
|
interface PersonaContextValue {
|
|
110
235
|
baseUrl: string;
|
|
@@ -121,17 +246,22 @@ declare function useChat(options?: UseChatOptions): {
|
|
|
121
246
|
setInput: react.Dispatch<react.SetStateAction<string>>;
|
|
122
247
|
handleInputChange: (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
123
248
|
handleSubmit: (e?: React.FormEvent) => void;
|
|
124
|
-
sendMessage: (contentToSend?: string, overrideOptions?:
|
|
125
|
-
agentId?: string;
|
|
126
|
-
threadId?: string;
|
|
127
|
-
}) => Promise<void>;
|
|
249
|
+
sendMessage: (contentToSend?: string, overrideOptions?: SendMessageOverride) => Promise<void>;
|
|
128
250
|
isStreaming: boolean;
|
|
129
251
|
isLoading: boolean;
|
|
252
|
+
isLoadingHistory: boolean;
|
|
130
253
|
error: Error | null;
|
|
254
|
+
interrupt: PersonaInterrupt | null;
|
|
255
|
+
resumeInterrupt: (resume: PersonaResumeValue, displayContent: string) => Promise<void>;
|
|
256
|
+
files: Record<string, PersonaWorkspaceFile>;
|
|
257
|
+
todos: PersonaTodo[];
|
|
258
|
+
presentedFile: PersonaPresentedFile | null;
|
|
259
|
+
dismissPresentedFile: () => void;
|
|
131
260
|
stop: () => void;
|
|
132
261
|
reload: () => void;
|
|
133
262
|
clear: () => void;
|
|
134
263
|
setMessages: react.Dispatch<react.SetStateAction<PersonaMessage[]>>;
|
|
264
|
+
loadThreadMessages: (id: string) => Promise<PersonaMessage[]>;
|
|
135
265
|
};
|
|
136
266
|
|
|
137
267
|
declare function useMemory(autoFetch?: boolean): {
|
|
@@ -161,44 +291,60 @@ declare function useThreads(autoFetch?: boolean): {
|
|
|
161
291
|
threads: PersonaThread[];
|
|
162
292
|
isLoading: boolean;
|
|
163
293
|
error: Error | null;
|
|
164
|
-
refetch: () => Promise<
|
|
294
|
+
refetch: () => Promise<PersonaThread[]>;
|
|
165
295
|
createThread: (agentId?: string) => Promise<PersonaThread>;
|
|
166
296
|
deleteThread: (threadId: string) => Promise<void>;
|
|
297
|
+
bulkDeleteThreads: (threadIds: string[]) => Promise<{
|
|
298
|
+
deleted: string[];
|
|
299
|
+
failed: Array<{
|
|
300
|
+
id: string;
|
|
301
|
+
reason: string;
|
|
302
|
+
}>;
|
|
303
|
+
}>;
|
|
304
|
+
deleteAllThreads: () => Promise<void>;
|
|
305
|
+
updateThread: (threadId: string, input: {
|
|
306
|
+
title?: string;
|
|
307
|
+
isArchived?: boolean;
|
|
308
|
+
}) => Promise<PersonaThread>;
|
|
309
|
+
renameThread: (threadId: string, title: string) => Promise<PersonaThread>;
|
|
310
|
+
getThread: (threadId: string) => Promise<PersonaThread>;
|
|
167
311
|
};
|
|
168
312
|
|
|
169
|
-
interface PersonaFileItem {
|
|
170
|
-
_id: string;
|
|
171
|
-
filename: string;
|
|
172
|
-
contentType?: string;
|
|
173
|
-
sizeBytes?: number;
|
|
174
|
-
createdAt: string;
|
|
175
|
-
}
|
|
176
313
|
declare function useFiles(autoFetch?: boolean): {
|
|
177
314
|
files: PersonaFileItem[];
|
|
178
315
|
isLoading: boolean;
|
|
179
316
|
isUploading: boolean;
|
|
180
317
|
error: Error | null;
|
|
181
|
-
refetch: () => Promise<
|
|
318
|
+
refetch: () => Promise<PersonaFileItem[]>;
|
|
182
319
|
uploadFile: (fileOrFormData: FormData | {
|
|
183
320
|
name: string;
|
|
184
321
|
uri: string;
|
|
185
322
|
type?: string;
|
|
186
323
|
}) => Promise<PersonaFileItem>;
|
|
187
324
|
deleteFile: (fileId: string) => Promise<void>;
|
|
325
|
+
bulkDeleteFiles: (fileIds: string[]) => Promise<{
|
|
326
|
+
deleted: string[];
|
|
327
|
+
failed: Array<{
|
|
328
|
+
id: string;
|
|
329
|
+
reason: string;
|
|
330
|
+
}>;
|
|
331
|
+
}>;
|
|
188
332
|
getDownloadUrl: (fileId: string) => string;
|
|
189
333
|
};
|
|
190
334
|
|
|
191
335
|
interface PersonaAgentSummary {
|
|
192
336
|
_id: string;
|
|
193
337
|
name: string;
|
|
338
|
+
slug: string;
|
|
194
339
|
description?: string;
|
|
195
|
-
|
|
340
|
+
tagline?: string;
|
|
341
|
+
avatar?: string;
|
|
196
342
|
}
|
|
197
343
|
declare function useAgents(autoFetch?: boolean): {
|
|
198
344
|
agents: PersonaAgentSummary[];
|
|
199
345
|
isLoading: boolean;
|
|
200
346
|
error: Error | null;
|
|
201
|
-
refetch: () => Promise<
|
|
347
|
+
refetch: () => Promise<PersonaAgentSummary[]>;
|
|
202
348
|
};
|
|
203
349
|
|
|
204
350
|
interface PersonaHealthInfo {
|
|
@@ -213,6 +359,6 @@ declare function useConnection(autoCheck?: boolean): {
|
|
|
213
359
|
checkHealth: () => Promise<PersonaHealthInfo | null>;
|
|
214
360
|
};
|
|
215
361
|
|
|
216
|
-
declare const VERSION = "0.
|
|
362
|
+
declare const VERSION = "0.2.0";
|
|
217
363
|
|
|
218
|
-
export { type PersonaAgentSummary, type PersonaFileItem, type PersonaHealthInfo, type PersonaMemoryFile, type PersonaMemoryList, type PersonaMessage, PersonaProvider, type PersonaProviderProps, type PersonaRole, type PersonaStreamingEvent, type PersonaThread, type PersonaToolCall, type UseChatOptions, VERSION, useAgents, useChat, useConnection, useFiles, useMemory, usePersonaContext, useThreads };
|
|
364
|
+
export { type PersonaAgentSummary, type PersonaClarificationQuestion, type PersonaFileItem, type PersonaHealthInfo, type PersonaHitlActionRequest, type PersonaInterrupt, 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 SendMessageOverride, type UseChatOptions, VERSION, useAgents, useChat, useConnection, useFiles, useMemory, usePersonaContext, useThreads };
|