@personaai/react 0.1.2 → 0.2.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 +206 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +175 -52
- package/dist/index.d.ts +175 -52
- package/dist/index.js +217 -58
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
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,7 +26,40 @@ 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;
|
|
19
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
|
+
};
|
|
20
63
|
interface PersonaProviderProps {
|
|
21
64
|
/** Base URL where the Persona runtime / adapter is mounted, e.g. "http://localhost:4000/api/persona" */
|
|
22
65
|
baseUrl: string;
|
|
@@ -28,73 +71,130 @@ interface PersonaProviderProps {
|
|
|
28
71
|
}
|
|
29
72
|
interface PersonaThread {
|
|
30
73
|
_id: string;
|
|
31
|
-
|
|
74
|
+
/** A bare id string on create()/get(); populated as an object on list(). */
|
|
75
|
+
agentId: string | {
|
|
76
|
+
_id: string;
|
|
77
|
+
name: string;
|
|
78
|
+
avatar?: string;
|
|
79
|
+
slug: string;
|
|
80
|
+
};
|
|
32
81
|
title?: string;
|
|
33
82
|
isArchived?: boolean;
|
|
34
83
|
createdAt: string;
|
|
35
84
|
updatedAt: string;
|
|
36
85
|
}
|
|
86
|
+
/** Mirrors the wire shape of `GET/POST /files` — `id`, not `_id`. */
|
|
87
|
+
interface PersonaFileItem {
|
|
88
|
+
id: string;
|
|
89
|
+
originalName: string;
|
|
90
|
+
mimeType: string;
|
|
91
|
+
/** Bytes. */
|
|
92
|
+
size: number;
|
|
93
|
+
agentId: string | null;
|
|
94
|
+
threadId: string | null;
|
|
95
|
+
createdAt: string;
|
|
96
|
+
}
|
|
37
97
|
interface PersonaMemoryFile {
|
|
98
|
+
scope?: 'user' | 'agent';
|
|
99
|
+
agentId?: string;
|
|
38
100
|
path: string;
|
|
39
101
|
content: string;
|
|
102
|
+
mimeType?: string;
|
|
103
|
+
createdAt?: string;
|
|
40
104
|
updatedAt?: string;
|
|
41
105
|
}
|
|
106
|
+
/** One agent's group of agent-scoped memory files, as returned by `GET /memory`. */
|
|
107
|
+
interface PersonaMemoryAgentGroup {
|
|
108
|
+
agentId: string;
|
|
109
|
+
/** `null` if the agent no longer exists. */
|
|
110
|
+
agentName: string | null;
|
|
111
|
+
files: PersonaMemoryFile[];
|
|
112
|
+
}
|
|
42
113
|
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
|
-
}>>;
|
|
114
|
+
userFiles: PersonaMemoryFile[];
|
|
115
|
+
agentMemories: PersonaMemoryAgentGroup[];
|
|
53
116
|
}
|
|
54
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* AG-UI protocol events emitted during streaming — mirrors exactly what
|
|
119
|
+
* `aguiTranslator.js` produces server-side (verified against that file, not
|
|
120
|
+
* guessed from the AG-UI spec: this backend only emits a subset, and uses
|
|
121
|
+
* `TOOL_CALL_CHUNK` rather than separate START/ARGS events for tool calls,
|
|
122
|
+
* and `REASONING_END` rather than `REASONING_MESSAGE_END`).
|
|
123
|
+
*/
|
|
55
124
|
type PersonaStreamingEvent = {
|
|
56
125
|
type: 'TEXT_MESSAGE_CHUNK';
|
|
57
126
|
delta: string;
|
|
58
127
|
messageId?: string;
|
|
128
|
+
role?: 'assistant';
|
|
59
129
|
} | {
|
|
60
|
-
type: '
|
|
61
|
-
toolCallId
|
|
62
|
-
|
|
130
|
+
type: 'TOOL_CALL_CHUNK';
|
|
131
|
+
toolCallId?: string;
|
|
132
|
+
toolCallName?: string;
|
|
133
|
+
delta?: string;
|
|
63
134
|
parentMessageId?: string;
|
|
64
|
-
} | {
|
|
65
|
-
type: 'TOOL_CALL_ARGS';
|
|
66
|
-
toolCallId: string;
|
|
67
|
-
delta: string;
|
|
68
135
|
} | {
|
|
69
136
|
type: 'TOOL_CALL_RESULT';
|
|
70
137
|
toolCallId: string;
|
|
71
|
-
|
|
72
|
-
|
|
138
|
+
content: string;
|
|
139
|
+
messageId?: string;
|
|
140
|
+
role?: 'tool';
|
|
141
|
+
structuredContent?: unknown;
|
|
73
142
|
} | {
|
|
74
|
-
type: '
|
|
75
|
-
|
|
76
|
-
|
|
143
|
+
type: 'REASONING_MESSAGE_START';
|
|
144
|
+
messageId: string;
|
|
145
|
+
} | {
|
|
146
|
+
type: 'REASONING_MESSAGE_CONTENT';
|
|
147
|
+
messageId: string;
|
|
148
|
+
delta: string;
|
|
149
|
+
} | {
|
|
150
|
+
type: 'REASONING_END';
|
|
77
151
|
} | {
|
|
78
|
-
type: '
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
152
|
+
type: 'STATE_SNAPSHOT';
|
|
153
|
+
snapshot: {
|
|
154
|
+
files: Record<string, unknown>;
|
|
155
|
+
todos: Array<{
|
|
156
|
+
content: string;
|
|
157
|
+
status: string;
|
|
158
|
+
}>;
|
|
83
159
|
};
|
|
84
160
|
} | {
|
|
85
161
|
type: 'RUN_ERROR';
|
|
86
162
|
code: string;
|
|
87
163
|
message: string;
|
|
164
|
+
retryable?: boolean;
|
|
165
|
+
providerName?: string;
|
|
88
166
|
} | {
|
|
89
|
-
type: '
|
|
90
|
-
|
|
167
|
+
type: 'CUSTOM';
|
|
168
|
+
name: 'hitl_request';
|
|
169
|
+
value: {
|
|
170
|
+
actionRequests: PersonaHitlActionRequest[];
|
|
171
|
+
reviewConfigs: unknown[];
|
|
172
|
+
};
|
|
91
173
|
} | {
|
|
92
|
-
type: '
|
|
93
|
-
|
|
174
|
+
type: 'CUSTOM';
|
|
175
|
+
name: 'clarification_request';
|
|
176
|
+
value: {
|
|
177
|
+
questions: PersonaClarificationQuestion[];
|
|
178
|
+
currentIndex: number;
|
|
179
|
+
};
|
|
94
180
|
} | {
|
|
95
181
|
type: 'CUSTOM';
|
|
96
|
-
name:
|
|
97
|
-
|
|
182
|
+
name: 'subagent_activity';
|
|
183
|
+
value: {
|
|
184
|
+
toolCallId: string;
|
|
185
|
+
} & PersonaSubagentActivityEntry;
|
|
186
|
+
} | {
|
|
187
|
+
type: 'CUSTOM';
|
|
188
|
+
name: 'mcp_app';
|
|
189
|
+
value: {
|
|
190
|
+
toolCallId: string;
|
|
191
|
+
resourceUri: string;
|
|
192
|
+
mcpId: string;
|
|
193
|
+
};
|
|
194
|
+
} | {
|
|
195
|
+
type: 'CUSTOM';
|
|
196
|
+
name: string & {};
|
|
197
|
+
value: unknown;
|
|
98
198
|
};
|
|
99
199
|
interface UseChatOptions {
|
|
100
200
|
agentId?: string;
|
|
@@ -105,6 +205,12 @@ interface UseChatOptions {
|
|
|
105
205
|
/** Hook for receiving every low-level AG-UI streaming event (tool calls, steps, subagents) */
|
|
106
206
|
onEvent?: (event: PersonaStreamingEvent) => void;
|
|
107
207
|
}
|
|
208
|
+
interface SendMessageOverride {
|
|
209
|
+
agentId?: string;
|
|
210
|
+
threadId?: string;
|
|
211
|
+
/** Answers/approves a paused interrupt from a previous turn instead of starting a fresh one. */
|
|
212
|
+
resume?: PersonaResumeValue;
|
|
213
|
+
}
|
|
108
214
|
|
|
109
215
|
interface PersonaContextValue {
|
|
110
216
|
baseUrl: string;
|
|
@@ -121,17 +227,18 @@ declare function useChat(options?: UseChatOptions): {
|
|
|
121
227
|
setInput: react.Dispatch<react.SetStateAction<string>>;
|
|
122
228
|
handleInputChange: (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
123
229
|
handleSubmit: (e?: React.FormEvent) => void;
|
|
124
|
-
sendMessage: (contentToSend?: string, overrideOptions?:
|
|
125
|
-
agentId?: string;
|
|
126
|
-
threadId?: string;
|
|
127
|
-
}) => Promise<void>;
|
|
230
|
+
sendMessage: (contentToSend?: string, overrideOptions?: SendMessageOverride) => Promise<void>;
|
|
128
231
|
isStreaming: boolean;
|
|
129
232
|
isLoading: boolean;
|
|
233
|
+
isLoadingHistory: boolean;
|
|
130
234
|
error: Error | null;
|
|
235
|
+
interrupt: PersonaInterrupt | null;
|
|
236
|
+
resumeInterrupt: (resume: PersonaResumeValue, displayContent: string) => Promise<void>;
|
|
131
237
|
stop: () => void;
|
|
132
238
|
reload: () => void;
|
|
133
239
|
clear: () => void;
|
|
134
240
|
setMessages: react.Dispatch<react.SetStateAction<PersonaMessage[]>>;
|
|
241
|
+
loadThreadMessages: (id: string) => Promise<PersonaMessage[]>;
|
|
135
242
|
};
|
|
136
243
|
|
|
137
244
|
declare function useMemory(autoFetch?: boolean): {
|
|
@@ -161,44 +268,60 @@ declare function useThreads(autoFetch?: boolean): {
|
|
|
161
268
|
threads: PersonaThread[];
|
|
162
269
|
isLoading: boolean;
|
|
163
270
|
error: Error | null;
|
|
164
|
-
refetch: () => Promise<
|
|
271
|
+
refetch: () => Promise<PersonaThread[]>;
|
|
165
272
|
createThread: (agentId?: string) => Promise<PersonaThread>;
|
|
166
273
|
deleteThread: (threadId: string) => Promise<void>;
|
|
274
|
+
bulkDeleteThreads: (threadIds: string[]) => Promise<{
|
|
275
|
+
deleted: string[];
|
|
276
|
+
failed: Array<{
|
|
277
|
+
id: string;
|
|
278
|
+
reason: string;
|
|
279
|
+
}>;
|
|
280
|
+
}>;
|
|
281
|
+
deleteAllThreads: () => Promise<void>;
|
|
282
|
+
updateThread: (threadId: string, input: {
|
|
283
|
+
title?: string;
|
|
284
|
+
isArchived?: boolean;
|
|
285
|
+
}) => Promise<PersonaThread>;
|
|
286
|
+
renameThread: (threadId: string, title: string) => Promise<PersonaThread>;
|
|
287
|
+
getThread: (threadId: string) => Promise<PersonaThread>;
|
|
167
288
|
};
|
|
168
289
|
|
|
169
|
-
interface PersonaFileItem {
|
|
170
|
-
_id: string;
|
|
171
|
-
filename: string;
|
|
172
|
-
contentType?: string;
|
|
173
|
-
sizeBytes?: number;
|
|
174
|
-
createdAt: string;
|
|
175
|
-
}
|
|
176
290
|
declare function useFiles(autoFetch?: boolean): {
|
|
177
291
|
files: PersonaFileItem[];
|
|
178
292
|
isLoading: boolean;
|
|
179
293
|
isUploading: boolean;
|
|
180
294
|
error: Error | null;
|
|
181
|
-
refetch: () => Promise<
|
|
295
|
+
refetch: () => Promise<PersonaFileItem[]>;
|
|
182
296
|
uploadFile: (fileOrFormData: FormData | {
|
|
183
297
|
name: string;
|
|
184
298
|
uri: string;
|
|
185
299
|
type?: string;
|
|
186
300
|
}) => Promise<PersonaFileItem>;
|
|
187
301
|
deleteFile: (fileId: string) => Promise<void>;
|
|
302
|
+
bulkDeleteFiles: (fileIds: string[]) => Promise<{
|
|
303
|
+
deleted: string[];
|
|
304
|
+
failed: Array<{
|
|
305
|
+
id: string;
|
|
306
|
+
reason: string;
|
|
307
|
+
}>;
|
|
308
|
+
}>;
|
|
188
309
|
getDownloadUrl: (fileId: string) => string;
|
|
189
310
|
};
|
|
190
311
|
|
|
191
312
|
interface PersonaAgentSummary {
|
|
192
313
|
_id: string;
|
|
193
314
|
name: string;
|
|
315
|
+
slug: string;
|
|
194
316
|
description?: string;
|
|
195
|
-
|
|
317
|
+
tagline?: string;
|
|
318
|
+
avatar?: string;
|
|
196
319
|
}
|
|
197
320
|
declare function useAgents(autoFetch?: boolean): {
|
|
198
321
|
agents: PersonaAgentSummary[];
|
|
199
322
|
isLoading: boolean;
|
|
200
323
|
error: Error | null;
|
|
201
|
-
refetch: () => Promise<
|
|
324
|
+
refetch: () => Promise<PersonaAgentSummary[]>;
|
|
202
325
|
};
|
|
203
326
|
|
|
204
327
|
interface PersonaHealthInfo {
|
|
@@ -213,6 +336,6 @@ declare function useConnection(autoCheck?: boolean): {
|
|
|
213
336
|
checkHealth: () => Promise<PersonaHealthInfo | null>;
|
|
214
337
|
};
|
|
215
338
|
|
|
216
|
-
declare const VERSION = "0.
|
|
339
|
+
declare const VERSION = "0.2.0";
|
|
217
340
|
|
|
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 };
|
|
341
|
+
export { type PersonaAgentSummary, type PersonaClarificationQuestion, type PersonaFileItem, type PersonaHealthInfo, type PersonaHitlActionRequest, type PersonaInterrupt, type PersonaMemoryAgentGroup, type PersonaMemoryFile, type PersonaMemoryList, type PersonaMessage, PersonaProvider, type PersonaProviderProps, type PersonaResumeValue, type PersonaRole, type PersonaStreamingEvent, type PersonaSubagentActivityEntry, type PersonaThread, type PersonaToolCall, type SendMessageOverride, type UseChatOptions, VERSION, useAgents, useChat, useConnection, useFiles, useMemory, usePersonaContext, useThreads };
|
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,7 +26,40 @@ 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;
|
|
19
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
|
+
};
|
|
20
63
|
interface PersonaProviderProps {
|
|
21
64
|
/** Base URL where the Persona runtime / adapter is mounted, e.g. "http://localhost:4000/api/persona" */
|
|
22
65
|
baseUrl: string;
|
|
@@ -28,73 +71,130 @@ interface PersonaProviderProps {
|
|
|
28
71
|
}
|
|
29
72
|
interface PersonaThread {
|
|
30
73
|
_id: string;
|
|
31
|
-
|
|
74
|
+
/** A bare id string on create()/get(); populated as an object on list(). */
|
|
75
|
+
agentId: string | {
|
|
76
|
+
_id: string;
|
|
77
|
+
name: string;
|
|
78
|
+
avatar?: string;
|
|
79
|
+
slug: string;
|
|
80
|
+
};
|
|
32
81
|
title?: string;
|
|
33
82
|
isArchived?: boolean;
|
|
34
83
|
createdAt: string;
|
|
35
84
|
updatedAt: string;
|
|
36
85
|
}
|
|
86
|
+
/** Mirrors the wire shape of `GET/POST /files` — `id`, not `_id`. */
|
|
87
|
+
interface PersonaFileItem {
|
|
88
|
+
id: string;
|
|
89
|
+
originalName: string;
|
|
90
|
+
mimeType: string;
|
|
91
|
+
/** Bytes. */
|
|
92
|
+
size: number;
|
|
93
|
+
agentId: string | null;
|
|
94
|
+
threadId: string | null;
|
|
95
|
+
createdAt: string;
|
|
96
|
+
}
|
|
37
97
|
interface PersonaMemoryFile {
|
|
98
|
+
scope?: 'user' | 'agent';
|
|
99
|
+
agentId?: string;
|
|
38
100
|
path: string;
|
|
39
101
|
content: string;
|
|
102
|
+
mimeType?: string;
|
|
103
|
+
createdAt?: string;
|
|
40
104
|
updatedAt?: string;
|
|
41
105
|
}
|
|
106
|
+
/** One agent's group of agent-scoped memory files, as returned by `GET /memory`. */
|
|
107
|
+
interface PersonaMemoryAgentGroup {
|
|
108
|
+
agentId: string;
|
|
109
|
+
/** `null` if the agent no longer exists. */
|
|
110
|
+
agentName: string | null;
|
|
111
|
+
files: PersonaMemoryFile[];
|
|
112
|
+
}
|
|
42
113
|
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
|
-
}>>;
|
|
114
|
+
userFiles: PersonaMemoryFile[];
|
|
115
|
+
agentMemories: PersonaMemoryAgentGroup[];
|
|
53
116
|
}
|
|
54
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* AG-UI protocol events emitted during streaming — mirrors exactly what
|
|
119
|
+
* `aguiTranslator.js` produces server-side (verified against that file, not
|
|
120
|
+
* guessed from the AG-UI spec: this backend only emits a subset, and uses
|
|
121
|
+
* `TOOL_CALL_CHUNK` rather than separate START/ARGS events for tool calls,
|
|
122
|
+
* and `REASONING_END` rather than `REASONING_MESSAGE_END`).
|
|
123
|
+
*/
|
|
55
124
|
type PersonaStreamingEvent = {
|
|
56
125
|
type: 'TEXT_MESSAGE_CHUNK';
|
|
57
126
|
delta: string;
|
|
58
127
|
messageId?: string;
|
|
128
|
+
role?: 'assistant';
|
|
59
129
|
} | {
|
|
60
|
-
type: '
|
|
61
|
-
toolCallId
|
|
62
|
-
|
|
130
|
+
type: 'TOOL_CALL_CHUNK';
|
|
131
|
+
toolCallId?: string;
|
|
132
|
+
toolCallName?: string;
|
|
133
|
+
delta?: string;
|
|
63
134
|
parentMessageId?: string;
|
|
64
|
-
} | {
|
|
65
|
-
type: 'TOOL_CALL_ARGS';
|
|
66
|
-
toolCallId: string;
|
|
67
|
-
delta: string;
|
|
68
135
|
} | {
|
|
69
136
|
type: 'TOOL_CALL_RESULT';
|
|
70
137
|
toolCallId: string;
|
|
71
|
-
|
|
72
|
-
|
|
138
|
+
content: string;
|
|
139
|
+
messageId?: string;
|
|
140
|
+
role?: 'tool';
|
|
141
|
+
structuredContent?: unknown;
|
|
73
142
|
} | {
|
|
74
|
-
type: '
|
|
75
|
-
|
|
76
|
-
|
|
143
|
+
type: 'REASONING_MESSAGE_START';
|
|
144
|
+
messageId: string;
|
|
145
|
+
} | {
|
|
146
|
+
type: 'REASONING_MESSAGE_CONTENT';
|
|
147
|
+
messageId: string;
|
|
148
|
+
delta: string;
|
|
149
|
+
} | {
|
|
150
|
+
type: 'REASONING_END';
|
|
77
151
|
} | {
|
|
78
|
-
type: '
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
152
|
+
type: 'STATE_SNAPSHOT';
|
|
153
|
+
snapshot: {
|
|
154
|
+
files: Record<string, unknown>;
|
|
155
|
+
todos: Array<{
|
|
156
|
+
content: string;
|
|
157
|
+
status: string;
|
|
158
|
+
}>;
|
|
83
159
|
};
|
|
84
160
|
} | {
|
|
85
161
|
type: 'RUN_ERROR';
|
|
86
162
|
code: string;
|
|
87
163
|
message: string;
|
|
164
|
+
retryable?: boolean;
|
|
165
|
+
providerName?: string;
|
|
88
166
|
} | {
|
|
89
|
-
type: '
|
|
90
|
-
|
|
167
|
+
type: 'CUSTOM';
|
|
168
|
+
name: 'hitl_request';
|
|
169
|
+
value: {
|
|
170
|
+
actionRequests: PersonaHitlActionRequest[];
|
|
171
|
+
reviewConfigs: unknown[];
|
|
172
|
+
};
|
|
91
173
|
} | {
|
|
92
|
-
type: '
|
|
93
|
-
|
|
174
|
+
type: 'CUSTOM';
|
|
175
|
+
name: 'clarification_request';
|
|
176
|
+
value: {
|
|
177
|
+
questions: PersonaClarificationQuestion[];
|
|
178
|
+
currentIndex: number;
|
|
179
|
+
};
|
|
94
180
|
} | {
|
|
95
181
|
type: 'CUSTOM';
|
|
96
|
-
name:
|
|
97
|
-
|
|
182
|
+
name: 'subagent_activity';
|
|
183
|
+
value: {
|
|
184
|
+
toolCallId: string;
|
|
185
|
+
} & PersonaSubagentActivityEntry;
|
|
186
|
+
} | {
|
|
187
|
+
type: 'CUSTOM';
|
|
188
|
+
name: 'mcp_app';
|
|
189
|
+
value: {
|
|
190
|
+
toolCallId: string;
|
|
191
|
+
resourceUri: string;
|
|
192
|
+
mcpId: string;
|
|
193
|
+
};
|
|
194
|
+
} | {
|
|
195
|
+
type: 'CUSTOM';
|
|
196
|
+
name: string & {};
|
|
197
|
+
value: unknown;
|
|
98
198
|
};
|
|
99
199
|
interface UseChatOptions {
|
|
100
200
|
agentId?: string;
|
|
@@ -105,6 +205,12 @@ interface UseChatOptions {
|
|
|
105
205
|
/** Hook for receiving every low-level AG-UI streaming event (tool calls, steps, subagents) */
|
|
106
206
|
onEvent?: (event: PersonaStreamingEvent) => void;
|
|
107
207
|
}
|
|
208
|
+
interface SendMessageOverride {
|
|
209
|
+
agentId?: string;
|
|
210
|
+
threadId?: string;
|
|
211
|
+
/** Answers/approves a paused interrupt from a previous turn instead of starting a fresh one. */
|
|
212
|
+
resume?: PersonaResumeValue;
|
|
213
|
+
}
|
|
108
214
|
|
|
109
215
|
interface PersonaContextValue {
|
|
110
216
|
baseUrl: string;
|
|
@@ -121,17 +227,18 @@ declare function useChat(options?: UseChatOptions): {
|
|
|
121
227
|
setInput: react.Dispatch<react.SetStateAction<string>>;
|
|
122
228
|
handleInputChange: (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
123
229
|
handleSubmit: (e?: React.FormEvent) => void;
|
|
124
|
-
sendMessage: (contentToSend?: string, overrideOptions?:
|
|
125
|
-
agentId?: string;
|
|
126
|
-
threadId?: string;
|
|
127
|
-
}) => Promise<void>;
|
|
230
|
+
sendMessage: (contentToSend?: string, overrideOptions?: SendMessageOverride) => Promise<void>;
|
|
128
231
|
isStreaming: boolean;
|
|
129
232
|
isLoading: boolean;
|
|
233
|
+
isLoadingHistory: boolean;
|
|
130
234
|
error: Error | null;
|
|
235
|
+
interrupt: PersonaInterrupt | null;
|
|
236
|
+
resumeInterrupt: (resume: PersonaResumeValue, displayContent: string) => Promise<void>;
|
|
131
237
|
stop: () => void;
|
|
132
238
|
reload: () => void;
|
|
133
239
|
clear: () => void;
|
|
134
240
|
setMessages: react.Dispatch<react.SetStateAction<PersonaMessage[]>>;
|
|
241
|
+
loadThreadMessages: (id: string) => Promise<PersonaMessage[]>;
|
|
135
242
|
};
|
|
136
243
|
|
|
137
244
|
declare function useMemory(autoFetch?: boolean): {
|
|
@@ -161,44 +268,60 @@ declare function useThreads(autoFetch?: boolean): {
|
|
|
161
268
|
threads: PersonaThread[];
|
|
162
269
|
isLoading: boolean;
|
|
163
270
|
error: Error | null;
|
|
164
|
-
refetch: () => Promise<
|
|
271
|
+
refetch: () => Promise<PersonaThread[]>;
|
|
165
272
|
createThread: (agentId?: string) => Promise<PersonaThread>;
|
|
166
273
|
deleteThread: (threadId: string) => Promise<void>;
|
|
274
|
+
bulkDeleteThreads: (threadIds: string[]) => Promise<{
|
|
275
|
+
deleted: string[];
|
|
276
|
+
failed: Array<{
|
|
277
|
+
id: string;
|
|
278
|
+
reason: string;
|
|
279
|
+
}>;
|
|
280
|
+
}>;
|
|
281
|
+
deleteAllThreads: () => Promise<void>;
|
|
282
|
+
updateThread: (threadId: string, input: {
|
|
283
|
+
title?: string;
|
|
284
|
+
isArchived?: boolean;
|
|
285
|
+
}) => Promise<PersonaThread>;
|
|
286
|
+
renameThread: (threadId: string, title: string) => Promise<PersonaThread>;
|
|
287
|
+
getThread: (threadId: string) => Promise<PersonaThread>;
|
|
167
288
|
};
|
|
168
289
|
|
|
169
|
-
interface PersonaFileItem {
|
|
170
|
-
_id: string;
|
|
171
|
-
filename: string;
|
|
172
|
-
contentType?: string;
|
|
173
|
-
sizeBytes?: number;
|
|
174
|
-
createdAt: string;
|
|
175
|
-
}
|
|
176
290
|
declare function useFiles(autoFetch?: boolean): {
|
|
177
291
|
files: PersonaFileItem[];
|
|
178
292
|
isLoading: boolean;
|
|
179
293
|
isUploading: boolean;
|
|
180
294
|
error: Error | null;
|
|
181
|
-
refetch: () => Promise<
|
|
295
|
+
refetch: () => Promise<PersonaFileItem[]>;
|
|
182
296
|
uploadFile: (fileOrFormData: FormData | {
|
|
183
297
|
name: string;
|
|
184
298
|
uri: string;
|
|
185
299
|
type?: string;
|
|
186
300
|
}) => Promise<PersonaFileItem>;
|
|
187
301
|
deleteFile: (fileId: string) => Promise<void>;
|
|
302
|
+
bulkDeleteFiles: (fileIds: string[]) => Promise<{
|
|
303
|
+
deleted: string[];
|
|
304
|
+
failed: Array<{
|
|
305
|
+
id: string;
|
|
306
|
+
reason: string;
|
|
307
|
+
}>;
|
|
308
|
+
}>;
|
|
188
309
|
getDownloadUrl: (fileId: string) => string;
|
|
189
310
|
};
|
|
190
311
|
|
|
191
312
|
interface PersonaAgentSummary {
|
|
192
313
|
_id: string;
|
|
193
314
|
name: string;
|
|
315
|
+
slug: string;
|
|
194
316
|
description?: string;
|
|
195
|
-
|
|
317
|
+
tagline?: string;
|
|
318
|
+
avatar?: string;
|
|
196
319
|
}
|
|
197
320
|
declare function useAgents(autoFetch?: boolean): {
|
|
198
321
|
agents: PersonaAgentSummary[];
|
|
199
322
|
isLoading: boolean;
|
|
200
323
|
error: Error | null;
|
|
201
|
-
refetch: () => Promise<
|
|
324
|
+
refetch: () => Promise<PersonaAgentSummary[]>;
|
|
202
325
|
};
|
|
203
326
|
|
|
204
327
|
interface PersonaHealthInfo {
|
|
@@ -213,6 +336,6 @@ declare function useConnection(autoCheck?: boolean): {
|
|
|
213
336
|
checkHealth: () => Promise<PersonaHealthInfo | null>;
|
|
214
337
|
};
|
|
215
338
|
|
|
216
|
-
declare const VERSION = "0.
|
|
339
|
+
declare const VERSION = "0.2.0";
|
|
217
340
|
|
|
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 };
|
|
341
|
+
export { type PersonaAgentSummary, type PersonaClarificationQuestion, type PersonaFileItem, type PersonaHealthInfo, type PersonaHitlActionRequest, type PersonaInterrupt, type PersonaMemoryAgentGroup, type PersonaMemoryFile, type PersonaMemoryList, type PersonaMessage, PersonaProvider, type PersonaProviderProps, type PersonaResumeValue, type PersonaRole, type PersonaStreamingEvent, type PersonaSubagentActivityEntry, type PersonaThread, type PersonaToolCall, type SendMessageOverride, type UseChatOptions, VERSION, useAgents, useChat, useConnection, useFiles, useMemory, usePersonaContext, useThreads };
|