@agno-hq/chat-react 0.1.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 ADDED
@@ -0,0 +1,1967 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ var react = require('react');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+
7
+ // src/useAgnoChat.ts
8
+
9
+ // src/stream.ts
10
+ function isEnvelope(data) {
11
+ return typeof data === "object" && data !== null && "event" in data && "data" in data && typeof data.event === "string";
12
+ }
13
+ function isFlatEvent(data) {
14
+ return typeof data === "object" && data !== null && "event" in data && !("data" in data) && typeof data.event === "string";
15
+ }
16
+ function normaliseEnvelope(env) {
17
+ let parsed = {};
18
+ if (typeof env.data === "string") {
19
+ try {
20
+ parsed = JSON.parse(env.data);
21
+ } catch {
22
+ parsed = {};
23
+ }
24
+ } else if (env.data && typeof env.data === "object") {
25
+ parsed = env.data;
26
+ }
27
+ return { event: env.event, ...parsed };
28
+ }
29
+ function drainBuffer(buffer, onEvent) {
30
+ let start = buffer.indexOf("{");
31
+ while (start !== -1 && start < buffer.length) {
32
+ let depth = 0;
33
+ let inString = false;
34
+ let escape = false;
35
+ let end = -1;
36
+ for (let i = start; i < buffer.length; i++) {
37
+ const ch = buffer[i];
38
+ if (inString) {
39
+ if (escape) escape = false;
40
+ else if (ch === "\\") escape = true;
41
+ else if (ch === '"') inString = false;
42
+ } else if (ch === '"') {
43
+ inString = true;
44
+ } else if (ch === "{") {
45
+ depth++;
46
+ } else if (ch === "}") {
47
+ depth--;
48
+ if (depth === 0) {
49
+ end = i;
50
+ break;
51
+ }
52
+ }
53
+ }
54
+ if (end === -1) break;
55
+ const slice = buffer.slice(start, end + 1);
56
+ try {
57
+ const parsed = JSON.parse(slice);
58
+ if (isEnvelope(parsed)) onEvent(normaliseEnvelope(parsed));
59
+ else if (isFlatEvent(parsed)) onEvent(parsed);
60
+ } catch {
61
+ start = buffer.indexOf("{", start + 1);
62
+ continue;
63
+ }
64
+ buffer = buffer.slice(end + 1).trim();
65
+ start = buffer.indexOf("{");
66
+ }
67
+ return buffer;
68
+ }
69
+ async function streamRun(options) {
70
+ const { url, body, headers = {}, signal, onEvent, onError, onComplete } = options;
71
+ let buffer = "";
72
+ try {
73
+ const response = await fetch(url, {
74
+ method: "POST",
75
+ headers: {
76
+ ...!(body instanceof FormData) && { "Content-Type": "application/json" },
77
+ ...headers
78
+ },
79
+ body: body instanceof FormData ? body : JSON.stringify(body),
80
+ signal
81
+ });
82
+ if (!response.ok) {
83
+ let detail;
84
+ try {
85
+ const err = await response.json();
86
+ detail = err?.detail ? String(err.detail) : `${response.status} ${response.statusText}`;
87
+ } catch {
88
+ detail = `${response.status} ${response.statusText}`;
89
+ }
90
+ throw new Error(detail);
91
+ }
92
+ if (!response.body) throw new Error("No response body");
93
+ const reader = response.body.getReader();
94
+ const decoder = new TextDecoder();
95
+ for (; ; ) {
96
+ const { done, value } = await reader.read();
97
+ if (done) {
98
+ buffer = drainBuffer(buffer, onEvent);
99
+ onComplete();
100
+ return;
101
+ }
102
+ buffer += decoder.decode(value, { stream: true });
103
+ buffer = drainBuffer(buffer, onEvent);
104
+ }
105
+ } catch (error) {
106
+ if (error instanceof DOMException && error.name === "AbortError") {
107
+ onComplete();
108
+ return;
109
+ }
110
+ onError(error instanceof Error ? error : new Error(String(error)));
111
+ }
112
+ }
113
+
114
+ // src/client.ts
115
+ function normaliseBaseUrl(value) {
116
+ if (!value) return "";
117
+ let url = value.trim();
118
+ if (!/^https?:\/\//.test(url)) {
119
+ const isLocal = url.startsWith("localhost") || /^\d{1,3}(\.\d{1,3}){3}/.test(url);
120
+ url = `${isLocal ? "http" : "https"}://${url}`;
121
+ }
122
+ return url.replace(/\/+$/, "");
123
+ }
124
+ var RUN_PATH = {
125
+ agent: "agents",
126
+ team: "teams",
127
+ workflow: "workflows"
128
+ };
129
+ var AgnoClient = class {
130
+ constructor(options) {
131
+ this.baseUrl = normaliseBaseUrl(options.baseUrl);
132
+ this.headers = options.headers ?? {};
133
+ this.dbId = options.dbId;
134
+ }
135
+ async getJson(path) {
136
+ const res = await fetch(`${this.baseUrl}${path}`, { headers: this.headers });
137
+ if (!res.ok) throw new Error(`GET ${path} failed: ${res.status} ${res.statusText}`);
138
+ return res.json();
139
+ }
140
+ /** Liveness check against /health. Returns the HTTP status code. */
141
+ async health() {
142
+ try {
143
+ const res = await fetch(`${this.baseUrl}/health`, { headers: this.headers });
144
+ return res.status;
145
+ } catch {
146
+ return 0;
147
+ }
148
+ }
149
+ /* ----------------------------- discovery ----------------------------- */
150
+ async getAgents() {
151
+ const data = await this.getJson("/agents").catch(() => []);
152
+ return data.map((a) => ({
153
+ type: "agent",
154
+ id: a.agent_id ?? a.id,
155
+ name: a.name ?? a.agent_id ?? a.id,
156
+ description: a.description,
157
+ model: a.model,
158
+ db_id: a.db_id
159
+ }));
160
+ }
161
+ async getTeams() {
162
+ const data = await this.getJson("/teams").catch(() => []);
163
+ return data.map((t) => ({
164
+ type: "team",
165
+ id: t.team_id ?? t.id,
166
+ name: t.name ?? t.team_id ?? t.id,
167
+ description: t.description,
168
+ model: t.model,
169
+ db_id: t.db_id
170
+ }));
171
+ }
172
+ async getWorkflows() {
173
+ const data = await this.getJson("/workflows").catch(() => []);
174
+ return data.map((w) => ({
175
+ type: "workflow",
176
+ id: w.workflow_id ?? w.id,
177
+ name: w.name ?? w.workflow_id ?? w.id,
178
+ description: w.description,
179
+ model: w.model,
180
+ db_id: w.db_id
181
+ }));
182
+ }
183
+ /** All runnable entities (agents, teams, workflows) in one list. */
184
+ async getEntities() {
185
+ const [agents, teams, workflows] = await Promise.all([
186
+ this.getAgents(),
187
+ this.getTeams(),
188
+ this.getWorkflows()
189
+ ]);
190
+ return [...agents, ...teams, ...workflows];
191
+ }
192
+ /* ------------------------------ sessions ----------------------------- */
193
+ async getSessions(type, componentId, dbId) {
194
+ const url = new URL(`${this.baseUrl}/sessions`);
195
+ url.searchParams.set("type", type);
196
+ url.searchParams.set("component_id", componentId);
197
+ const db = dbId ?? this.dbId;
198
+ if (db) url.searchParams.set("db_id", db);
199
+ try {
200
+ const res = await fetch(url.toString(), { headers: this.headers });
201
+ if (!res.ok) return { data: [] };
202
+ return await res.json();
203
+ } catch {
204
+ return { data: [] };
205
+ }
206
+ }
207
+ /** Runs (with messages/tools/events) for a session — used to rehydrate chat history. */
208
+ async getSessionRuns(type, sessionId, dbId) {
209
+ const url = new URL(`${this.baseUrl}/sessions/${sessionId}/runs`);
210
+ url.searchParams.set("type", type);
211
+ const db = dbId ?? this.dbId;
212
+ if (db) url.searchParams.set("db_id", db);
213
+ const res = await fetch(url.toString(), { headers: this.headers });
214
+ if (!res.ok) throw new Error(`Failed to load session: ${res.statusText}`);
215
+ return res.json();
216
+ }
217
+ async deleteSession(sessionId, dbId) {
218
+ const url = new URL(`${this.baseUrl}/sessions/${sessionId}`);
219
+ const db = dbId ?? this.dbId;
220
+ if (db) url.searchParams.set("db_id", db);
221
+ const res = await fetch(url.toString(), { method: "DELETE", headers: this.headers });
222
+ return res.ok;
223
+ }
224
+ /* -------------------------------- runs ------------------------------- */
225
+ /** Start a streaming run for an agent, team or workflow. */
226
+ async run(args) {
227
+ const form = new FormData();
228
+ if (args.message != null) form.append("message", args.message);
229
+ form.append("stream", "true");
230
+ if (args.sessionId) form.append("session_id", args.sessionId);
231
+ if (args.userId) form.append("user_id", args.userId);
232
+ for (const file of args.files ?? []) form.append("files", file);
233
+ for (const [k, v] of Object.entries(args.extra ?? {})) form.append(k, v);
234
+ const url = `${this.baseUrl}/${RUN_PATH[args.type]}/${args.id}/runs`;
235
+ return streamRun({
236
+ url,
237
+ body: form,
238
+ headers: this.headers,
239
+ signal: args.signal,
240
+ onEvent: (e) => args.onEvent(e),
241
+ onError: args.onError,
242
+ onComplete: args.onComplete
243
+ });
244
+ }
245
+ /** Continue a paused run (resolving a human-in-the-loop requirement). */
246
+ async continueRun(args) {
247
+ const form = new FormData();
248
+ form.append("stream", "true");
249
+ if (args.sessionId) form.append("session_id", args.sessionId);
250
+ if (args.userId) form.append("user_id", args.userId);
251
+ if (args.type === "workflow") {
252
+ if (args.stepRequirements) form.append("step_requirements", JSON.stringify(args.stepRequirements));
253
+ } else if (args.tools) {
254
+ form.append("tools", JSON.stringify(args.tools));
255
+ }
256
+ const url = `${this.baseUrl}/${RUN_PATH[args.type]}/${args.id}/runs/${args.runId}/continue`;
257
+ return streamRun({
258
+ url,
259
+ body: form,
260
+ headers: this.headers,
261
+ signal: args.signal,
262
+ onEvent: (e) => args.onEvent(e),
263
+ onError: args.onError,
264
+ onComplete: args.onComplete
265
+ });
266
+ }
267
+ /** Cancel an in-flight run. */
268
+ async cancelRun(type, id2, runId, sessionId) {
269
+ const url = new URL(`${this.baseUrl}/${RUN_PATH[type]}/${id2}/runs/${runId}/cancel`);
270
+ if (sessionId) url.searchParams.set("session_id", sessionId);
271
+ try {
272
+ const res = await fetch(url.toString(), { method: "POST", headers: this.headers });
273
+ return res.ok;
274
+ } catch {
275
+ return false;
276
+ }
277
+ }
278
+ };
279
+
280
+ // src/events.ts
281
+ var name = (e) => String(e.event ?? "");
282
+ var isStartedEvent = (e) => name(e) === "RunStarted" || name(e) === "TeamRunStarted" || name(e) === "WorkflowStarted" || name(e) === "ReasoningStarted" || name(e) === "TeamReasoningStarted";
283
+ var isContentEvent = (e) => name(e) === "RunContent" || name(e) === "TeamRunContent" || name(e) === "WorkflowAgentCompleted";
284
+ var isCompletedEvent = (e) => name(e) === "RunCompleted" || name(e) === "TeamRunCompleted" || name(e) === "WorkflowCompleted";
285
+ var isErrorEvent = (e) => name(e) === "RunError" || name(e) === "TeamRunError" || name(e) === "WorkflowError" || name(e) === "StepError" || name(e) === "ToolCallError" || name(e) === "TeamToolCallError";
286
+ var isCancelledEvent = (e) => name(e) === "RunCancelled" || name(e) === "TeamRunCancelled" || name(e) === "WorkflowCancelled";
287
+ var isPausedEvent = (e) => name(e) === "RunPaused" || name(e) === "TeamRunPaused" || name(e) === "WorkflowPaused" || name(e) === "StepPaused" || name(e) === "RouterPaused" || name(e) === "ConditionPaused";
288
+ var isToolStartedEvent = (e) => name(e) === "ToolCallStarted" || name(e) === "TeamToolCallStarted";
289
+ var isToolCompletedEvent = (e) => name(e) === "ToolCallCompleted" || name(e) === "TeamToolCallCompleted";
290
+ var isToolEvent = (e) => isToolStartedEvent(e) || isToolCompletedEvent(e) || name(e) === "ToolCallError" || name(e) === "TeamToolCallError";
291
+ var isReasoningStepEvent = (e) => name(e) === "ReasoningStep" || name(e) === "TeamReasoningStep";
292
+ var isReasoningCompletedEvent = (e) => name(e) === "ReasoningCompleted" || name(e) === "TeamReasoningCompleted";
293
+ function isSubRunEvent(e) {
294
+ if (!e.parent_run_id) return false;
295
+ const ev = name(e);
296
+ return isContentEvent(e) || isToolEvent(e) || isCompletedEvent(e) || isErrorEvent(e) || ev === "RunStarted" || ev === "TeamRunStarted";
297
+ }
298
+ function isStepEvent(e) {
299
+ const ev = name(e);
300
+ return ev === "StepStarted" || ev === "StepCompleted" || ev === "StepOutput" || ev === "StepError";
301
+ }
302
+ function toolsFromEvent(e) {
303
+ const out = [];
304
+ if (e.tool) out.push(e.tool);
305
+ if (Array.isArray(e.tools)) out.push(...e.tools);
306
+ return out;
307
+ }
308
+ function activityLabel(e) {
309
+ const ev = name(e);
310
+ switch (ev) {
311
+ case "RunStarted":
312
+ case "TeamRunStarted":
313
+ case "WorkflowStarted":
314
+ return "Thinking";
315
+ case "ModelRequestStarted":
316
+ case "TeamModelRequestStarted":
317
+ return "Generating";
318
+ case "ReasoningStarted":
319
+ case "TeamReasoningStarted":
320
+ case "ReasoningStep":
321
+ case "TeamReasoningStep":
322
+ case "ReasoningContentDelta":
323
+ case "TeamReasoningContentDelta":
324
+ return "Reasoning";
325
+ case "MemoryUpdateStarted":
326
+ case "TeamMemoryUpdateStarted":
327
+ return "Updating memory";
328
+ case "SessionSummaryStarted":
329
+ case "TeamSessionSummaryStarted":
330
+ return "Summarising session";
331
+ case "CompressionStarted":
332
+ return "Compressing context";
333
+ case "ToolCallStarted":
334
+ case "TeamToolCallStarted": {
335
+ const tool = e.tool?.tool_name;
336
+ return tool ? `Calling ${tool}` : "Calling tool";
337
+ }
338
+ case "ToolCallCompleted":
339
+ case "TeamToolCallCompleted":
340
+ return "Generating";
341
+ case "StepStarted":
342
+ return e.step_name ? `Running step: ${e.step_name}` : "Running step";
343
+ case "LoopIterationStarted":
344
+ return `Loop iteration ${e.iteration ?? ""}`.trim();
345
+ case "ParallelExecutionStarted":
346
+ return "Running parallel steps";
347
+ case "RouterExecutionStarted":
348
+ return "Routing";
349
+ case "ConditionExecutionStarted":
350
+ return "Evaluating condition";
351
+ default:
352
+ return null;
353
+ }
354
+ }
355
+ function textOf(value) {
356
+ if (typeof value === "string") return value;
357
+ if (value && typeof value === "object") return "```json\n" + JSON.stringify(value, null, 2) + "\n```";
358
+ return void 0;
359
+ }
360
+ function applySubRunEvent(message, e, kind) {
361
+ const rid = e.run_id || e.parent_run_id || "sub";
362
+ const members = message.members ? [...message.members] : [];
363
+ const idx = members.findIndex((s) => s.run_id === rid);
364
+ const base = idx >= 0 ? { ...members[idx] } : { run_id: rid, kind, content: "", status: "running" };
365
+ base.name = base.name || e.agent_name || e.team_name || e.agent_id;
366
+ const tools = toolsFromEvent(e);
367
+ if (tools.length) {
368
+ let tc = base.tool_calls ?? [];
369
+ for (const t of tools) tc = mergeTool(tc, t);
370
+ base.tool_calls = tc;
371
+ }
372
+ if (isErrorEvent(e)) {
373
+ base.status = "error";
374
+ } else if (isCompletedEvent(e)) {
375
+ base.status = "completed";
376
+ const final = textOf(e.content);
377
+ if (final) base.content = final;
378
+ } else if (isContentEvent(e)) {
379
+ const delta = typeof e.content === "string" ? e.content : "";
380
+ if (delta) base.content += delta;
381
+ }
382
+ if (idx >= 0) members[idx] = base;
383
+ else members.push(base);
384
+ return { ...message, members };
385
+ }
386
+ function applyStepEvent(message, e) {
387
+ const ev = name(e);
388
+ const key = e.step_name || `step-${JSON.stringify(e.step_index ?? "")}`;
389
+ const steps = message.steps ? [...message.steps] : [];
390
+ const idx = steps.findIndex((s) => s.key === key);
391
+ const step = idx >= 0 ? { ...steps[idx] } : { key, name: e.step_name, index: e.step_index, status: "running" };
392
+ if (ev === "StepStarted") {
393
+ step.status = "running";
394
+ } else if (ev === "StepError") {
395
+ step.status = "error";
396
+ step.error = e.error || (typeof e.content === "string" ? e.content : void 0);
397
+ } else {
398
+ step.status = "completed";
399
+ const stepResponse = e.step_response ?? e.step_output;
400
+ const content = textOf(e.content) ?? textOf(stepResponse?.content);
401
+ if (content) step.content = content;
402
+ }
403
+ if (idx >= 0) steps[idx] = step;
404
+ else steps.push(step);
405
+ return { ...message, steps };
406
+ }
407
+ function mergeTool(list, tool) {
408
+ const key = tool.tool_call_id || `${tool.tool_name}-${tool.created_at}`;
409
+ const idx = list.findIndex((t) => {
410
+ if (t.tool_call_id && tool.tool_call_id) return t.tool_call_id === tool.tool_call_id;
411
+ return `${t.tool_name}-${t.created_at}` === key;
412
+ });
413
+ if (idx >= 0) {
414
+ const next = [...list];
415
+ next[idx] = { ...next[idx], ...tool };
416
+ return next;
417
+ }
418
+ return [...list, tool];
419
+ }
420
+
421
+ // src/session.ts
422
+ function toText(value) {
423
+ if (value == null) return "";
424
+ if (typeof value === "string") return value;
425
+ if (Array.isArray(value)) {
426
+ return value.map(
427
+ (part) => part && typeof part === "object" && "text" in part ? String(part.text) : ""
428
+ ).filter(Boolean).join(" ");
429
+ }
430
+ if (typeof value === "object") {
431
+ const obj = value;
432
+ if (typeof obj.input_content === "string") return obj.input_content;
433
+ if (typeof obj.message === "string") return obj.message;
434
+ if (typeof obj.content === "string") return obj.content;
435
+ return "```json\n" + JSON.stringify(value, null, 2) + "\n```";
436
+ }
437
+ return String(value);
438
+ }
439
+ var seq = 0;
440
+ var id = (prefix) => `${prefix}-${seq++}`;
441
+ function sessionRunsToMessages(runs) {
442
+ if (!Array.isArray(runs)) return [];
443
+ const messages = [];
444
+ for (const run of runs) {
445
+ const created = run.created_at ?? Math.floor(Date.now() / 1e3);
446
+ const userContent = toText(run.run_input);
447
+ if (userContent) {
448
+ messages.push({
449
+ id: id("hist-u"),
450
+ role: "user",
451
+ content: userContent,
452
+ created_at: created
453
+ });
454
+ }
455
+ messages.push({
456
+ id: id("hist-a"),
457
+ role: "agent",
458
+ content: toText(run.content),
459
+ created_at: created,
460
+ status: "completed",
461
+ run_id: run.run_id,
462
+ session_id: run.session_id,
463
+ tool_calls: run.tools && run.tools.length ? run.tools : void 0,
464
+ reasoning_steps: run.reasoning_steps ?? run.extra_data?.reasoning_steps,
465
+ references: run.references ?? run.extra_data?.references,
466
+ images: run.images,
467
+ videos: run.videos,
468
+ audio: run.audio,
469
+ response_audio: run.response_audio
470
+ });
471
+ }
472
+ return messages;
473
+ }
474
+
475
+ // src/useAgnoChat.ts
476
+ var messageCounter = 0;
477
+ var nextId = () => `m${Date.now().toString(36)}-${(messageCounter++).toString(36)}`;
478
+ var nowSeconds = () => Math.floor(Date.now() / 1e3);
479
+ function useAgnoChat(options) {
480
+ const { entity, userId, onEvent, onSessionId } = options;
481
+ const client = react.useMemo(() => {
482
+ if (options.client) return options.client;
483
+ return new AgnoClient({ baseUrl: options.baseUrl ?? "", headers: options.headers });
484
+ }, [options.client, options.baseUrl, JSON.stringify(options.headers)]);
485
+ const [messages, setMessages] = react.useState(options.initialMessages ?? []);
486
+ const [events, setEvents] = react.useState([]);
487
+ const [currentEvent, setCurrentEvent] = react.useState(null);
488
+ const [status, setStatus] = react.useState("idle");
489
+ const [activity, setActivity] = react.useState(null);
490
+ const [error, setError] = react.useState(null);
491
+ const [sessionId, setSessionId] = react.useState(options.sessionId);
492
+ const [sessions, setSessions] = react.useState([]);
493
+ const [sessionsLoading, setSessionsLoading] = react.useState(false);
494
+ const abortRef = react.useRef(null);
495
+ const activeMsgIdRef = react.useRef(null);
496
+ const lastContentRef = react.useRef("");
497
+ const runIdRef = react.useRef(void 0);
498
+ const entityRef = react.useRef(entity);
499
+ const sessionIdRef = react.useRef(options.sessionId);
500
+ react.useEffect(() => {
501
+ entityRef.current = entity;
502
+ }, [entity]);
503
+ react.useEffect(() => {
504
+ sessionIdRef.current = sessionId;
505
+ }, [sessionId]);
506
+ const patchActive = react.useCallback((patch) => {
507
+ const id2 = activeMsgIdRef.current;
508
+ if (!id2) return;
509
+ setMessages((prev) => prev.map((m) => m.id === id2 ? patch(m) : m));
510
+ }, []);
511
+ const applyEvent = react.useCallback(
512
+ (e) => {
513
+ setEvents((prev) => [...prev, e]);
514
+ setCurrentEvent(e);
515
+ onEvent?.(e);
516
+ const label2 = activityLabel(e);
517
+ if (label2) setActivity(label2);
518
+ if (e.session_id && e.session_id !== sessionIdRef.current) {
519
+ sessionIdRef.current = e.session_id;
520
+ setSessionId(e.session_id);
521
+ onSessionId?.(e.session_id);
522
+ }
523
+ if (e.run_id && !e.parent_run_id) runIdRef.current = e.run_id;
524
+ if (isSubRunEvent(e)) {
525
+ const kind = entityRef.current?.type === "workflow" ? "executor" : "member";
526
+ patchActive((m) => applySubRunEvent(m, e, kind));
527
+ return;
528
+ }
529
+ if (isStepEvent(e)) {
530
+ patchActive((m) => applyStepEvent(m, e));
531
+ return;
532
+ }
533
+ if (isStartedEvent(e)) {
534
+ patchActive((m) => ({ ...m, run_id: e.run_id ?? m.run_id, session_id: e.session_id ?? m.session_id, status: "streaming" }));
535
+ return;
536
+ }
537
+ if (isToolEvent(e)) {
538
+ const incoming = toolsFromEvent(e);
539
+ if (incoming.length) {
540
+ patchActive((m) => {
541
+ let tool_calls = m.tool_calls ?? [];
542
+ for (const t of incoming) tool_calls = mergeTool(tool_calls, t);
543
+ return { ...m, tool_calls };
544
+ });
545
+ }
546
+ return;
547
+ }
548
+ if (isContentEvent(e)) {
549
+ patchActive((m) => {
550
+ const next = { ...m };
551
+ if (typeof e.content === "string" && e.content) {
552
+ const unique = e.content.startsWith(lastContentRef.current) ? e.content.slice(lastContentRef.current.length) : e.content;
553
+ next.content = (m.content ?? "") + unique;
554
+ lastContentRef.current = e.content.length >= lastContentRef.current.length ? e.content : lastContentRef.current;
555
+ } else if (e.content && typeof e.content === "object") {
556
+ next.content = (m.content ?? "") + "\n```json\n" + JSON.stringify(e.content, null, 2) + "\n```\n";
557
+ }
558
+ if (e.reasoning_steps?.length) next.reasoning_steps = e.reasoning_steps;
559
+ if (e.extra_data?.reasoning_steps?.length) next.reasoning_steps = e.extra_data.reasoning_steps;
560
+ if (e.references?.length) next.references = e.references;
561
+ if (e.extra_data?.references?.length) next.references = e.extra_data.references;
562
+ if (e.citations) next.citations = e.citations;
563
+ const tools = toolsFromEvent(e);
564
+ if (tools.length) {
565
+ let tc = m.tool_calls ?? [];
566
+ for (const t of tools) tc = mergeTool(tc, t);
567
+ next.tool_calls = tc;
568
+ }
569
+ if (e.images?.length) next.images = e.images;
570
+ if (e.videos?.length) next.videos = e.videos;
571
+ if (e.audio?.length) next.audio = e.audio;
572
+ if (e.response_audio?.transcript) {
573
+ next.response_audio = {
574
+ ...m.response_audio,
575
+ transcript: (m.response_audio?.transcript ?? "") + e.response_audio.transcript
576
+ };
577
+ }
578
+ return next;
579
+ });
580
+ return;
581
+ }
582
+ if (isReasoningStepEvent(e)) {
583
+ const incoming = e.reasoning_steps ?? e.extra_data?.reasoning_steps ?? [];
584
+ if (incoming.length) {
585
+ patchActive((m) => ({
586
+ ...m,
587
+ reasoning_steps: [...m.reasoning_steps ?? [], ...incoming]
588
+ }));
589
+ }
590
+ return;
591
+ }
592
+ if (isReasoningCompletedEvent(e)) {
593
+ const steps = e.reasoning_steps ?? e.extra_data?.reasoning_steps;
594
+ if (steps?.length) patchActive((m) => ({ ...m, reasoning_steps: steps }));
595
+ return;
596
+ }
597
+ if (isPausedEvent(e)) {
598
+ const requirements = e.requirements ?? [];
599
+ const pausedTools2 = toolsFromEvent(e);
600
+ setStatus("paused");
601
+ setActivity("Waiting for input");
602
+ patchActive((m) => {
603
+ let tool_calls = m.tool_calls ?? [];
604
+ for (const t of pausedTools2) tool_calls = mergeTool(tool_calls, t);
605
+ return { ...m, status: "paused", streaming: false, requirements, tool_calls };
606
+ });
607
+ return;
608
+ }
609
+ if (isCompletedEvent(e)) {
610
+ patchActive((m) => {
611
+ const next = { ...m, streaming: false, status: "completed" };
612
+ if (typeof e.content === "string" && e.content) next.content = e.content;
613
+ const tools = toolsFromEvent(e);
614
+ if (tools.length) {
615
+ let tc = m.tool_calls ?? [];
616
+ for (const t of tools) tc = mergeTool(tc, t);
617
+ next.tool_calls = tc;
618
+ }
619
+ if (e.reasoning_steps?.length) next.reasoning_steps = e.reasoning_steps;
620
+ if (e.references?.length) next.references = e.references;
621
+ if (e.images?.length) next.images = e.images;
622
+ if (e.videos?.length) next.videos = e.videos;
623
+ if (e.audio?.length) next.audio = e.audio;
624
+ if (e.response_audio) next.response_audio = e.response_audio;
625
+ return next;
626
+ });
627
+ return;
628
+ }
629
+ if (isCancelledEvent(e)) {
630
+ patchActive((m) => ({ ...m, streaming: false, status: "cancelled" }));
631
+ setStatus("cancelled");
632
+ return;
633
+ }
634
+ if (isErrorEvent(e)) {
635
+ const msg = typeof e.content === "string" ? e.content : e.error || "Error during run";
636
+ patchActive((m) => ({ ...m, streaming: false, status: "error", error: msg }));
637
+ setError(msg);
638
+ setStatus("error");
639
+ return;
640
+ }
641
+ },
642
+ [onEvent, onSessionId, patchActive]
643
+ );
644
+ const drive = react.useCallback(
645
+ async (starter) => {
646
+ const controller = new AbortController();
647
+ abortRef.current = controller;
648
+ setError(null);
649
+ setStatus("streaming");
650
+ lastContentRef.current = "";
651
+ await starter({
652
+ signal: controller.signal,
653
+ onEvent: applyEvent,
654
+ onError: (err) => {
655
+ patchActive((m) => ({ ...m, streaming: false, status: "error", error: err.message }));
656
+ setError(err.message);
657
+ setStatus("error");
658
+ },
659
+ onComplete: () => {
660
+ setActivity(null);
661
+ patchActive((m) => m.streaming ? { ...m, streaming: false } : m);
662
+ setStatus((s) => s === "streaming" ? "completed" : s);
663
+ }
664
+ });
665
+ abortRef.current = null;
666
+ },
667
+ [applyEvent, patchActive]
668
+ );
669
+ const sendMessage = react.useCallback(
670
+ async (message, sendOptions) => {
671
+ const ent = entityRef.current;
672
+ if (!ent) {
673
+ setError("No agent, team or workflow selected.");
674
+ return;
675
+ }
676
+ const userMsg = {
677
+ id: nextId(),
678
+ role: "user",
679
+ content: message,
680
+ created_at: nowSeconds()
681
+ };
682
+ const agentMsg = {
683
+ id: nextId(),
684
+ role: "agent",
685
+ content: "",
686
+ created_at: nowSeconds() + 1,
687
+ streaming: true,
688
+ status: "streaming",
689
+ tool_calls: [],
690
+ events: []
691
+ };
692
+ activeMsgIdRef.current = agentMsg.id;
693
+ setEvents([]);
694
+ setCurrentEvent(null);
695
+ setMessages((prev) => [...prev, userMsg, agentMsg]);
696
+ await drive(
697
+ (cb) => client.run({
698
+ type: ent.type,
699
+ id: ent.id,
700
+ message,
701
+ sessionId: sessionIdRef.current,
702
+ userId,
703
+ files: sendOptions?.files,
704
+ ...cb
705
+ })
706
+ );
707
+ },
708
+ [client, drive, userId]
709
+ );
710
+ const continueRun = react.useCallback(
711
+ async (resolution) => {
712
+ const ent = entityRef.current;
713
+ const runId = runIdRef.current;
714
+ if (!ent || !runId) {
715
+ setError("No paused run to continue.");
716
+ return;
717
+ }
718
+ patchActive((m) => ({ ...m, streaming: true, status: "streaming", requirements: void 0 }));
719
+ await drive(
720
+ (cb) => client.continueRun({
721
+ type: ent.type,
722
+ id: ent.id,
723
+ runId,
724
+ sessionId: sessionIdRef.current,
725
+ userId,
726
+ tools: resolution.tools,
727
+ stepRequirements: resolution.stepRequirements,
728
+ ...cb
729
+ })
730
+ );
731
+ },
732
+ [client, drive, patchActive, userId]
733
+ );
734
+ const activeMessage = react.useMemo(
735
+ () => messages.find((m) => m.id === activeMsgIdRef.current) ?? null,
736
+ [messages]
737
+ );
738
+ const pausedTools = react.useMemo(
739
+ () => (activeMessage?.tool_calls ?? []).filter((t) => t.requires_confirmation || t.requires_user_input),
740
+ [activeMessage]
741
+ );
742
+ const respondToConfirmation = react.useCallback(
743
+ async (approve) => {
744
+ const ent = entityRef.current;
745
+ if (ent?.type === "workflow") {
746
+ const reqs = (activeMessage?.requirements ?? []).map((r) => ({ ...r, confirmation: approve }));
747
+ await continueRun({ stepRequirements: reqs });
748
+ return;
749
+ }
750
+ const resolved = pausedTools.map((t) => ({ ...t, confirmed: approve }));
751
+ await continueRun({ tools: resolved });
752
+ },
753
+ [activeMessage, continueRun, pausedTools]
754
+ );
755
+ const submitUserInput = react.useCallback(
756
+ async (values) => {
757
+ const ent = entityRef.current;
758
+ if (ent?.type === "workflow") {
759
+ const reqs = (activeMessage?.requirements ?? []).map((r) => ({
760
+ ...r,
761
+ user_input_schema: (r.user_input_schema ?? []).map((f) => ({
762
+ ...f,
763
+ value: f.name in values ? values[f.name] : f.value
764
+ }))
765
+ }));
766
+ await continueRun({ stepRequirements: reqs });
767
+ return;
768
+ }
769
+ const resolved = pausedTools.map((t) => ({
770
+ ...t,
771
+ confirmed: true,
772
+ user_input_schema: (t.user_input_schema ?? []).map((f) => ({
773
+ ...f,
774
+ value: f.name in values ? values[f.name] : f.value
775
+ }))
776
+ }));
777
+ await continueRun({ tools: resolved });
778
+ },
779
+ [activeMessage, continueRun, pausedTools]
780
+ );
781
+ const cancel = react.useCallback(async () => {
782
+ abortRef.current?.abort();
783
+ const ent = entityRef.current;
784
+ const runId = runIdRef.current;
785
+ setStatus("cancelled");
786
+ setActivity(null);
787
+ patchActive((m) => m.streaming ? { ...m, streaming: false, status: "cancelled" } : m);
788
+ if (ent && runId) await client.cancelRun(ent.type, ent.id, runId, sessionIdRef.current);
789
+ }, [client, patchActive]);
790
+ const refreshSessions = react.useCallback(async () => {
791
+ const ent = entityRef.current;
792
+ if (!ent) {
793
+ setSessions([]);
794
+ return;
795
+ }
796
+ setSessionsLoading(true);
797
+ try {
798
+ const res = await client.getSessions(ent.type, ent.id, ent.db_id);
799
+ setSessions(res.data ?? []);
800
+ } finally {
801
+ setSessionsLoading(false);
802
+ }
803
+ }, [client]);
804
+ const loadSession = react.useCallback(
805
+ async (id2) => {
806
+ const ent = entityRef.current;
807
+ if (!ent) return;
808
+ abortRef.current?.abort();
809
+ activeMsgIdRef.current = null;
810
+ runIdRef.current = void 0;
811
+ lastContentRef.current = "";
812
+ setEvents([]);
813
+ setCurrentEvent(null);
814
+ setStatus("idle");
815
+ setActivity(null);
816
+ setError(null);
817
+ sessionIdRef.current = id2;
818
+ setSessionId(id2);
819
+ onSessionId?.(id2);
820
+ try {
821
+ const runs = await client.getSessionRuns(ent.type, id2, ent.db_id);
822
+ setMessages(sessionRunsToMessages(runs));
823
+ } catch (err) {
824
+ setError(err instanceof Error ? err.message : String(err));
825
+ }
826
+ },
827
+ [client, onSessionId]
828
+ );
829
+ const deleteSession = react.useCallback(
830
+ async (id2) => {
831
+ const ent = entityRef.current;
832
+ const ok = await client.deleteSession(id2, ent?.db_id);
833
+ if (ok) {
834
+ setSessions((prev) => prev.filter((s) => s.session_id !== id2));
835
+ if (sessionIdRef.current === id2) {
836
+ sessionIdRef.current = void 0;
837
+ setSessionId(void 0);
838
+ setMessages([]);
839
+ }
840
+ }
841
+ },
842
+ [client]
843
+ );
844
+ const reset = react.useCallback(() => {
845
+ abortRef.current?.abort();
846
+ abortRef.current = null;
847
+ activeMsgIdRef.current = null;
848
+ runIdRef.current = void 0;
849
+ lastContentRef.current = "";
850
+ sessionIdRef.current = void 0;
851
+ setMessages([]);
852
+ setEvents([]);
853
+ setCurrentEvent(null);
854
+ setStatus("idle");
855
+ setActivity(null);
856
+ setError(null);
857
+ setSessionId(void 0);
858
+ }, []);
859
+ react.useEffect(() => () => abortRef.current?.abort(), []);
860
+ const streamingMessage = react.useMemo(
861
+ () => messages.find((m) => m.role === "agent" && m.streaming) ?? null,
862
+ [messages]
863
+ );
864
+ return {
865
+ messages,
866
+ streamingMessage,
867
+ events,
868
+ currentEvent,
869
+ status,
870
+ activity,
871
+ isStreaming: status === "streaming",
872
+ isPaused: status === "paused",
873
+ error,
874
+ sessionId,
875
+ entityType: entity?.type,
876
+ tools: activeMessage?.tool_calls ?? [],
877
+ reasoning: activeMessage?.reasoning_steps,
878
+ pendingRequirements: activeMessage?.requirements ?? [],
879
+ sessions,
880
+ sessionsLoading,
881
+ sendMessage,
882
+ cancel,
883
+ continueRun,
884
+ respondToConfirmation,
885
+ submitUserInput,
886
+ refreshSessions,
887
+ loadSession,
888
+ deleteSession,
889
+ reset,
890
+ setMessages,
891
+ client
892
+ };
893
+ }
894
+ function ChatInput({
895
+ onSend,
896
+ onStop,
897
+ disabled,
898
+ busy,
899
+ placeholder = "Ask anything",
900
+ allowFiles = false
901
+ }) {
902
+ const [value, setValue] = react.useState("");
903
+ const [files, setFiles] = react.useState([]);
904
+ const fileRef = react.useRef(null);
905
+ const submit = () => {
906
+ const text = value.trim();
907
+ if (!text && files.length === 0) return;
908
+ onSend(text, files.length ? files : void 0);
909
+ setValue("");
910
+ setFiles([]);
911
+ };
912
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-input", children: [
913
+ files.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-input__files", children: files.map((f, i) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "agno-input__file", children: [
914
+ f.name,
915
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => setFiles((prev) => prev.filter((_, j) => j !== i)), "aria-label": "Remove", children: "\xD7" })
916
+ ] }, i)) }),
917
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-input__row", children: [
918
+ allowFiles && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
919
+ /* @__PURE__ */ jsxRuntime.jsx(
920
+ "button",
921
+ {
922
+ type: "button",
923
+ className: "agno-input__attach",
924
+ onClick: () => fileRef.current?.click(),
925
+ disabled,
926
+ "aria-label": "Attach files",
927
+ children: "\u{1F4CE}"
928
+ }
929
+ ),
930
+ /* @__PURE__ */ jsxRuntime.jsx(
931
+ "input",
932
+ {
933
+ ref: fileRef,
934
+ type: "file",
935
+ multiple: true,
936
+ hidden: true,
937
+ onChange: (e) => setFiles((prev) => [...prev, ...Array.from(e.target.files ?? [])])
938
+ }
939
+ )
940
+ ] }),
941
+ /* @__PURE__ */ jsxRuntime.jsx(
942
+ "textarea",
943
+ {
944
+ className: "agno-input__textarea",
945
+ value,
946
+ placeholder,
947
+ disabled,
948
+ rows: 1,
949
+ onChange: (e) => setValue(e.target.value),
950
+ onKeyDown: (e) => {
951
+ if (e.key === "Enter" && !e.shiftKey) {
952
+ e.preventDefault();
953
+ submit();
954
+ }
955
+ }
956
+ }
957
+ ),
958
+ busy && onStop ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "agno-input__send agno-input__send--stop", onClick: onStop, "aria-label": "Stop", children: /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, children: "\u25A0" }) }) : /* @__PURE__ */ jsxRuntime.jsx(
959
+ "button",
960
+ {
961
+ type: "button",
962
+ className: "agno-input__send",
963
+ onClick: submit,
964
+ disabled: disabled || !value.trim() && files.length === 0,
965
+ "aria-label": "Send",
966
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, children: "\u27A4" })
967
+ }
968
+ )
969
+ ] })
970
+ ] });
971
+ }
972
+ var isBoolField = (f) => f.field_type === "bool" || f.field_type === "boolean";
973
+ function buildAsks(message, entityType) {
974
+ const fromTools = (message.tool_calls ?? []).filter((t) => t.requires_confirmation || t.requires_user_input).map((t) => ({
975
+ id: t.tool_call_id ?? `${t.tool_name}`,
976
+ name: t.tool_name,
977
+ args: t.tool_args,
978
+ needsConfirmation: Boolean(t.requires_confirmation) && t.confirmed == null,
979
+ fields: t.requires_user_input ? t.user_input_schema ?? [] : [],
980
+ tool: t
981
+ }));
982
+ const fromReqs = (message.requirements ?? []).map((r) => ({
983
+ id: r.id,
984
+ name: r.tool_execution?.tool_name,
985
+ args: r.tool_execution?.tool_args,
986
+ needsConfirmation: Boolean(r.tool_execution?.requires_confirmation) || r.confirmation == null,
987
+ fields: r.user_input_schema ?? r.tool_execution?.user_input_schema ?? [],
988
+ requirement: r
989
+ }));
990
+ if (entityType === "workflow") return fromReqs.length ? fromReqs : fromTools;
991
+ return fromTools.length ? fromTools : fromReqs;
992
+ }
993
+ function HumanInput({ message, entityType, busy, onResolve }) {
994
+ const asks = react.useMemo(() => buildAsks(message, entityType), [message, entityType]);
995
+ const [choices, setChoices] = react.useState({});
996
+ const [values, setValues] = react.useState({});
997
+ const [reasons, setReasons] = react.useState({});
998
+ const [openArgs, setOpenArgs] = react.useState({});
999
+ if (asks.length === 0) return null;
1000
+ const setValue = (id2, name2, value) => setValues((v) => ({ ...v, [id2]: { ...v[id2] ?? {}, [name2]: value } }));
1001
+ const valueFor = (ask, field) => values[ask.id]?.[field.name] ?? field.value ?? (isBoolField(field) ? false : "");
1002
+ const fillFields = (ask) => ask.fields.map((f) => ({ ...f, value: valueFor(ask, f) }));
1003
+ const ready = asks.every((a) => !a.needsConfirmation || choices[a.id]);
1004
+ const submit = () => {
1005
+ if (entityType === "workflow") {
1006
+ const stepRequirements = asks.map((a) => {
1007
+ const approved = a.needsConfirmation ? choices[a.id] === "confirm" : true;
1008
+ return {
1009
+ id: a.id,
1010
+ confirmation: approved,
1011
+ ...a.fields.length ? { user_input_schema: fillFields(a) } : {},
1012
+ tool_execution: a.requirement?.tool_execution,
1013
+ ...reasons[a.id] ? { confirmation_note: reasons[a.id] } : {}
1014
+ };
1015
+ });
1016
+ onResolve({ stepRequirements });
1017
+ return;
1018
+ }
1019
+ const tools = asks.map((a) => {
1020
+ const base = a.tool ?? { tool_call_id: a.id, tool_name: a.name };
1021
+ const approved = a.needsConfirmation ? choices[a.id] === "confirm" : true;
1022
+ return {
1023
+ ...base,
1024
+ ...a.needsConfirmation ? { confirmed: approved } : {},
1025
+ ...a.fields.length ? { answered: true, user_input_schema: fillFields(a) } : {},
1026
+ ...reasons[a.id] ? { confirmation_note: reasons[a.id] } : {}
1027
+ };
1028
+ });
1029
+ onResolve({ tools });
1030
+ };
1031
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-hitl", children: [
1032
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-hitl__title", children: [
1033
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, children: "\u270B" }),
1034
+ " Your input is needed"
1035
+ ] }),
1036
+ asks.map((ask) => {
1037
+ const choice = choices[ask.id];
1038
+ const hasArgs = ask.args && Object.keys(ask.args).length > 0;
1039
+ const argsOpen = openArgs[ask.id] ?? true;
1040
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-hitl-card", children: [
1041
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-hitl-card__head", children: [
1042
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "agno-hitl-card__tool", children: [
1043
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-hitl-card__icon", "aria-hidden": true, children: "\u{1F527}" }),
1044
+ ask.name ?? "tool"
1045
+ ] }),
1046
+ ask.needsConfirmation && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "agno-hitl-card__choices", children: [
1047
+ /* @__PURE__ */ jsxRuntime.jsx(
1048
+ "button",
1049
+ {
1050
+ type: "button",
1051
+ className: `agno-hitl-card__choice ${choice === "reject" ? "is-active is-reject" : ""}`,
1052
+ "aria-label": "Reject",
1053
+ disabled: busy,
1054
+ onClick: () => setChoices((c) => ({ ...c, [ask.id]: "reject" })),
1055
+ children: "\u2715"
1056
+ }
1057
+ ),
1058
+ /* @__PURE__ */ jsxRuntime.jsx(
1059
+ "button",
1060
+ {
1061
+ type: "button",
1062
+ className: `agno-hitl-card__choice ${choice === "confirm" ? "is-active is-confirm" : ""}`,
1063
+ "aria-label": "Approve",
1064
+ disabled: busy,
1065
+ onClick: () => setChoices((c) => ({ ...c, [ask.id]: "confirm" })),
1066
+ children: "\u2713"
1067
+ }
1068
+ )
1069
+ ] })
1070
+ ] }),
1071
+ hasArgs && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-hitl-card__args", children: [
1072
+ /* @__PURE__ */ jsxRuntime.jsxs(
1073
+ "button",
1074
+ {
1075
+ type: "button",
1076
+ className: "agno-hitl-card__args-head",
1077
+ onClick: () => setOpenArgs((o) => ({ ...o, [ask.id]: !argsOpen })),
1078
+ children: [
1079
+ "Arguments",
1080
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-hitl-card__chev", children: argsOpen ? "\u25B2" : "\u25BC" })
1081
+ ]
1082
+ }
1083
+ ),
1084
+ argsOpen && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-hitl-card__args-body", children: Object.entries(ask.args ?? {}).map(([k, v]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-hitl-card__arg", children: [
1085
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-hitl-card__arg-key", children: k }),
1086
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-hitl-card__arg-val", children: typeof v === "object" ? JSON.stringify(v) : String(v) })
1087
+ ] }, k)) })
1088
+ ] }),
1089
+ choice === "reject" && /* @__PURE__ */ jsxRuntime.jsx(
1090
+ "textarea",
1091
+ {
1092
+ className: "agno-hitl-card__reason",
1093
+ placeholder: "Reason for rejection (optional)\u2026",
1094
+ rows: 2,
1095
+ value: reasons[ask.id] ?? "",
1096
+ disabled: busy,
1097
+ onChange: (e) => setReasons((r) => ({ ...r, [ask.id]: e.target.value }))
1098
+ }
1099
+ ),
1100
+ ask.fields.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-hitl-card__fields", children: ask.fields.map((field) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: `agno-hitl-card__field ${isBoolField(field) ? "is-bool" : ""}`, children: [
1101
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-hitl-card__field-name", children: field.description || field.name }),
1102
+ isBoolField(field) ? /* @__PURE__ */ jsxRuntime.jsx(
1103
+ "input",
1104
+ {
1105
+ type: "checkbox",
1106
+ checked: Boolean(valueFor(ask, field)),
1107
+ disabled: busy,
1108
+ onChange: (e) => setValue(ask.id, field.name, e.target.checked)
1109
+ }
1110
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
1111
+ "input",
1112
+ {
1113
+ className: "agno-hitl-card__input",
1114
+ value: String(valueFor(ask, field) ?? ""),
1115
+ placeholder: field.field_type ?? "text",
1116
+ disabled: busy,
1117
+ onChange: (e) => setValue(ask.id, field.name, e.target.value)
1118
+ }
1119
+ )
1120
+ ] }, field.name)) })
1121
+ ] }, ask.id);
1122
+ }),
1123
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-hitl__actions", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "agno-btn agno-btn--primary", disabled: busy || !ready, onClick: submit, children: "Continue" }) })
1124
+ ] });
1125
+ }
1126
+ function Citations({
1127
+ references,
1128
+ citations
1129
+ }) {
1130
+ const [open, setOpen] = react.useState(false);
1131
+ const refCount = references?.reduce((n, r) => n + (r.references?.length ?? 0), 0) ?? 0;
1132
+ const urls = citations?.urls ?? [];
1133
+ const total = refCount + urls.length;
1134
+ if (total === 0) return null;
1135
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-citations", children: [
1136
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "agno-citations__toggle", onClick: () => setOpen((v) => !v), children: [
1137
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, children: "\u{1F4DA}" }),
1138
+ " ",
1139
+ total,
1140
+ " source",
1141
+ total > 1 ? "s" : "",
1142
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-citations__chev", children: open ? "\u25B2" : "\u25BC" })
1143
+ ] }),
1144
+ open && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-citations__body", children: [
1145
+ references?.map(
1146
+ (group, gi) => (group.references ?? []).map((ref, ri) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-citations__item", children: [
1147
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-citations__name", children: ref.name ?? "reference" }),
1148
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-citations__snippet", children: ref.content })
1149
+ ] }, `r-${gi}-${ri}`))
1150
+ ),
1151
+ urls.map((u, i) => /* @__PURE__ */ jsxRuntime.jsx(
1152
+ "a",
1153
+ {
1154
+ className: "agno-citations__url",
1155
+ href: u.url,
1156
+ target: "_blank",
1157
+ rel: "noreferrer noopener",
1158
+ children: u.title ?? u.url
1159
+ },
1160
+ `u-${i}`
1161
+ ))
1162
+ ] })
1163
+ ] });
1164
+ }
1165
+ function renderInline(text, keyPrefix) {
1166
+ const nodes = [];
1167
+ const regex = /(`[^`]+`)|(\*\*[^*]+\*\*)|(\*[^*]+\*)|(\[[^\]]+\]\([^)]+\))/g;
1168
+ let last = 0;
1169
+ let match;
1170
+ let i = 0;
1171
+ while ((match = regex.exec(text)) !== null) {
1172
+ if (match.index > last) nodes.push(text.slice(last, match.index));
1173
+ const token = match[0];
1174
+ const key = `${keyPrefix}-${i++}`;
1175
+ if (token.startsWith("`")) {
1176
+ nodes.push(/* @__PURE__ */ jsxRuntime.jsx("code", { className: "agno-md-code", children: token.slice(1, -1) }, key));
1177
+ } else if (token.startsWith("**")) {
1178
+ nodes.push(/* @__PURE__ */ jsxRuntime.jsx("strong", { children: token.slice(2, -2) }, key));
1179
+ } else if (token.startsWith("*")) {
1180
+ nodes.push(/* @__PURE__ */ jsxRuntime.jsx("em", { children: token.slice(1, -1) }, key));
1181
+ } else {
1182
+ const m = /\[([^\]]+)\]\(([^)]+)\)/.exec(token);
1183
+ if (m) {
1184
+ nodes.push(
1185
+ /* @__PURE__ */ jsxRuntime.jsx("a", { href: m[2], target: "_blank", rel: "noreferrer noopener", children: m[1] }, key)
1186
+ );
1187
+ } else {
1188
+ nodes.push(token);
1189
+ }
1190
+ }
1191
+ last = match.index + token.length;
1192
+ }
1193
+ if (last < text.length) nodes.push(text.slice(last));
1194
+ return nodes;
1195
+ }
1196
+ function Markdown({ content, className }) {
1197
+ const blocks = [];
1198
+ const segments = content.split(/(```[\s\S]*?```)/g);
1199
+ segments.forEach((segment, si) => {
1200
+ if (segment.startsWith("```")) {
1201
+ const body = segment.replace(/^```[^\n]*\n?/, "").replace(/```$/, "");
1202
+ blocks.push(
1203
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "agno-md-pre", children: /* @__PURE__ */ jsxRuntime.jsx("code", { children: body }) }, `pre-${si}`)
1204
+ );
1205
+ return;
1206
+ }
1207
+ const lines = segment.split("\n");
1208
+ let listBuffer = [];
1209
+ const flushList = (key) => {
1210
+ if (!listBuffer.length) return;
1211
+ blocks.push(
1212
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "agno-md-list", children: listBuffer.map((item, ii) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: renderInline(item, `${key}-${ii}`) }, ii)) }, key)
1213
+ );
1214
+ listBuffer = [];
1215
+ };
1216
+ lines.forEach((line, li) => {
1217
+ const key = `${si}-${li}`;
1218
+ const heading = /^(#{1,4})\s+(.*)$/.exec(line);
1219
+ const listItem = /^\s*[-*]\s+(.*)$/.exec(line);
1220
+ if (listItem) {
1221
+ listBuffer.push(listItem[1]);
1222
+ return;
1223
+ }
1224
+ flushList(`ul-${key}`);
1225
+ if (heading) {
1226
+ const level = heading[1].length;
1227
+ const Tag = `h${Math.min(level + 1, 6)}`;
1228
+ blocks.push(
1229
+ /* @__PURE__ */ jsxRuntime.jsx(Tag, { className: "agno-md-heading", children: renderInline(heading[2], `h-${key}`) }, `h-${key}`)
1230
+ );
1231
+ } else if (line.trim() === "") ; else {
1232
+ blocks.push(
1233
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "agno-md-p", children: renderInline(line, `p-${key}`) }, `p-${key}`)
1234
+ );
1235
+ }
1236
+ });
1237
+ flushList(`ul-end-${si}`);
1238
+ });
1239
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: ["agno-md", className].filter(Boolean).join(" "), children: blocks });
1240
+ }
1241
+ function statusOf(tool) {
1242
+ if (tool.tool_call_error) return { label: "error", cls: "error" };
1243
+ if (tool.requires_confirmation && tool.confirmed == null) return { label: "awaiting approval", cls: "paused" };
1244
+ if (tool.requires_user_input && !tool.answered) return { label: "awaiting input", cls: "paused" };
1245
+ if (tool.result != null) return { label: "done", cls: "done" };
1246
+ return { label: "running", cls: "running" };
1247
+ }
1248
+ function ToolCall({ tool }) {
1249
+ const [open, setOpen] = react.useState(false);
1250
+ const status = statusOf(tool);
1251
+ const hasDetail = Boolean(tool.tool_args && Object.keys(tool.tool_args).length) || tool.result != null;
1252
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `agno-tool agno-tool--${status.cls}`, children: [
1253
+ /* @__PURE__ */ jsxRuntime.jsxs(
1254
+ "button",
1255
+ {
1256
+ type: "button",
1257
+ className: "agno-tool__head",
1258
+ onClick: () => hasDetail && setOpen((v) => !v),
1259
+ "aria-expanded": open,
1260
+ children: [
1261
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-tool__icon", "aria-hidden": true, children: "\u{1F527}" }),
1262
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-tool__name", children: tool.tool_name ?? "tool" }),
1263
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `agno-tool__status agno-tool__status--${status.cls}`, children: status.label }),
1264
+ hasDetail && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-tool__chev", children: open ? "\u25B2" : "\u25BC" })
1265
+ ]
1266
+ }
1267
+ ),
1268
+ open && hasDetail && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-tool__body", children: [
1269
+ tool.tool_args && Object.keys(tool.tool_args).length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-tool__section", children: [
1270
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-tool__label", children: "Arguments" }),
1271
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "agno-tool__pre", children: JSON.stringify(tool.tool_args, null, 2) })
1272
+ ] }),
1273
+ tool.result != null && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-tool__section", children: [
1274
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-tool__label", children: "Result" }),
1275
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "agno-tool__pre", children: String(tool.result) })
1276
+ ] })
1277
+ ] })
1278
+ ] });
1279
+ }
1280
+ function ToolCalls({ tools }) {
1281
+ if (!tools || tools.length === 0) return null;
1282
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-tools", children: tools.map((tool, i) => /* @__PURE__ */ jsxRuntime.jsx(ToolCall, { tool }, tool.tool_call_id ?? `${tool.tool_name}-${i}`)) });
1283
+ }
1284
+ function statusDot(status) {
1285
+ if (status === "error") return "error";
1286
+ if (status === "completed") return "done";
1287
+ return "running";
1288
+ }
1289
+ function MemberCard({ member, renderMarkdown }) {
1290
+ const [open, setOpen] = react.useState(true);
1291
+ const label2 = member.kind === "executor" ? "Step executor" : "Member";
1292
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-member", children: [
1293
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "agno-member__head", onClick: () => setOpen((v) => !v), "aria-expanded": open, children: [
1294
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `agno-member__dot agno-member__dot--${statusDot(member.status)}`, "aria-hidden": true }),
1295
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-member__name", children: member.name ?? member.agent_id ?? label2 }),
1296
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-member__kind", children: label2 }),
1297
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-member__chev", children: open ? "\u25B2" : "\u25BC" })
1298
+ ] }),
1299
+ open && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-member__body", children: [
1300
+ /* @__PURE__ */ jsxRuntime.jsx(ToolCalls, { tools: member.tool_calls }),
1301
+ member.content && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-member__content", children: renderMarkdown ? renderMarkdown(member.content) : /* @__PURE__ */ jsxRuntime.jsx(Markdown, { content: member.content }) })
1302
+ ] })
1303
+ ] });
1304
+ }
1305
+ function MemberResponses({
1306
+ members,
1307
+ renderMarkdown,
1308
+ title = "Member responses"
1309
+ }) {
1310
+ if (!members || members.length === 0) return null;
1311
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-members", children: [
1312
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-members__title", children: [
1313
+ title,
1314
+ " (",
1315
+ members.length,
1316
+ ")"
1317
+ ] }),
1318
+ members.map((m) => /* @__PURE__ */ jsxRuntime.jsx(MemberCard, { member: m, renderMarkdown }, m.run_id))
1319
+ ] });
1320
+ }
1321
+ function audioSrc(a) {
1322
+ if (a.url) return a.url;
1323
+ if (a.base64_audio) return `data:${a.mime_type ?? "audio/mpeg"};base64,${a.base64_audio}`;
1324
+ if (a.content) return `data:${a.mime_type ?? "audio/wav"};base64,${a.content}`;
1325
+ return void 0;
1326
+ }
1327
+ function Multimedia({
1328
+ images,
1329
+ videos,
1330
+ audio,
1331
+ responseAudio
1332
+ }) {
1333
+ const audios = [...audio ?? [], ...responseAudio ? [responseAudio] : []];
1334
+ if (!images?.length && !videos?.length && !audios.length) return null;
1335
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-media", children: [
1336
+ images?.map(
1337
+ (img, i) => img.url ? /* @__PURE__ */ jsxRuntime.jsx("img", { className: "agno-media__img", src: img.url, alt: img.revised_prompt ?? "image" }, `img-${i}`) : null
1338
+ ),
1339
+ videos?.map(
1340
+ (v, i) => v.url ? /* @__PURE__ */ jsxRuntime.jsx("video", { className: "agno-media__video", src: v.url, controls: true }, `vid-${i}`) : null
1341
+ ),
1342
+ audios.map((a, i) => {
1343
+ const src = audioSrc(a);
1344
+ return src ? /* @__PURE__ */ jsxRuntime.jsx("audio", { className: "agno-media__audio", src, controls: true }, `aud-${i}`) : null;
1345
+ })
1346
+ ] });
1347
+ }
1348
+ function Reasoning({
1349
+ steps,
1350
+ defaultOpen = false
1351
+ }) {
1352
+ const [open, setOpen] = react.useState(defaultOpen);
1353
+ if (!steps || steps.length === 0) return null;
1354
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-reasoning", children: [
1355
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "agno-reasoning__toggle", onClick: () => setOpen((v) => !v), children: [
1356
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, children: "\u{1F4AD}" }),
1357
+ " Reasoning (",
1358
+ steps.length,
1359
+ " step",
1360
+ steps.length > 1 ? "s" : "",
1361
+ ")",
1362
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-reasoning__chev", children: open ? "\u25B2" : "\u25BC" })
1363
+ ] }),
1364
+ open && /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "agno-reasoning__list", children: steps.map((step, i) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "agno-reasoning__step", children: [
1365
+ step.title && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-reasoning__title", children: step.title }),
1366
+ step.reasoning && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-reasoning__text", children: step.reasoning }),
1367
+ step.action && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-reasoning__meta", children: [
1368
+ "Action: ",
1369
+ step.action
1370
+ ] }),
1371
+ step.result && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-reasoning__meta", children: [
1372
+ "Result: ",
1373
+ step.result
1374
+ ] }),
1375
+ typeof step.confidence === "number" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-reasoning__meta", children: [
1376
+ "Confidence: ",
1377
+ Math.round(step.confidence * 100),
1378
+ "%"
1379
+ ] })
1380
+ ] }, i)) })
1381
+ ] });
1382
+ }
1383
+ function StepRow({ step, renderMarkdown }) {
1384
+ const [open, setOpen] = react.useState(false);
1385
+ const hasBody = Boolean(step.content || step.error);
1386
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `agno-step agno-step--${step.status}`, children: [
1387
+ /* @__PURE__ */ jsxRuntime.jsxs(
1388
+ "button",
1389
+ {
1390
+ type: "button",
1391
+ className: "agno-step__head",
1392
+ onClick: () => hasBody && setOpen((v) => !v),
1393
+ "aria-expanded": open,
1394
+ children: [
1395
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `agno-step__icon agno-step__icon--${step.status}`, "aria-hidden": true, children: step.status === "completed" ? "\u2713" : step.status === "error" ? "!" : "\u25CF" }),
1396
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-step__name", children: step.name ?? step.key }),
1397
+ hasBody && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-step__chev", children: open ? "\u25B2" : "\u25BC" })
1398
+ ]
1399
+ }
1400
+ ),
1401
+ open && hasBody && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-step__body", children: step.error ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-step__error", children: step.error }) : step.content ? renderMarkdown ? renderMarkdown(step.content) : /* @__PURE__ */ jsxRuntime.jsx(Markdown, { content: step.content }) : null })
1402
+ ] });
1403
+ }
1404
+ function WorkflowSteps({
1405
+ steps,
1406
+ renderMarkdown,
1407
+ title = "Steps"
1408
+ }) {
1409
+ if (!steps || steps.length === 0) return null;
1410
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-steps", children: [
1411
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-steps__title", children: [
1412
+ title,
1413
+ " (",
1414
+ steps.length,
1415
+ ")"
1416
+ ] }),
1417
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-steps__list", children: steps.map((s) => /* @__PURE__ */ jsxRuntime.jsx(StepRow, { step: s, renderMarkdown }, s.key)) })
1418
+ ] });
1419
+ }
1420
+ function Message({ message, renderMarkdown, activity, hideReasoning, hideTools }) {
1421
+ const isUser = message.role === "user";
1422
+ const isAgent = message.role === "agent";
1423
+ const hasActivity = !message.content && !message.tool_calls?.length && !message.steps?.length && !message.members?.length && !message.reasoning_steps?.length;
1424
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `agno-msg agno-msg--${message.role}`, "data-status": message.status, children: [
1425
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-msg__avatar", "aria-hidden": true, children: isUser ? "\u{1F464}" : isAgent ? "A" : "\u2699" }),
1426
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-msg__body", children: [
1427
+ isAgent && !hideReasoning && /* @__PURE__ */ jsxRuntime.jsx(Reasoning, { steps: message.reasoning_steps }),
1428
+ isAgent && /* @__PURE__ */ jsxRuntime.jsx(WorkflowSteps, { steps: message.steps, renderMarkdown }),
1429
+ isAgent && /* @__PURE__ */ jsxRuntime.jsx(MemberResponses, { members: message.members, renderMarkdown }),
1430
+ isAgent && !hideTools && /* @__PURE__ */ jsxRuntime.jsx(ToolCalls, { tools: message.tool_calls }),
1431
+ message.content ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-msg__content", children: [
1432
+ renderMarkdown ? renderMarkdown(message.content) : /* @__PURE__ */ jsxRuntime.jsx(Markdown, { content: message.content }),
1433
+ message.streaming && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-msg__caret", "aria-hidden": true })
1434
+ ] }) : isAgent && message.streaming && hasActivity && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-msg__activity", role: "status", "aria-live": "polite", children: [
1435
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "agno-status__dots", "aria-hidden": true, children: [
1436
+ /* @__PURE__ */ jsxRuntime.jsx("span", {}),
1437
+ /* @__PURE__ */ jsxRuntime.jsx("span", {}),
1438
+ /* @__PURE__ */ jsxRuntime.jsx("span", {})
1439
+ ] }),
1440
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-msg__activity-label", children: activity ?? "Working" })
1441
+ ] }),
1442
+ /* @__PURE__ */ jsxRuntime.jsx(
1443
+ Multimedia,
1444
+ {
1445
+ images: message.images,
1446
+ videos: message.videos,
1447
+ audio: message.audio,
1448
+ responseAudio: message.response_audio
1449
+ }
1450
+ ),
1451
+ isAgent && /* @__PURE__ */ jsxRuntime.jsx(Citations, { references: message.references, citations: message.citations }),
1452
+ message.error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-msg__error", children: message.error })
1453
+ ] })
1454
+ ] });
1455
+ }
1456
+ function MessageList({
1457
+ messages,
1458
+ status,
1459
+ activity,
1460
+ renderMarkdown,
1461
+ emptyState,
1462
+ footer
1463
+ }) {
1464
+ const endRef = react.useRef(null);
1465
+ const stick = react.useRef(true);
1466
+ const containerRef = react.useRef(null);
1467
+ const onScroll = () => {
1468
+ const el = containerRef.current;
1469
+ if (!el) return;
1470
+ stick.current = el.scrollHeight - el.scrollTop - el.clientHeight < 80;
1471
+ };
1472
+ react.useEffect(() => {
1473
+ if (stick.current) endRef.current?.scrollIntoView({ behavior: "smooth", block: "end" });
1474
+ }, [messages, activity, status]);
1475
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-list", ref: containerRef, onScroll, children: [
1476
+ messages.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-list__empty", children: emptyState ?? "Start the conversation." }),
1477
+ messages.map((m) => /* @__PURE__ */ jsxRuntime.jsx(
1478
+ Message,
1479
+ {
1480
+ message: m,
1481
+ renderMarkdown,
1482
+ activity: m.streaming && status === "streaming" ? activity : void 0
1483
+ },
1484
+ m.id
1485
+ )),
1486
+ footer,
1487
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: endRef })
1488
+ ] });
1489
+ }
1490
+ function ChatWindow({
1491
+ chat,
1492
+ placeholder,
1493
+ emptyState,
1494
+ allowFiles,
1495
+ disabled,
1496
+ renderMarkdown,
1497
+ className
1498
+ }) {
1499
+ const pausedMessage = chat.isPaused ? [...chat.messages].reverse().find((m) => m.status === "paused") : void 0;
1500
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ["agno-chat", className].filter(Boolean).join(" "), children: [
1501
+ /* @__PURE__ */ jsxRuntime.jsx(
1502
+ MessageList,
1503
+ {
1504
+ messages: chat.messages,
1505
+ status: chat.status,
1506
+ activity: chat.activity,
1507
+ renderMarkdown,
1508
+ emptyState,
1509
+ footer: pausedMessage ? /* @__PURE__ */ jsxRuntime.jsx(
1510
+ HumanInput,
1511
+ {
1512
+ message: pausedMessage,
1513
+ entityType: chat.entityType,
1514
+ busy: chat.isStreaming,
1515
+ onResolve: chat.continueRun
1516
+ }
1517
+ ) : null
1518
+ }
1519
+ ),
1520
+ chat.error && !chat.isPaused && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-chat__error", children: chat.error }),
1521
+ /* @__PURE__ */ jsxRuntime.jsx(
1522
+ ChatInput,
1523
+ {
1524
+ onSend: (message, files) => chat.sendMessage(message, files ? { files } : void 0),
1525
+ onStop: chat.cancel,
1526
+ busy: chat.isStreaming,
1527
+ disabled: disabled || chat.isPaused,
1528
+ placeholder,
1529
+ allowFiles
1530
+ }
1531
+ )
1532
+ ] });
1533
+ }
1534
+ var TYPE_LABEL = {
1535
+ agent: "Agents",
1536
+ team: "Teams",
1537
+ workflow: "Workflows"
1538
+ };
1539
+ var ORDER = ["agent", "team", "workflow"];
1540
+ function EntitySelector({
1541
+ entities,
1542
+ value,
1543
+ onChange,
1544
+ disabled,
1545
+ placeholder = "Select an agent, team or workflow"
1546
+ }) {
1547
+ const [open, setOpen] = react.useState(false);
1548
+ const rootRef = react.useRef(null);
1549
+ const key = (e) => `${e.type}:${e.id}`;
1550
+ react.useEffect(() => {
1551
+ if (!open) return;
1552
+ const onDocClick = (e) => {
1553
+ if (rootRef.current && !rootRef.current.contains(e.target)) setOpen(false);
1554
+ };
1555
+ const onKey = (e) => {
1556
+ if (e.key === "Escape") setOpen(false);
1557
+ };
1558
+ document.addEventListener("mousedown", onDocClick);
1559
+ document.addEventListener("keydown", onKey);
1560
+ return () => {
1561
+ document.removeEventListener("mousedown", onDocClick);
1562
+ document.removeEventListener("keydown", onKey);
1563
+ };
1564
+ }, [open]);
1565
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-select", ref: rootRef, children: [
1566
+ /* @__PURE__ */ jsxRuntime.jsxs(
1567
+ "button",
1568
+ {
1569
+ type: "button",
1570
+ className: "agno-select__trigger",
1571
+ disabled,
1572
+ "aria-haspopup": "listbox",
1573
+ "aria-expanded": open,
1574
+ onClick: () => setOpen((v) => !v),
1575
+ children: [
1576
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-select__value", children: value ? value.name : placeholder }),
1577
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: `agno-select__chev ${open ? "is-open" : ""}`, "aria-hidden": true, children: "\u2304" })
1578
+ ]
1579
+ }
1580
+ ),
1581
+ open && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-select__panel", role: "listbox", children: [
1582
+ entities.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-select__empty", children: "Nothing available" }),
1583
+ ORDER.map((type) => {
1584
+ const items = entities.filter((e) => e.type === type);
1585
+ if (items.length === 0) return null;
1586
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-select__group", children: [
1587
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-select__group-label", children: TYPE_LABEL[type] }),
1588
+ items.map((ent) => {
1589
+ const selected = value ? key(value) === key(ent) : false;
1590
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1591
+ "button",
1592
+ {
1593
+ type: "button",
1594
+ role: "option",
1595
+ "aria-selected": selected,
1596
+ className: `agno-select__option ${selected ? "is-selected" : ""}`,
1597
+ onClick: () => {
1598
+ onChange(ent);
1599
+ setOpen(false);
1600
+ },
1601
+ children: [
1602
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-select__check", "aria-hidden": true, children: selected ? "\u2713" : "" }),
1603
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-select__label", children: ent.name }),
1604
+ ent.model?.model && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-select__model", children: ent.model.model })
1605
+ ]
1606
+ },
1607
+ key(ent)
1608
+ );
1609
+ })
1610
+ ] }, type);
1611
+ })
1612
+ ] })
1613
+ ] });
1614
+ }
1615
+ function sourceOf(e) {
1616
+ return e.agent_name || e.team_name || e.workflow_name || e.agent_id || e.team_id || e.workflow_id || void 0;
1617
+ }
1618
+ function fold(events) {
1619
+ const rows = [];
1620
+ for (const e of events) {
1621
+ const name2 = String(e.event);
1622
+ const source = sourceOf(e);
1623
+ const last = rows[rows.length - 1];
1624
+ if (last && last.event === name2 && last.source === source) {
1625
+ last.count += 1;
1626
+ last.created_at = e.created_at ?? last.created_at;
1627
+ continue;
1628
+ }
1629
+ rows.push({ event: name2, source, count: 1, created_at: e.created_at, detail: activityLabel(e) });
1630
+ }
1631
+ return rows;
1632
+ }
1633
+ function EventLog({
1634
+ events,
1635
+ autoScroll = true,
1636
+ maxHeight = 240
1637
+ }) {
1638
+ const ref = react.useRef(null);
1639
+ const rows = react.useMemo(() => fold(events), [events]);
1640
+ react.useEffect(() => {
1641
+ if (autoScroll && ref.current) ref.current.scrollTop = ref.current.scrollHeight;
1642
+ }, [rows, autoScroll]);
1643
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-eventlog", ref, style: { maxHeight }, children: [
1644
+ rows.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-eventlog__empty", children: "No events yet." }),
1645
+ rows.map((row, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-eventlog__row", children: [
1646
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-eventlog__name", children: row.event }),
1647
+ row.count > 1 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "agno-eventlog__count", children: [
1648
+ "\xD7",
1649
+ row.count
1650
+ ] }),
1651
+ row.source && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-eventlog__source", children: row.source }),
1652
+ row.created_at && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-eventlog__time", children: new Date(row.created_at * 1e3).toLocaleTimeString() })
1653
+ ] }, i))
1654
+ ] });
1655
+ }
1656
+ function label(session) {
1657
+ return session.session_name?.trim() || session.session_id;
1658
+ }
1659
+ function formatDate(value) {
1660
+ if (value == null) return "";
1661
+ let date;
1662
+ if (typeof value === "number") {
1663
+ date = new Date(value < 1e12 ? value * 1e3 : value);
1664
+ } else {
1665
+ date = new Date(value);
1666
+ }
1667
+ if (Number.isNaN(date.getTime())) return "";
1668
+ return date.toLocaleDateString();
1669
+ }
1670
+ function SessionList({
1671
+ sessions,
1672
+ activeSessionId,
1673
+ loading,
1674
+ onSelect,
1675
+ onDelete,
1676
+ onNew,
1677
+ title = "Sessions"
1678
+ }) {
1679
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-sessions", children: [
1680
+ onNew && /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "agno-sessions__new", onClick: onNew, "aria-label": "New chat", children: [
1681
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, children: "+" }),
1682
+ " New Chat"
1683
+ ] }),
1684
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-sessions__head", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-sessions__title", children: title }) }),
1685
+ loading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-sessions__empty", children: "Loading\u2026" }),
1686
+ !loading && sessions.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-sessions__empty", children: "No past sessions." }),
1687
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "agno-sessions__list", children: sessions.map((session) => /* @__PURE__ */ jsxRuntime.jsxs(
1688
+ "li",
1689
+ {
1690
+ className: `agno-sessions__item ${session.session_id === activeSessionId ? "is-active" : ""}`,
1691
+ children: [
1692
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "agno-sessions__select", onClick: () => onSelect(session.session_id), children: [
1693
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-sessions__name", children: label(session) }),
1694
+ formatDate(session.created_at) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-sessions__date", children: formatDate(session.created_at) })
1695
+ ] }),
1696
+ onDelete && /* @__PURE__ */ jsxRuntime.jsx(
1697
+ "button",
1698
+ {
1699
+ type: "button",
1700
+ className: "agno-sessions__delete",
1701
+ "aria-label": "Delete session",
1702
+ onClick: () => onDelete(session.session_id),
1703
+ children: "\u{1F5D1}"
1704
+ }
1705
+ )
1706
+ ]
1707
+ },
1708
+ session.session_id
1709
+ )) })
1710
+ ] });
1711
+ }
1712
+ function AgnoChat(props) {
1713
+ const client = react.useMemo(
1714
+ () => props.client ?? new AgnoClient({ baseUrl: props.baseUrl ?? "", headers: props.headers }),
1715
+ [props.client, props.baseUrl, props.headers]
1716
+ );
1717
+ const [discovered, setDiscovered] = react.useState(props.entities ?? []);
1718
+ const [selected, setSelected] = react.useState(props.entity ?? null);
1719
+ const [showLog, setShowLog] = react.useState(false);
1720
+ const [discoveryDone, setDiscoveryDone] = react.useState(Boolean(props.entity || props.entities));
1721
+ react.useEffect(() => {
1722
+ if (props.entity || props.entities) return;
1723
+ let cancelled = false;
1724
+ setDiscoveryDone(false);
1725
+ client.getEntities().then((list) => {
1726
+ if (cancelled) return;
1727
+ setDiscovered(list);
1728
+ setSelected((cur) => cur ?? list[0] ?? null);
1729
+ setDiscoveryDone(true);
1730
+ });
1731
+ return () => {
1732
+ cancelled = true;
1733
+ };
1734
+ }, [client, props.entity, props.entities]);
1735
+ const entity = props.entity ?? selected;
1736
+ const chat = useAgnoChat({ client, entity, userId: props.userId });
1737
+ const { refreshSessions } = chat;
1738
+ react.useEffect(() => {
1739
+ if (props.showSessions && entity) refreshSessions();
1740
+ }, [props.showSessions, entity?.type, entity?.id, refreshSessions]);
1741
+ react.useEffect(() => {
1742
+ if (props.showSessions && entity && chat.status === "completed") refreshSessions();
1743
+ }, [chat.status]);
1744
+ const onSelect = (e) => {
1745
+ setSelected(e);
1746
+ chat.reset();
1747
+ };
1748
+ const showSelector = !props.entity;
1749
+ const entities = props.entities ?? discovered;
1750
+ const noEntities = showSelector && discoveryDone && entities.length === 0;
1751
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1752
+ "div",
1753
+ {
1754
+ className: ["agno-root", props.className].filter(Boolean).join(" "),
1755
+ style: { height: props.height ?? 560 },
1756
+ children: [
1757
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-header", children: [
1758
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-header__brand", children: [
1759
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-logo", "aria-hidden": true, children: "A" }),
1760
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-header__title", children: props.title ?? entity?.name ?? "Agent UI" })
1761
+ ] }),
1762
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-header__controls", children: [
1763
+ showSelector && /* @__PURE__ */ jsxRuntime.jsx(EntitySelector, { entities, value: entity, onChange: onSelect, disabled: chat.isStreaming }),
1764
+ props.showEventLog && /* @__PURE__ */ jsxRuntime.jsx(
1765
+ "button",
1766
+ {
1767
+ type: "button",
1768
+ className: `agno-btn agno-btn--ghost ${showLog ? "is-active" : ""}`,
1769
+ onClick: () => setShowLog((v) => !v),
1770
+ children: "Events"
1771
+ }
1772
+ ),
1773
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "agno-btn agno-btn--ghost", onClick: chat.reset, disabled: chat.isStreaming, children: "New chat" })
1774
+ ] })
1775
+ ] }),
1776
+ noEntities && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-banner", children: [
1777
+ "No agents, teams or workflows found at ",
1778
+ /* @__PURE__ */ jsxRuntime.jsx("code", { children: client.baseUrl || "(no URL)" }),
1779
+ ". Check the URL is correct, that AgentOS is running, and that this origin is in its CORS allowlist (",
1780
+ /* @__PURE__ */ jsxRuntime.jsx("code", { children: "cors_allowed_origins" }),
1781
+ ")."
1782
+ ] }),
1783
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-main", children: [
1784
+ props.showSessions && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-sidebar agno-sidebar--left", children: /* @__PURE__ */ jsxRuntime.jsx(
1785
+ SessionList,
1786
+ {
1787
+ sessions: chat.sessions,
1788
+ activeSessionId: chat.sessionId,
1789
+ loading: chat.sessionsLoading,
1790
+ onSelect: chat.loadSession,
1791
+ onDelete: chat.deleteSession,
1792
+ onNew: chat.reset
1793
+ }
1794
+ ) }),
1795
+ /* @__PURE__ */ jsxRuntime.jsx(
1796
+ ChatWindow,
1797
+ {
1798
+ chat,
1799
+ placeholder: props.placeholder,
1800
+ allowFiles: props.allowFiles,
1801
+ disabled: !entity,
1802
+ renderMarkdown: props.renderMarkdown,
1803
+ emptyState: entity ? `Chat with ${entity.name}.` : "Select an agent, team or workflow to begin."
1804
+ }
1805
+ ),
1806
+ props.showEventLog && showLog && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "agno-sidebar", children: [
1807
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "agno-sidebar__title", children: "Event stream" }),
1808
+ /* @__PURE__ */ jsxRuntime.jsx(EventLog, { events: chat.events })
1809
+ ] })
1810
+ ] })
1811
+ ]
1812
+ }
1813
+ );
1814
+ }
1815
+ function StatusIndicator({
1816
+ status,
1817
+ activity
1818
+ }) {
1819
+ if (status !== "streaming" && status !== "paused") return null;
1820
+ const label2 = activity ?? (status === "paused" ? "Waiting for input" : "Working");
1821
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `agno-status agno-status--${status}`, role: "status", "aria-live": "polite", children: [
1822
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "agno-status__dots", "aria-hidden": true, children: [
1823
+ /* @__PURE__ */ jsxRuntime.jsx("span", {}),
1824
+ /* @__PURE__ */ jsxRuntime.jsx("span", {}),
1825
+ /* @__PURE__ */ jsxRuntime.jsx("span", {})
1826
+ ] }),
1827
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "agno-status__label", children: label2 })
1828
+ ] });
1829
+ }
1830
+
1831
+ // src/types.ts
1832
+ var RunEvent = /* @__PURE__ */ ((RunEvent2) => {
1833
+ RunEvent2["RunStarted"] = "RunStarted";
1834
+ RunEvent2["RunContent"] = "RunContent";
1835
+ RunEvent2["RunContentCompleted"] = "RunContentCompleted";
1836
+ RunEvent2["RunIntermediateContent"] = "RunIntermediateContent";
1837
+ RunEvent2["RunCompleted"] = "RunCompleted";
1838
+ RunEvent2["RunError"] = "RunError";
1839
+ RunEvent2["RunCancelled"] = "RunCancelled";
1840
+ RunEvent2["RunPaused"] = "RunPaused";
1841
+ RunEvent2["RunContinued"] = "RunContinued";
1842
+ RunEvent2["PreHookStarted"] = "PreHookStarted";
1843
+ RunEvent2["PreHookCompleted"] = "PreHookCompleted";
1844
+ RunEvent2["PostHookStarted"] = "PostHookStarted";
1845
+ RunEvent2["PostHookCompleted"] = "PostHookCompleted";
1846
+ RunEvent2["ToolCallStarted"] = "ToolCallStarted";
1847
+ RunEvent2["ToolCallCompleted"] = "ToolCallCompleted";
1848
+ RunEvent2["ToolCallError"] = "ToolCallError";
1849
+ RunEvent2["ReasoningStarted"] = "ReasoningStarted";
1850
+ RunEvent2["ReasoningStep"] = "ReasoningStep";
1851
+ RunEvent2["ReasoningContentDelta"] = "ReasoningContentDelta";
1852
+ RunEvent2["ReasoningCompleted"] = "ReasoningCompleted";
1853
+ RunEvent2["MemoryUpdateStarted"] = "MemoryUpdateStarted";
1854
+ RunEvent2["MemoryUpdateCompleted"] = "MemoryUpdateCompleted";
1855
+ RunEvent2["SessionSummaryStarted"] = "SessionSummaryStarted";
1856
+ RunEvent2["SessionSummaryCompleted"] = "SessionSummaryCompleted";
1857
+ RunEvent2["ParserModelResponseStarted"] = "ParserModelResponseStarted";
1858
+ RunEvent2["ParserModelResponseCompleted"] = "ParserModelResponseCompleted";
1859
+ RunEvent2["OutputModelResponseStarted"] = "OutputModelResponseStarted";
1860
+ RunEvent2["OutputModelResponseCompleted"] = "OutputModelResponseCompleted";
1861
+ RunEvent2["ModelRequestStarted"] = "ModelRequestStarted";
1862
+ RunEvent2["ModelRequestCompleted"] = "ModelRequestCompleted";
1863
+ RunEvent2["CompressionStarted"] = "CompressionStarted";
1864
+ RunEvent2["CompressionCompleted"] = "CompressionCompleted";
1865
+ RunEvent2["FollowupsStarted"] = "FollowupsStarted";
1866
+ RunEvent2["FollowupsCompleted"] = "FollowupsCompleted";
1867
+ RunEvent2["CustomEvent"] = "CustomEvent";
1868
+ return RunEvent2;
1869
+ })(RunEvent || {});
1870
+ var TeamRunEvent = /* @__PURE__ */ ((TeamRunEvent2) => {
1871
+ TeamRunEvent2["TeamRunStarted"] = "TeamRunStarted";
1872
+ TeamRunEvent2["TeamRunContent"] = "TeamRunContent";
1873
+ TeamRunEvent2["TeamRunIntermediateContent"] = "TeamRunIntermediateContent";
1874
+ TeamRunEvent2["TeamRunContentCompleted"] = "TeamRunContentCompleted";
1875
+ TeamRunEvent2["TeamRunCompleted"] = "TeamRunCompleted";
1876
+ TeamRunEvent2["TeamRunError"] = "TeamRunError";
1877
+ TeamRunEvent2["TeamRunCancelled"] = "TeamRunCancelled";
1878
+ TeamRunEvent2["TeamRunPaused"] = "TeamRunPaused";
1879
+ TeamRunEvent2["TeamRunContinued"] = "TeamRunContinued";
1880
+ TeamRunEvent2["TeamToolCallStarted"] = "TeamToolCallStarted";
1881
+ TeamRunEvent2["TeamToolCallCompleted"] = "TeamToolCallCompleted";
1882
+ TeamRunEvent2["TeamToolCallError"] = "TeamToolCallError";
1883
+ TeamRunEvent2["TeamReasoningStarted"] = "TeamReasoningStarted";
1884
+ TeamRunEvent2["TeamReasoningStep"] = "TeamReasoningStep";
1885
+ TeamRunEvent2["TeamReasoningContentDelta"] = "TeamReasoningContentDelta";
1886
+ TeamRunEvent2["TeamReasoningCompleted"] = "TeamReasoningCompleted";
1887
+ TeamRunEvent2["TeamMemoryUpdateStarted"] = "TeamMemoryUpdateStarted";
1888
+ TeamRunEvent2["TeamMemoryUpdateCompleted"] = "TeamMemoryUpdateCompleted";
1889
+ TeamRunEvent2["TeamTaskIterationStarted"] = "TeamTaskIterationStarted";
1890
+ TeamRunEvent2["TeamTaskIterationCompleted"] = "TeamTaskIterationCompleted";
1891
+ TeamRunEvent2["TeamTaskStateUpdated"] = "TeamTaskStateUpdated";
1892
+ TeamRunEvent2["TeamTaskCreated"] = "TeamTaskCreated";
1893
+ TeamRunEvent2["TeamTaskUpdated"] = "TeamTaskUpdated";
1894
+ return TeamRunEvent2;
1895
+ })(TeamRunEvent || {});
1896
+ var WorkflowRunEvent = /* @__PURE__ */ ((WorkflowRunEvent2) => {
1897
+ WorkflowRunEvent2["WorkflowStarted"] = "WorkflowStarted";
1898
+ WorkflowRunEvent2["WorkflowCompleted"] = "WorkflowCompleted";
1899
+ WorkflowRunEvent2["WorkflowPaused"] = "WorkflowPaused";
1900
+ WorkflowRunEvent2["WorkflowCancelled"] = "WorkflowCancelled";
1901
+ WorkflowRunEvent2["WorkflowError"] = "WorkflowError";
1902
+ WorkflowRunEvent2["WorkflowAgentStarted"] = "WorkflowAgentStarted";
1903
+ WorkflowRunEvent2["WorkflowAgentCompleted"] = "WorkflowAgentCompleted";
1904
+ WorkflowRunEvent2["StepStarted"] = "StepStarted";
1905
+ WorkflowRunEvent2["StepCompleted"] = "StepCompleted";
1906
+ WorkflowRunEvent2["StepPaused"] = "StepPaused";
1907
+ WorkflowRunEvent2["StepContinued"] = "StepContinued";
1908
+ WorkflowRunEvent2["StepError"] = "StepError";
1909
+ WorkflowRunEvent2["StepOutput"] = "StepOutput";
1910
+ WorkflowRunEvent2["StepOutputReview"] = "StepOutputReview";
1911
+ WorkflowRunEvent2["LoopExecutionStarted"] = "LoopExecutionStarted";
1912
+ WorkflowRunEvent2["LoopIterationStarted"] = "LoopIterationStarted";
1913
+ WorkflowRunEvent2["LoopIterationCompleted"] = "LoopIterationCompleted";
1914
+ WorkflowRunEvent2["LoopExecutionCompleted"] = "LoopExecutionCompleted";
1915
+ WorkflowRunEvent2["ParallelExecutionStarted"] = "ParallelExecutionStarted";
1916
+ WorkflowRunEvent2["ParallelExecutionCompleted"] = "ParallelExecutionCompleted";
1917
+ WorkflowRunEvent2["ConditionExecutionStarted"] = "ConditionExecutionStarted";
1918
+ WorkflowRunEvent2["ConditionExecutionCompleted"] = "ConditionExecutionCompleted";
1919
+ WorkflowRunEvent2["ConditionPaused"] = "ConditionPaused";
1920
+ WorkflowRunEvent2["RouterExecutionStarted"] = "RouterExecutionStarted";
1921
+ WorkflowRunEvent2["RouterExecutionCompleted"] = "RouterExecutionCompleted";
1922
+ WorkflowRunEvent2["RouterPaused"] = "RouterPaused";
1923
+ WorkflowRunEvent2["StepsExecutionStarted"] = "StepsExecutionStarted";
1924
+ WorkflowRunEvent2["StepsExecutionCompleted"] = "StepsExecutionCompleted";
1925
+ return WorkflowRunEvent2;
1926
+ })(WorkflowRunEvent || {});
1927
+
1928
+ exports.AgnoChat = AgnoChat;
1929
+ exports.AgnoClient = AgnoClient;
1930
+ exports.ChatInput = ChatInput;
1931
+ exports.ChatWindow = ChatWindow;
1932
+ exports.Citations = Citations;
1933
+ exports.EntitySelector = EntitySelector;
1934
+ exports.EventLog = EventLog;
1935
+ exports.HumanInput = HumanInput;
1936
+ exports.Markdown = Markdown;
1937
+ exports.MemberResponses = MemberResponses;
1938
+ exports.Message = Message;
1939
+ exports.MessageList = MessageList;
1940
+ exports.Multimedia = Multimedia;
1941
+ exports.Reasoning = Reasoning;
1942
+ exports.RunEvent = RunEvent;
1943
+ exports.SessionList = SessionList;
1944
+ exports.StatusIndicator = StatusIndicator;
1945
+ exports.TeamRunEvent = TeamRunEvent;
1946
+ exports.ToolCalls = ToolCalls;
1947
+ exports.WorkflowRunEvent = WorkflowRunEvent;
1948
+ exports.WorkflowSteps = WorkflowSteps;
1949
+ exports.activityLabel = activityLabel;
1950
+ exports.applyStepEvent = applyStepEvent;
1951
+ exports.applySubRunEvent = applySubRunEvent;
1952
+ exports.isCompletedEvent = isCompletedEvent;
1953
+ exports.isContentEvent = isContentEvent;
1954
+ exports.isErrorEvent = isErrorEvent;
1955
+ exports.isPausedEvent = isPausedEvent;
1956
+ exports.isReasoningStepEvent = isReasoningStepEvent;
1957
+ exports.isStepEvent = isStepEvent;
1958
+ exports.isSubRunEvent = isSubRunEvent;
1959
+ exports.isToolEvent = isToolEvent;
1960
+ exports.mergeTool = mergeTool;
1961
+ exports.normaliseBaseUrl = normaliseBaseUrl;
1962
+ exports.sessionRunsToMessages = sessionRunsToMessages;
1963
+ exports.streamRun = streamRun;
1964
+ exports.toolsFromEvent = toolsFromEvent;
1965
+ exports.useAgnoChat = useAgnoChat;
1966
+ //# sourceMappingURL=index.cjs.map
1967
+ //# sourceMappingURL=index.cjs.map