@invergent/agent-chat-react 1.4.3
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/LICENSE.AGPL-3.0 +661 -0
- package/README.md +6 -0
- package/dist/artifact-chart-7J6GOR4M.js +88 -0
- package/dist/artifact-chart-7J6GOR4M.js.map +1 -0
- package/dist/index.cjs +6929 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +287 -0
- package/dist/index.d.ts +287 -0
- package/dist/index.js +6821 -0
- package/dist/index.js.map +1 -0
- package/package.json +93 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
|
|
4
|
+
type AgentChatRole = "user" | "assistant" | "system";
|
|
5
|
+
type AgentChatMessageStatus = "complete" | "streaming" | "error";
|
|
6
|
+
type AgentChatSystemKind = "skill_invoked" | "artifact" | "error";
|
|
7
|
+
interface AgentChatMessage {
|
|
8
|
+
id: string;
|
|
9
|
+
role: AgentChatRole;
|
|
10
|
+
content: string;
|
|
11
|
+
createdAt: Date;
|
|
12
|
+
status: AgentChatMessageStatus;
|
|
13
|
+
toolCalls?: AgentChatToolCallInfo[];
|
|
14
|
+
reasoning?: string;
|
|
15
|
+
systemKind?: AgentChatSystemKind;
|
|
16
|
+
systemMeta?: Record<string, unknown>;
|
|
17
|
+
errorInfo?: AgentChatErrorInfo;
|
|
18
|
+
}
|
|
19
|
+
interface AgentChatToolCallInfo {
|
|
20
|
+
id: string;
|
|
21
|
+
toolName: string;
|
|
22
|
+
args: string;
|
|
23
|
+
result?: string;
|
|
24
|
+
status: "running" | "complete" | "error";
|
|
25
|
+
checkpointHash?: string;
|
|
26
|
+
expertResultEventId?: number;
|
|
27
|
+
expertFeedback?: {
|
|
28
|
+
rating: "up" | "down";
|
|
29
|
+
reason?: string;
|
|
30
|
+
};
|
|
31
|
+
clarifyAnswers?: AgentChatClarifyAnswer[];
|
|
32
|
+
cancelled?: boolean;
|
|
33
|
+
}
|
|
34
|
+
interface AgentChatTokenUsage {
|
|
35
|
+
inputTokens: number;
|
|
36
|
+
outputTokens: number;
|
|
37
|
+
reasoningTokens: number;
|
|
38
|
+
cachedInputTokens: number;
|
|
39
|
+
totalTokens: number;
|
|
40
|
+
contextWindow: number;
|
|
41
|
+
model: string;
|
|
42
|
+
}
|
|
43
|
+
interface AgentChatRetryIndicator {
|
|
44
|
+
title: string;
|
|
45
|
+
detail: string;
|
|
46
|
+
attempt: number;
|
|
47
|
+
}
|
|
48
|
+
type AgentChatErrorCategory = "provider_error" | "rate_limit" | "auth_failed" | "context_overflow" | "network" | "timeout" | "invalid_response" | "tool_error" | "storage_error" | "database_error" | "governance_denied" | "unknown";
|
|
49
|
+
interface AgentChatErrorInfo {
|
|
50
|
+
category: AgentChatErrorCategory;
|
|
51
|
+
title: string;
|
|
52
|
+
detail: string;
|
|
53
|
+
retryable: boolean;
|
|
54
|
+
}
|
|
55
|
+
interface AgentChatSession {
|
|
56
|
+
id: string;
|
|
57
|
+
userId?: string | null;
|
|
58
|
+
orgId?: string | null;
|
|
59
|
+
agentId?: string | null;
|
|
60
|
+
channel?: string | null;
|
|
61
|
+
status: "active" | "paused" | "completed" | "failed" | string;
|
|
62
|
+
title?: string | null;
|
|
63
|
+
model?: string | null;
|
|
64
|
+
config?: Record<string, unknown>;
|
|
65
|
+
parentId?: string | null;
|
|
66
|
+
messageCount?: number;
|
|
67
|
+
toolCallCount?: number;
|
|
68
|
+
inputTokens?: number;
|
|
69
|
+
outputTokens?: number;
|
|
70
|
+
estimatedCostUsd?: number | string;
|
|
71
|
+
createdAt?: string;
|
|
72
|
+
updatedAt?: string;
|
|
73
|
+
}
|
|
74
|
+
interface AgentChatSessionList {
|
|
75
|
+
sessions: AgentChatSession[];
|
|
76
|
+
total: number;
|
|
77
|
+
}
|
|
78
|
+
type AgentChatEventType = "user.message" | "llm.request" | "llm.response" | "llm.thinking" | "llm.delta" | "tool.call" | "tool.result" | "session.start" | "session.pause" | "session.resume" | "session.complete" | "session.fail" | "session.done" | "harness.wake" | "harness.crash" | "context.compact" | "skill.invoked" | "policy.denied" | "stream.timeout" | "expert.result" | "expert.endorse" | "expert.override" | "artifact.created" | "artifact.updated" | "clarify.response";
|
|
79
|
+
interface AgentChatRuntimeEvent {
|
|
80
|
+
type: AgentChatEventType;
|
|
81
|
+
eventId: number;
|
|
82
|
+
data: Record<string, unknown>;
|
|
83
|
+
}
|
|
84
|
+
interface AgentChatState {
|
|
85
|
+
messages: AgentChatMessage[];
|
|
86
|
+
isRunning: boolean;
|
|
87
|
+
tokenUsage: AgentChatTokenUsage;
|
|
88
|
+
retryIndicator: AgentChatRetryIndicator | null;
|
|
89
|
+
lastEventId: number;
|
|
90
|
+
sessionDone: boolean;
|
|
91
|
+
hadDeltas: boolean;
|
|
92
|
+
terminal: boolean;
|
|
93
|
+
}
|
|
94
|
+
type AgentChatArtifactKind = "markdown" | "table" | "chart" | "html" | "svg";
|
|
95
|
+
interface AgentChatArtifactMeta {
|
|
96
|
+
artifact_id: string;
|
|
97
|
+
session_id: string;
|
|
98
|
+
name: string;
|
|
99
|
+
kind: AgentChatArtifactKind;
|
|
100
|
+
version: number;
|
|
101
|
+
size: number;
|
|
102
|
+
created_at: string;
|
|
103
|
+
}
|
|
104
|
+
interface AgentChatMarkdownArtifactSpec {
|
|
105
|
+
content: string;
|
|
106
|
+
}
|
|
107
|
+
interface AgentChatTableArtifactSpec {
|
|
108
|
+
columns: string[];
|
|
109
|
+
rows: Array<Record<string, unknown>>;
|
|
110
|
+
caption?: string | null;
|
|
111
|
+
}
|
|
112
|
+
interface AgentChatChartArtifactSpec {
|
|
113
|
+
vega_lite: Record<string, unknown>;
|
|
114
|
+
caption?: string | null;
|
|
115
|
+
}
|
|
116
|
+
interface AgentChatHtmlArtifactSpec {
|
|
117
|
+
html: string;
|
|
118
|
+
caption?: string | null;
|
|
119
|
+
}
|
|
120
|
+
interface AgentChatSvgArtifactSpec {
|
|
121
|
+
svg: string;
|
|
122
|
+
caption?: string | null;
|
|
123
|
+
}
|
|
124
|
+
type AgentChatArtifactPayload = {
|
|
125
|
+
meta: AgentChatArtifactMeta;
|
|
126
|
+
kind: "markdown";
|
|
127
|
+
spec: AgentChatMarkdownArtifactSpec;
|
|
128
|
+
} | {
|
|
129
|
+
meta: AgentChatArtifactMeta;
|
|
130
|
+
kind: "table";
|
|
131
|
+
spec: AgentChatTableArtifactSpec;
|
|
132
|
+
} | {
|
|
133
|
+
meta: AgentChatArtifactMeta;
|
|
134
|
+
kind: "chart";
|
|
135
|
+
spec: AgentChatChartArtifactSpec;
|
|
136
|
+
} | {
|
|
137
|
+
meta: AgentChatArtifactMeta;
|
|
138
|
+
kind: "html";
|
|
139
|
+
spec: AgentChatHtmlArtifactSpec;
|
|
140
|
+
} | {
|
|
141
|
+
meta: AgentChatArtifactMeta;
|
|
142
|
+
kind: "svg";
|
|
143
|
+
spec: AgentChatSvgArtifactSpec;
|
|
144
|
+
};
|
|
145
|
+
interface AgentChatClarifyChoice {
|
|
146
|
+
label: string;
|
|
147
|
+
description?: string;
|
|
148
|
+
}
|
|
149
|
+
interface AgentChatClarifyQuestion {
|
|
150
|
+
prompt: string;
|
|
151
|
+
choices?: AgentChatClarifyChoice[];
|
|
152
|
+
allow_other?: boolean;
|
|
153
|
+
}
|
|
154
|
+
interface AgentChatClarifyArgs {
|
|
155
|
+
questions: AgentChatClarifyQuestion[];
|
|
156
|
+
}
|
|
157
|
+
interface AgentChatClarifyAnswer {
|
|
158
|
+
question: string;
|
|
159
|
+
answer: string;
|
|
160
|
+
is_other: boolean;
|
|
161
|
+
}
|
|
162
|
+
interface AgentChatSlashCommand {
|
|
163
|
+
value: string;
|
|
164
|
+
label: string;
|
|
165
|
+
description: string;
|
|
166
|
+
}
|
|
167
|
+
type AgentChatExpertFeedbackRating = "up" | "down";
|
|
168
|
+
interface AgentChatSseMessageEvent {
|
|
169
|
+
data: string;
|
|
170
|
+
lastEventId: string;
|
|
171
|
+
}
|
|
172
|
+
interface AgentChatEventStream {
|
|
173
|
+
addEventListener(type: AgentChatEventType, listener: (event: AgentChatSseMessageEvent) => void): void;
|
|
174
|
+
close(): void;
|
|
175
|
+
onerror: (() => void) | null;
|
|
176
|
+
}
|
|
177
|
+
interface AgentChatAdapter {
|
|
178
|
+
listSessions(input: {
|
|
179
|
+
agentId?: string;
|
|
180
|
+
limit?: number;
|
|
181
|
+
offset?: number;
|
|
182
|
+
}): Promise<AgentChatSessionList>;
|
|
183
|
+
createSession(input: {
|
|
184
|
+
agentId?: string;
|
|
185
|
+
system?: string;
|
|
186
|
+
}): Promise<AgentChatSession>;
|
|
187
|
+
getSession(input: {
|
|
188
|
+
sessionId: string;
|
|
189
|
+
}): Promise<AgentChatSession>;
|
|
190
|
+
sendMessage(input: {
|
|
191
|
+
sessionId: string;
|
|
192
|
+
content: string;
|
|
193
|
+
}): Promise<{
|
|
194
|
+
eventId?: number;
|
|
195
|
+
status?: string;
|
|
196
|
+
}>;
|
|
197
|
+
pauseSession(input: {
|
|
198
|
+
sessionId: string;
|
|
199
|
+
}): Promise<void>;
|
|
200
|
+
retrySession(input: {
|
|
201
|
+
sessionId: string;
|
|
202
|
+
}): Promise<AgentChatSession>;
|
|
203
|
+
deleteSession?(input: {
|
|
204
|
+
sessionId: string;
|
|
205
|
+
}): Promise<void>;
|
|
206
|
+
getArtifact(input: {
|
|
207
|
+
sessionId: string;
|
|
208
|
+
artifactId: string;
|
|
209
|
+
}): Promise<AgentChatArtifactPayload>;
|
|
210
|
+
submitClarifyResponse(input: {
|
|
211
|
+
sessionId: string;
|
|
212
|
+
toolCallId: string;
|
|
213
|
+
responses: AgentChatClarifyAnswer[];
|
|
214
|
+
}): Promise<{
|
|
215
|
+
eventId?: number;
|
|
216
|
+
}>;
|
|
217
|
+
submitExpertFeedback?(input: {
|
|
218
|
+
sessionId: string;
|
|
219
|
+
expertResultEventId: number;
|
|
220
|
+
rating: AgentChatExpertFeedbackRating;
|
|
221
|
+
reason?: string;
|
|
222
|
+
}): Promise<{
|
|
223
|
+
eventId?: number;
|
|
224
|
+
eventType?: string;
|
|
225
|
+
}>;
|
|
226
|
+
listSlashCommands?(): Promise<AgentChatSlashCommand[]>;
|
|
227
|
+
openEventStream(input: {
|
|
228
|
+
sessionId: string;
|
|
229
|
+
after: number;
|
|
230
|
+
}): AgentChatEventStream;
|
|
231
|
+
}
|
|
232
|
+
interface AgentChatRuntimeApi {
|
|
233
|
+
messages: AgentChatMessage[];
|
|
234
|
+
isRunning: boolean;
|
|
235
|
+
tokenUsage: AgentChatTokenUsage;
|
|
236
|
+
retryIndicator: AgentChatRetryIndicator | null;
|
|
237
|
+
send(content: string): Promise<void>;
|
|
238
|
+
stop(): Promise<void>;
|
|
239
|
+
retry(): Promise<void>;
|
|
240
|
+
markSending(content: string): void;
|
|
241
|
+
markSendError(errorText: string): void;
|
|
242
|
+
}
|
|
243
|
+
type ChatMessage = AgentChatMessage;
|
|
244
|
+
type ToolCallInfo = AgentChatToolCallInfo;
|
|
245
|
+
type TokenUsage = AgentChatTokenUsage;
|
|
246
|
+
type RetryIndicator = AgentChatRetryIndicator;
|
|
247
|
+
type ErrorInfo = AgentChatErrorInfo;
|
|
248
|
+
type ArtifactKind = AgentChatArtifactKind;
|
|
249
|
+
type ArtifactPayload = AgentChatArtifactPayload;
|
|
250
|
+
type MarkdownArtifactSpec = AgentChatMarkdownArtifactSpec;
|
|
251
|
+
type TableArtifactSpec = AgentChatTableArtifactSpec;
|
|
252
|
+
type ChartArtifactSpec = AgentChatChartArtifactSpec;
|
|
253
|
+
type HtmlArtifactSpec = AgentChatHtmlArtifactSpec;
|
|
254
|
+
type SvgArtifactSpec = AgentChatSvgArtifactSpec;
|
|
255
|
+
type ClarifyChoice = AgentChatClarifyChoice;
|
|
256
|
+
type ClarifyQuestion = AgentChatClarifyQuestion;
|
|
257
|
+
type ClarifyArgs = AgentChatClarifyArgs;
|
|
258
|
+
type ClarifyAnswer = AgentChatClarifyAnswer;
|
|
259
|
+
|
|
260
|
+
interface AgentChatProps {
|
|
261
|
+
adapter: AgentChatAdapter;
|
|
262
|
+
agentId?: string;
|
|
263
|
+
sessionId: string | null;
|
|
264
|
+
onSessionChange?: (sessionId: string) => void;
|
|
265
|
+
onFileSelect?: (path: string) => void;
|
|
266
|
+
onMessagesChange?: (messages: AgentChatMessage[]) => void;
|
|
267
|
+
disabled?: boolean;
|
|
268
|
+
}
|
|
269
|
+
declare function AgentChat({ adapter, agentId, sessionId, onSessionChange, onFileSelect, onMessagesChange, disabled, }: AgentChatProps): react_jsx_runtime.JSX.Element;
|
|
270
|
+
|
|
271
|
+
interface AgentChatAdapterContextValue {
|
|
272
|
+
adapter: AgentChatAdapter;
|
|
273
|
+
sessionId: string | null;
|
|
274
|
+
onFileSelect?: (path: string) => void;
|
|
275
|
+
}
|
|
276
|
+
declare const AgentChatAdapterProvider: react.Provider<AgentChatAdapterContextValue | null>;
|
|
277
|
+
declare function useAgentChatAdapterContext(): AgentChatAdapterContextValue;
|
|
278
|
+
|
|
279
|
+
interface UseAgentChatRuntimeInput {
|
|
280
|
+
adapter: AgentChatAdapter;
|
|
281
|
+
agentId?: string;
|
|
282
|
+
sessionId: string | null;
|
|
283
|
+
onSessionChange?: (sessionId: string) => void;
|
|
284
|
+
}
|
|
285
|
+
declare function useAgentChatRuntime({ adapter, agentId, sessionId, onSessionChange, }: UseAgentChatRuntimeInput): AgentChatRuntimeApi;
|
|
286
|
+
|
|
287
|
+
export { AgentChat, type AgentChatAdapter, type AgentChatAdapterContextValue, AgentChatAdapterProvider, type AgentChatArtifactKind, type AgentChatArtifactMeta, type AgentChatArtifactPayload, type AgentChatChartArtifactSpec, type AgentChatClarifyAnswer, type AgentChatClarifyArgs, type AgentChatClarifyChoice, type AgentChatClarifyQuestion, type AgentChatErrorCategory, type AgentChatErrorInfo, type AgentChatEventStream, type AgentChatEventType, type AgentChatExpertFeedbackRating, type AgentChatHtmlArtifactSpec, type AgentChatMarkdownArtifactSpec, type AgentChatMessage, type AgentChatMessageStatus, type AgentChatProps, type AgentChatRole, type AgentChatRuntimeApi, type AgentChatRuntimeEvent, type AgentChatSession, type AgentChatSessionList, type AgentChatSlashCommand, type AgentChatSseMessageEvent, type AgentChatState, type AgentChatSvgArtifactSpec, type AgentChatSystemKind, type AgentChatTableArtifactSpec, type AgentChatTokenUsage, type AgentChatToolCallInfo, type ArtifactKind, type ArtifactPayload, type ChartArtifactSpec, type ChatMessage, type ClarifyAnswer, type ClarifyArgs, type ClarifyChoice, type ClarifyQuestion, type ErrorInfo, type HtmlArtifactSpec, type MarkdownArtifactSpec, type RetryIndicator, type SvgArtifactSpec, type TableArtifactSpec, type TokenUsage, type ToolCallInfo, useAgentChatAdapterContext, useAgentChatRuntime };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
|
|
4
|
+
type AgentChatRole = "user" | "assistant" | "system";
|
|
5
|
+
type AgentChatMessageStatus = "complete" | "streaming" | "error";
|
|
6
|
+
type AgentChatSystemKind = "skill_invoked" | "artifact" | "error";
|
|
7
|
+
interface AgentChatMessage {
|
|
8
|
+
id: string;
|
|
9
|
+
role: AgentChatRole;
|
|
10
|
+
content: string;
|
|
11
|
+
createdAt: Date;
|
|
12
|
+
status: AgentChatMessageStatus;
|
|
13
|
+
toolCalls?: AgentChatToolCallInfo[];
|
|
14
|
+
reasoning?: string;
|
|
15
|
+
systemKind?: AgentChatSystemKind;
|
|
16
|
+
systemMeta?: Record<string, unknown>;
|
|
17
|
+
errorInfo?: AgentChatErrorInfo;
|
|
18
|
+
}
|
|
19
|
+
interface AgentChatToolCallInfo {
|
|
20
|
+
id: string;
|
|
21
|
+
toolName: string;
|
|
22
|
+
args: string;
|
|
23
|
+
result?: string;
|
|
24
|
+
status: "running" | "complete" | "error";
|
|
25
|
+
checkpointHash?: string;
|
|
26
|
+
expertResultEventId?: number;
|
|
27
|
+
expertFeedback?: {
|
|
28
|
+
rating: "up" | "down";
|
|
29
|
+
reason?: string;
|
|
30
|
+
};
|
|
31
|
+
clarifyAnswers?: AgentChatClarifyAnswer[];
|
|
32
|
+
cancelled?: boolean;
|
|
33
|
+
}
|
|
34
|
+
interface AgentChatTokenUsage {
|
|
35
|
+
inputTokens: number;
|
|
36
|
+
outputTokens: number;
|
|
37
|
+
reasoningTokens: number;
|
|
38
|
+
cachedInputTokens: number;
|
|
39
|
+
totalTokens: number;
|
|
40
|
+
contextWindow: number;
|
|
41
|
+
model: string;
|
|
42
|
+
}
|
|
43
|
+
interface AgentChatRetryIndicator {
|
|
44
|
+
title: string;
|
|
45
|
+
detail: string;
|
|
46
|
+
attempt: number;
|
|
47
|
+
}
|
|
48
|
+
type AgentChatErrorCategory = "provider_error" | "rate_limit" | "auth_failed" | "context_overflow" | "network" | "timeout" | "invalid_response" | "tool_error" | "storage_error" | "database_error" | "governance_denied" | "unknown";
|
|
49
|
+
interface AgentChatErrorInfo {
|
|
50
|
+
category: AgentChatErrorCategory;
|
|
51
|
+
title: string;
|
|
52
|
+
detail: string;
|
|
53
|
+
retryable: boolean;
|
|
54
|
+
}
|
|
55
|
+
interface AgentChatSession {
|
|
56
|
+
id: string;
|
|
57
|
+
userId?: string | null;
|
|
58
|
+
orgId?: string | null;
|
|
59
|
+
agentId?: string | null;
|
|
60
|
+
channel?: string | null;
|
|
61
|
+
status: "active" | "paused" | "completed" | "failed" | string;
|
|
62
|
+
title?: string | null;
|
|
63
|
+
model?: string | null;
|
|
64
|
+
config?: Record<string, unknown>;
|
|
65
|
+
parentId?: string | null;
|
|
66
|
+
messageCount?: number;
|
|
67
|
+
toolCallCount?: number;
|
|
68
|
+
inputTokens?: number;
|
|
69
|
+
outputTokens?: number;
|
|
70
|
+
estimatedCostUsd?: number | string;
|
|
71
|
+
createdAt?: string;
|
|
72
|
+
updatedAt?: string;
|
|
73
|
+
}
|
|
74
|
+
interface AgentChatSessionList {
|
|
75
|
+
sessions: AgentChatSession[];
|
|
76
|
+
total: number;
|
|
77
|
+
}
|
|
78
|
+
type AgentChatEventType = "user.message" | "llm.request" | "llm.response" | "llm.thinking" | "llm.delta" | "tool.call" | "tool.result" | "session.start" | "session.pause" | "session.resume" | "session.complete" | "session.fail" | "session.done" | "harness.wake" | "harness.crash" | "context.compact" | "skill.invoked" | "policy.denied" | "stream.timeout" | "expert.result" | "expert.endorse" | "expert.override" | "artifact.created" | "artifact.updated" | "clarify.response";
|
|
79
|
+
interface AgentChatRuntimeEvent {
|
|
80
|
+
type: AgentChatEventType;
|
|
81
|
+
eventId: number;
|
|
82
|
+
data: Record<string, unknown>;
|
|
83
|
+
}
|
|
84
|
+
interface AgentChatState {
|
|
85
|
+
messages: AgentChatMessage[];
|
|
86
|
+
isRunning: boolean;
|
|
87
|
+
tokenUsage: AgentChatTokenUsage;
|
|
88
|
+
retryIndicator: AgentChatRetryIndicator | null;
|
|
89
|
+
lastEventId: number;
|
|
90
|
+
sessionDone: boolean;
|
|
91
|
+
hadDeltas: boolean;
|
|
92
|
+
terminal: boolean;
|
|
93
|
+
}
|
|
94
|
+
type AgentChatArtifactKind = "markdown" | "table" | "chart" | "html" | "svg";
|
|
95
|
+
interface AgentChatArtifactMeta {
|
|
96
|
+
artifact_id: string;
|
|
97
|
+
session_id: string;
|
|
98
|
+
name: string;
|
|
99
|
+
kind: AgentChatArtifactKind;
|
|
100
|
+
version: number;
|
|
101
|
+
size: number;
|
|
102
|
+
created_at: string;
|
|
103
|
+
}
|
|
104
|
+
interface AgentChatMarkdownArtifactSpec {
|
|
105
|
+
content: string;
|
|
106
|
+
}
|
|
107
|
+
interface AgentChatTableArtifactSpec {
|
|
108
|
+
columns: string[];
|
|
109
|
+
rows: Array<Record<string, unknown>>;
|
|
110
|
+
caption?: string | null;
|
|
111
|
+
}
|
|
112
|
+
interface AgentChatChartArtifactSpec {
|
|
113
|
+
vega_lite: Record<string, unknown>;
|
|
114
|
+
caption?: string | null;
|
|
115
|
+
}
|
|
116
|
+
interface AgentChatHtmlArtifactSpec {
|
|
117
|
+
html: string;
|
|
118
|
+
caption?: string | null;
|
|
119
|
+
}
|
|
120
|
+
interface AgentChatSvgArtifactSpec {
|
|
121
|
+
svg: string;
|
|
122
|
+
caption?: string | null;
|
|
123
|
+
}
|
|
124
|
+
type AgentChatArtifactPayload = {
|
|
125
|
+
meta: AgentChatArtifactMeta;
|
|
126
|
+
kind: "markdown";
|
|
127
|
+
spec: AgentChatMarkdownArtifactSpec;
|
|
128
|
+
} | {
|
|
129
|
+
meta: AgentChatArtifactMeta;
|
|
130
|
+
kind: "table";
|
|
131
|
+
spec: AgentChatTableArtifactSpec;
|
|
132
|
+
} | {
|
|
133
|
+
meta: AgentChatArtifactMeta;
|
|
134
|
+
kind: "chart";
|
|
135
|
+
spec: AgentChatChartArtifactSpec;
|
|
136
|
+
} | {
|
|
137
|
+
meta: AgentChatArtifactMeta;
|
|
138
|
+
kind: "html";
|
|
139
|
+
spec: AgentChatHtmlArtifactSpec;
|
|
140
|
+
} | {
|
|
141
|
+
meta: AgentChatArtifactMeta;
|
|
142
|
+
kind: "svg";
|
|
143
|
+
spec: AgentChatSvgArtifactSpec;
|
|
144
|
+
};
|
|
145
|
+
interface AgentChatClarifyChoice {
|
|
146
|
+
label: string;
|
|
147
|
+
description?: string;
|
|
148
|
+
}
|
|
149
|
+
interface AgentChatClarifyQuestion {
|
|
150
|
+
prompt: string;
|
|
151
|
+
choices?: AgentChatClarifyChoice[];
|
|
152
|
+
allow_other?: boolean;
|
|
153
|
+
}
|
|
154
|
+
interface AgentChatClarifyArgs {
|
|
155
|
+
questions: AgentChatClarifyQuestion[];
|
|
156
|
+
}
|
|
157
|
+
interface AgentChatClarifyAnswer {
|
|
158
|
+
question: string;
|
|
159
|
+
answer: string;
|
|
160
|
+
is_other: boolean;
|
|
161
|
+
}
|
|
162
|
+
interface AgentChatSlashCommand {
|
|
163
|
+
value: string;
|
|
164
|
+
label: string;
|
|
165
|
+
description: string;
|
|
166
|
+
}
|
|
167
|
+
type AgentChatExpertFeedbackRating = "up" | "down";
|
|
168
|
+
interface AgentChatSseMessageEvent {
|
|
169
|
+
data: string;
|
|
170
|
+
lastEventId: string;
|
|
171
|
+
}
|
|
172
|
+
interface AgentChatEventStream {
|
|
173
|
+
addEventListener(type: AgentChatEventType, listener: (event: AgentChatSseMessageEvent) => void): void;
|
|
174
|
+
close(): void;
|
|
175
|
+
onerror: (() => void) | null;
|
|
176
|
+
}
|
|
177
|
+
interface AgentChatAdapter {
|
|
178
|
+
listSessions(input: {
|
|
179
|
+
agentId?: string;
|
|
180
|
+
limit?: number;
|
|
181
|
+
offset?: number;
|
|
182
|
+
}): Promise<AgentChatSessionList>;
|
|
183
|
+
createSession(input: {
|
|
184
|
+
agentId?: string;
|
|
185
|
+
system?: string;
|
|
186
|
+
}): Promise<AgentChatSession>;
|
|
187
|
+
getSession(input: {
|
|
188
|
+
sessionId: string;
|
|
189
|
+
}): Promise<AgentChatSession>;
|
|
190
|
+
sendMessage(input: {
|
|
191
|
+
sessionId: string;
|
|
192
|
+
content: string;
|
|
193
|
+
}): Promise<{
|
|
194
|
+
eventId?: number;
|
|
195
|
+
status?: string;
|
|
196
|
+
}>;
|
|
197
|
+
pauseSession(input: {
|
|
198
|
+
sessionId: string;
|
|
199
|
+
}): Promise<void>;
|
|
200
|
+
retrySession(input: {
|
|
201
|
+
sessionId: string;
|
|
202
|
+
}): Promise<AgentChatSession>;
|
|
203
|
+
deleteSession?(input: {
|
|
204
|
+
sessionId: string;
|
|
205
|
+
}): Promise<void>;
|
|
206
|
+
getArtifact(input: {
|
|
207
|
+
sessionId: string;
|
|
208
|
+
artifactId: string;
|
|
209
|
+
}): Promise<AgentChatArtifactPayload>;
|
|
210
|
+
submitClarifyResponse(input: {
|
|
211
|
+
sessionId: string;
|
|
212
|
+
toolCallId: string;
|
|
213
|
+
responses: AgentChatClarifyAnswer[];
|
|
214
|
+
}): Promise<{
|
|
215
|
+
eventId?: number;
|
|
216
|
+
}>;
|
|
217
|
+
submitExpertFeedback?(input: {
|
|
218
|
+
sessionId: string;
|
|
219
|
+
expertResultEventId: number;
|
|
220
|
+
rating: AgentChatExpertFeedbackRating;
|
|
221
|
+
reason?: string;
|
|
222
|
+
}): Promise<{
|
|
223
|
+
eventId?: number;
|
|
224
|
+
eventType?: string;
|
|
225
|
+
}>;
|
|
226
|
+
listSlashCommands?(): Promise<AgentChatSlashCommand[]>;
|
|
227
|
+
openEventStream(input: {
|
|
228
|
+
sessionId: string;
|
|
229
|
+
after: number;
|
|
230
|
+
}): AgentChatEventStream;
|
|
231
|
+
}
|
|
232
|
+
interface AgentChatRuntimeApi {
|
|
233
|
+
messages: AgentChatMessage[];
|
|
234
|
+
isRunning: boolean;
|
|
235
|
+
tokenUsage: AgentChatTokenUsage;
|
|
236
|
+
retryIndicator: AgentChatRetryIndicator | null;
|
|
237
|
+
send(content: string): Promise<void>;
|
|
238
|
+
stop(): Promise<void>;
|
|
239
|
+
retry(): Promise<void>;
|
|
240
|
+
markSending(content: string): void;
|
|
241
|
+
markSendError(errorText: string): void;
|
|
242
|
+
}
|
|
243
|
+
type ChatMessage = AgentChatMessage;
|
|
244
|
+
type ToolCallInfo = AgentChatToolCallInfo;
|
|
245
|
+
type TokenUsage = AgentChatTokenUsage;
|
|
246
|
+
type RetryIndicator = AgentChatRetryIndicator;
|
|
247
|
+
type ErrorInfo = AgentChatErrorInfo;
|
|
248
|
+
type ArtifactKind = AgentChatArtifactKind;
|
|
249
|
+
type ArtifactPayload = AgentChatArtifactPayload;
|
|
250
|
+
type MarkdownArtifactSpec = AgentChatMarkdownArtifactSpec;
|
|
251
|
+
type TableArtifactSpec = AgentChatTableArtifactSpec;
|
|
252
|
+
type ChartArtifactSpec = AgentChatChartArtifactSpec;
|
|
253
|
+
type HtmlArtifactSpec = AgentChatHtmlArtifactSpec;
|
|
254
|
+
type SvgArtifactSpec = AgentChatSvgArtifactSpec;
|
|
255
|
+
type ClarifyChoice = AgentChatClarifyChoice;
|
|
256
|
+
type ClarifyQuestion = AgentChatClarifyQuestion;
|
|
257
|
+
type ClarifyArgs = AgentChatClarifyArgs;
|
|
258
|
+
type ClarifyAnswer = AgentChatClarifyAnswer;
|
|
259
|
+
|
|
260
|
+
interface AgentChatProps {
|
|
261
|
+
adapter: AgentChatAdapter;
|
|
262
|
+
agentId?: string;
|
|
263
|
+
sessionId: string | null;
|
|
264
|
+
onSessionChange?: (sessionId: string) => void;
|
|
265
|
+
onFileSelect?: (path: string) => void;
|
|
266
|
+
onMessagesChange?: (messages: AgentChatMessage[]) => void;
|
|
267
|
+
disabled?: boolean;
|
|
268
|
+
}
|
|
269
|
+
declare function AgentChat({ adapter, agentId, sessionId, onSessionChange, onFileSelect, onMessagesChange, disabled, }: AgentChatProps): react_jsx_runtime.JSX.Element;
|
|
270
|
+
|
|
271
|
+
interface AgentChatAdapterContextValue {
|
|
272
|
+
adapter: AgentChatAdapter;
|
|
273
|
+
sessionId: string | null;
|
|
274
|
+
onFileSelect?: (path: string) => void;
|
|
275
|
+
}
|
|
276
|
+
declare const AgentChatAdapterProvider: react.Provider<AgentChatAdapterContextValue | null>;
|
|
277
|
+
declare function useAgentChatAdapterContext(): AgentChatAdapterContextValue;
|
|
278
|
+
|
|
279
|
+
interface UseAgentChatRuntimeInput {
|
|
280
|
+
adapter: AgentChatAdapter;
|
|
281
|
+
agentId?: string;
|
|
282
|
+
sessionId: string | null;
|
|
283
|
+
onSessionChange?: (sessionId: string) => void;
|
|
284
|
+
}
|
|
285
|
+
declare function useAgentChatRuntime({ adapter, agentId, sessionId, onSessionChange, }: UseAgentChatRuntimeInput): AgentChatRuntimeApi;
|
|
286
|
+
|
|
287
|
+
export { AgentChat, type AgentChatAdapter, type AgentChatAdapterContextValue, AgentChatAdapterProvider, type AgentChatArtifactKind, type AgentChatArtifactMeta, type AgentChatArtifactPayload, type AgentChatChartArtifactSpec, type AgentChatClarifyAnswer, type AgentChatClarifyArgs, type AgentChatClarifyChoice, type AgentChatClarifyQuestion, type AgentChatErrorCategory, type AgentChatErrorInfo, type AgentChatEventStream, type AgentChatEventType, type AgentChatExpertFeedbackRating, type AgentChatHtmlArtifactSpec, type AgentChatMarkdownArtifactSpec, type AgentChatMessage, type AgentChatMessageStatus, type AgentChatProps, type AgentChatRole, type AgentChatRuntimeApi, type AgentChatRuntimeEvent, type AgentChatSession, type AgentChatSessionList, type AgentChatSlashCommand, type AgentChatSseMessageEvent, type AgentChatState, type AgentChatSvgArtifactSpec, type AgentChatSystemKind, type AgentChatTableArtifactSpec, type AgentChatTokenUsage, type AgentChatToolCallInfo, type ArtifactKind, type ArtifactPayload, type ChartArtifactSpec, type ChatMessage, type ClarifyAnswer, type ClarifyArgs, type ClarifyChoice, type ClarifyQuestion, type ErrorInfo, type HtmlArtifactSpec, type MarkdownArtifactSpec, type RetryIndicator, type SvgArtifactSpec, type TableArtifactSpec, type TokenUsage, type ToolCallInfo, useAgentChatAdapterContext, useAgentChatRuntime };
|