@agno-hq/chat-react 0.1.1 → 0.3.1

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.
@@ -0,0 +1,413 @@
1
+ /**
2
+ * Types for AgentOS run events, messages, and entities.
3
+ *
4
+ * These mirror the wire format emitted by Agno's AgentOS when streaming a run
5
+ * for an agent, team, or workflow. Field names match the JSON sent on the wire.
6
+ */
7
+ /** Agent run event names. */
8
+ declare enum RunEvent {
9
+ RunStarted = "RunStarted",
10
+ RunContent = "RunContent",
11
+ RunContentCompleted = "RunContentCompleted",
12
+ RunIntermediateContent = "RunIntermediateContent",
13
+ RunCompleted = "RunCompleted",
14
+ RunError = "RunError",
15
+ RunCancelled = "RunCancelled",
16
+ RunPaused = "RunPaused",
17
+ RunContinued = "RunContinued",
18
+ PreHookStarted = "PreHookStarted",
19
+ PreHookCompleted = "PreHookCompleted",
20
+ PostHookStarted = "PostHookStarted",
21
+ PostHookCompleted = "PostHookCompleted",
22
+ ToolCallStarted = "ToolCallStarted",
23
+ ToolCallCompleted = "ToolCallCompleted",
24
+ ToolCallError = "ToolCallError",
25
+ ReasoningStarted = "ReasoningStarted",
26
+ ReasoningStep = "ReasoningStep",
27
+ ReasoningContentDelta = "ReasoningContentDelta",
28
+ ReasoningCompleted = "ReasoningCompleted",
29
+ MemoryUpdateStarted = "MemoryUpdateStarted",
30
+ MemoryUpdateCompleted = "MemoryUpdateCompleted",
31
+ SessionSummaryStarted = "SessionSummaryStarted",
32
+ SessionSummaryCompleted = "SessionSummaryCompleted",
33
+ ParserModelResponseStarted = "ParserModelResponseStarted",
34
+ ParserModelResponseCompleted = "ParserModelResponseCompleted",
35
+ OutputModelResponseStarted = "OutputModelResponseStarted",
36
+ OutputModelResponseCompleted = "OutputModelResponseCompleted",
37
+ ModelRequestStarted = "ModelRequestStarted",
38
+ ModelRequestCompleted = "ModelRequestCompleted",
39
+ CompressionStarted = "CompressionStarted",
40
+ CompressionCompleted = "CompressionCompleted",
41
+ FollowupsStarted = "FollowupsStarted",
42
+ FollowupsCompleted = "FollowupsCompleted",
43
+ CustomEvent = "CustomEvent"
44
+ }
45
+ /** Team run event names. */
46
+ declare enum TeamRunEvent {
47
+ TeamRunStarted = "TeamRunStarted",
48
+ TeamRunContent = "TeamRunContent",
49
+ TeamRunIntermediateContent = "TeamRunIntermediateContent",
50
+ TeamRunContentCompleted = "TeamRunContentCompleted",
51
+ TeamRunCompleted = "TeamRunCompleted",
52
+ TeamRunError = "TeamRunError",
53
+ TeamRunCancelled = "TeamRunCancelled",
54
+ TeamRunPaused = "TeamRunPaused",
55
+ TeamRunContinued = "TeamRunContinued",
56
+ TeamToolCallStarted = "TeamToolCallStarted",
57
+ TeamToolCallCompleted = "TeamToolCallCompleted",
58
+ TeamToolCallError = "TeamToolCallError",
59
+ TeamReasoningStarted = "TeamReasoningStarted",
60
+ TeamReasoningStep = "TeamReasoningStep",
61
+ TeamReasoningContentDelta = "TeamReasoningContentDelta",
62
+ TeamReasoningCompleted = "TeamReasoningCompleted",
63
+ TeamMemoryUpdateStarted = "TeamMemoryUpdateStarted",
64
+ TeamMemoryUpdateCompleted = "TeamMemoryUpdateCompleted",
65
+ TeamFollowupsStarted = "TeamFollowupsStarted",
66
+ TeamFollowupsCompleted = "TeamFollowupsCompleted",
67
+ TeamTaskIterationStarted = "TeamTaskIterationStarted",
68
+ TeamTaskIterationCompleted = "TeamTaskIterationCompleted",
69
+ TeamTaskStateUpdated = "TeamTaskStateUpdated",
70
+ TeamTaskCreated = "TeamTaskCreated",
71
+ TeamTaskUpdated = "TeamTaskUpdated"
72
+ }
73
+ /** Workflow run event names. */
74
+ declare enum WorkflowRunEvent {
75
+ WorkflowStarted = "WorkflowStarted",
76
+ WorkflowCompleted = "WorkflowCompleted",
77
+ WorkflowPaused = "WorkflowPaused",
78
+ WorkflowCancelled = "WorkflowCancelled",
79
+ WorkflowError = "WorkflowError",
80
+ WorkflowAgentStarted = "WorkflowAgentStarted",
81
+ WorkflowAgentCompleted = "WorkflowAgentCompleted",
82
+ StepStarted = "StepStarted",
83
+ StepCompleted = "StepCompleted",
84
+ StepPaused = "StepPaused",
85
+ StepContinued = "StepContinued",
86
+ StepError = "StepError",
87
+ StepOutput = "StepOutput",
88
+ StepOutputReview = "StepOutputReview",
89
+ LoopExecutionStarted = "LoopExecutionStarted",
90
+ LoopIterationStarted = "LoopIterationStarted",
91
+ LoopIterationCompleted = "LoopIterationCompleted",
92
+ LoopExecutionCompleted = "LoopExecutionCompleted",
93
+ ParallelExecutionStarted = "ParallelExecutionStarted",
94
+ ParallelExecutionCompleted = "ParallelExecutionCompleted",
95
+ ConditionExecutionStarted = "ConditionExecutionStarted",
96
+ ConditionExecutionCompleted = "ConditionExecutionCompleted",
97
+ ConditionPaused = "ConditionPaused",
98
+ RouterExecutionStarted = "RouterExecutionStarted",
99
+ RouterExecutionCompleted = "RouterExecutionCompleted",
100
+ RouterPaused = "RouterPaused",
101
+ StepsExecutionStarted = "StepsExecutionStarted",
102
+ StepsExecutionCompleted = "StepsExecutionCompleted"
103
+ }
104
+ /** Any run event name, across agents, teams and workflows. */
105
+ type AnyRunEventName = RunEvent | TeamRunEvent | WorkflowRunEvent | string;
106
+ interface UserInputField {
107
+ name: string;
108
+ field_type?: string;
109
+ description?: string;
110
+ value?: unknown;
111
+ }
112
+ interface ToolExecution {
113
+ tool_call_id?: string;
114
+ tool_name?: string;
115
+ tool_args?: Record<string, unknown>;
116
+ tool_call_error?: boolean;
117
+ result?: string;
118
+ metrics?: {
119
+ time?: number;
120
+ };
121
+ created_at?: number;
122
+ stop_after_tool_call?: boolean;
123
+ requires_confirmation?: boolean;
124
+ confirmed?: boolean;
125
+ confirmation_note?: string;
126
+ requires_user_input?: boolean;
127
+ user_input_schema?: UserInputField[];
128
+ answered?: boolean;
129
+ external_execution_required?: boolean;
130
+ role?: string;
131
+ content?: string | null;
132
+ }
133
+ interface ReasoningStep {
134
+ title?: string;
135
+ action?: string;
136
+ result?: string;
137
+ reasoning?: string;
138
+ confidence?: number;
139
+ next_action?: string;
140
+ }
141
+ interface Reference {
142
+ content: string;
143
+ name?: string;
144
+ meta_data?: Record<string, unknown>;
145
+ }
146
+ interface ReferenceData {
147
+ query: string;
148
+ references: Reference[];
149
+ time?: number;
150
+ }
151
+ interface ImageData {
152
+ url?: string;
153
+ revised_prompt?: string;
154
+ content?: string;
155
+ }
156
+ interface VideoData {
157
+ id?: number | string;
158
+ url?: string;
159
+ eta?: number;
160
+ }
161
+ interface AudioData {
162
+ id?: string;
163
+ url?: string;
164
+ base64_audio?: string;
165
+ mime_type?: string;
166
+ content?: string;
167
+ transcript?: string;
168
+ channels?: number;
169
+ sample_rate?: number;
170
+ }
171
+ interface Citations {
172
+ raw?: unknown;
173
+ urls?: Array<{
174
+ url?: string;
175
+ title?: string;
176
+ }>;
177
+ }
178
+ /**
179
+ * A single run event off the wire, normalised to a flat object. The `event`
180
+ * field is the discriminator; other fields depend on the event type. This is a
181
+ * permissive superset — most fields are optional and present only for the
182
+ * events that carry them.
183
+ */
184
+ interface RunEventData {
185
+ event: AnyRunEventName;
186
+ created_at?: number;
187
+ run_id?: string;
188
+ parent_run_id?: string;
189
+ session_id?: string;
190
+ agent_id?: string;
191
+ agent_name?: string;
192
+ team_id?: string;
193
+ team_name?: string;
194
+ workflow_id?: string;
195
+ workflow_name?: string;
196
+ content?: string | object | null;
197
+ content_type?: string;
198
+ reasoning_content?: string;
199
+ tool?: ToolExecution;
200
+ tools?: ToolExecution[];
201
+ reasoning_steps?: ReasoningStep[];
202
+ references?: ReferenceData[];
203
+ citations?: Citations;
204
+ /** `FollowupsCompleted`: the suggested next prompts. */
205
+ followups?: string[];
206
+ images?: ImageData[];
207
+ videos?: VideoData[];
208
+ audio?: AudioData[];
209
+ response_audio?: AudioData;
210
+ step_name?: string;
211
+ step_index?: number | [number, number];
212
+ iteration?: number;
213
+ max_iterations?: number;
214
+ requirements?: RunRequirement[];
215
+ requires_confirmation?: boolean;
216
+ confirmation_message?: string;
217
+ requires_user_input?: boolean;
218
+ user_input_message?: string;
219
+ user_input_schema?: UserInputField[];
220
+ available_choices?: string[];
221
+ allow_multiple_selections?: boolean;
222
+ error?: string;
223
+ error_type?: string;
224
+ model?: string;
225
+ model_provider?: string;
226
+ input_tokens?: number;
227
+ output_tokens?: number;
228
+ total_tokens?: number;
229
+ metrics?: Record<string, unknown>;
230
+ extra_data?: {
231
+ reasoning_steps?: ReasoningStep[];
232
+ references?: ReferenceData[];
233
+ };
234
+ [key: string]: unknown;
235
+ }
236
+ type PauseType = 'confirmation' | 'user_input' | 'user_feedback' | 'external_execution';
237
+ interface RunRequirement {
238
+ id: string;
239
+ tool_execution?: ToolExecution;
240
+ confirmation?: boolean;
241
+ confirmation_note?: string;
242
+ user_input_schema?: UserInputField[];
243
+ external_execution_result?: string;
244
+ member_agent_id?: string;
245
+ member_agent_name?: string;
246
+ pause_type?: PauseType;
247
+ }
248
+ type ChatRole = 'user' | 'agent' | 'system';
249
+ type ChatStatus = 'idle' | 'streaming' | 'paused' | 'completed' | 'error' | 'cancelled';
250
+ type SubRunStatus = 'running' | 'completed' | 'error';
251
+ /**
252
+ * A nested run inside a team or workflow run — a team member's turn, or the
253
+ * agent/team that executes a workflow step. Accumulated from events that carry
254
+ * a `parent_run_id`.
255
+ */
256
+ interface SubRun {
257
+ run_id: string;
258
+ kind: 'member' | 'executor';
259
+ name?: string;
260
+ agent_id?: string;
261
+ content: string;
262
+ tool_calls?: ToolExecution[];
263
+ status: SubRunStatus;
264
+ }
265
+ /** A workflow step and its output, accumulated from `Step*` events. */
266
+ interface WorkflowStep {
267
+ key: string;
268
+ name?: string;
269
+ index?: number | [number, number];
270
+ status: SubRunStatus;
271
+ content?: string;
272
+ error?: string;
273
+ }
274
+ interface ChatMessage {
275
+ id: string;
276
+ role: ChatRole;
277
+ content: string;
278
+ created_at: number;
279
+ /** Set while this message is being streamed. */
280
+ streaming?: boolean;
281
+ /** Run-level status, set for agent messages. */
282
+ status?: ChatStatus;
283
+ error?: string;
284
+ run_id?: string;
285
+ session_id?: string;
286
+ tool_calls?: ToolExecution[];
287
+ reasoning_steps?: ReasoningStep[];
288
+ references?: ReferenceData[];
289
+ citations?: Citations;
290
+ /**
291
+ * Suggested next prompts, when the agent was built with `followups=True`.
292
+ * Rendered under the latest answer as "Related questions".
293
+ */
294
+ followups?: string[];
295
+ images?: ImageData[];
296
+ videos?: VideoData[];
297
+ audio?: AudioData[];
298
+ response_audio?: AudioData;
299
+ /** Live "what is it doing right now" label, e.g. "Calling get_weather". */
300
+ activity?: string;
301
+ /** Pause requirements when the run is waiting for a human. */
302
+ requirements?: RunRequirement[];
303
+ /** Team member turns / workflow step executors (nested runs). */
304
+ members?: SubRun[];
305
+ /** Workflow steps and their outputs. */
306
+ steps?: WorkflowStep[];
307
+ /** Every raw event that contributed to this message, in order. */
308
+ events?: RunEventData[];
309
+ }
310
+ interface Model {
311
+ name?: string;
312
+ model?: string;
313
+ provider?: string;
314
+ }
315
+ type EntityType = 'agent' | 'team' | 'workflow';
316
+ interface Entity {
317
+ type: EntityType;
318
+ id: string;
319
+ name: string;
320
+ description?: string;
321
+ model?: Model;
322
+ db_id?: string;
323
+ }
324
+ interface SessionEntry {
325
+ session_id: string;
326
+ session_name?: string;
327
+ /** Unix seconds, Unix milliseconds, or an ISO date string, depending on the backend. */
328
+ created_at: number | string;
329
+ updated_at?: number | string;
330
+ }
331
+ interface Pagination {
332
+ page: number;
333
+ limit: number;
334
+ total_pages: number;
335
+ total_count: number;
336
+ }
337
+ interface SessionsResponse {
338
+ data: SessionEntry[];
339
+ meta?: Pagination;
340
+ }
341
+
342
+ /**
343
+ * Thin client for an AgentOS HTTP backend.
344
+ *
345
+ * Wraps the discovery, run, continue, cancel and session endpoints. Streaming
346
+ * runs are handled by `streamRun` from ./stream; everything else is plain JSON.
347
+ */
348
+
349
+ /** Normalise a base URL: add a scheme for bare hosts, strip trailing slash. */
350
+ declare function normaliseBaseUrl(value: string | null | undefined): string;
351
+ interface AgnoClientOptions {
352
+ /** AgentOS base URL, e.g. "http://localhost:7777". */
353
+ baseUrl: string;
354
+ /** Optional headers (e.g. Authorization) added to every request. */
355
+ headers?: Record<string, string>;
356
+ /** Default db_id used for session listing where the backend requires it. */
357
+ dbId?: string;
358
+ }
359
+ interface RunArgs {
360
+ type: EntityType;
361
+ id: string;
362
+ message?: string;
363
+ sessionId?: string;
364
+ userId?: string;
365
+ files?: File[];
366
+ /** Extra form fields appended verbatim. */
367
+ extra?: Record<string, string>;
368
+ signal?: AbortSignal;
369
+ onEvent: (event: RunEventData) => void;
370
+ onError: (error: Error) => void;
371
+ onComplete: () => void;
372
+ }
373
+ interface ContinueArgs {
374
+ type: EntityType;
375
+ id: string;
376
+ runId: string;
377
+ sessionId?: string;
378
+ userId?: string;
379
+ /** Resolved tool executions (agents/teams human-in-the-loop). */
380
+ tools?: ToolExecution[];
381
+ /** Resolved step requirements (workflow human-in-the-loop). */
382
+ stepRequirements?: unknown[];
383
+ signal?: AbortSignal;
384
+ onEvent: (event: RunEventData) => void;
385
+ onError: (error: Error) => void;
386
+ onComplete: () => void;
387
+ }
388
+ declare class AgnoClient {
389
+ readonly baseUrl: string;
390
+ readonly headers: Record<string, string>;
391
+ readonly dbId?: string;
392
+ constructor(options: AgnoClientOptions);
393
+ private getJson;
394
+ /** Liveness check against /health. Returns the HTTP status code. */
395
+ health(): Promise<number>;
396
+ getAgents(): Promise<Entity[]>;
397
+ getTeams(): Promise<Entity[]>;
398
+ getWorkflows(): Promise<Entity[]>;
399
+ /** All runnable entities (agents, teams, workflows) in one list. */
400
+ getEntities(): Promise<Entity[]>;
401
+ getSessions(type: EntityType, componentId: string, dbId?: string): Promise<SessionsResponse>;
402
+ /** Runs (with messages/tools/events) for a session — used to rehydrate chat history. */
403
+ getSessionRuns(type: EntityType, sessionId: string, dbId?: string): Promise<any[]>;
404
+ deleteSession(sessionId: string, dbId?: string): Promise<boolean>;
405
+ /** Start a streaming run for an agent, team or workflow. */
406
+ run(args: RunArgs): Promise<void>;
407
+ /** Continue a paused run (resolving a human-in-the-loop requirement). */
408
+ continueRun(args: ContinueArgs): Promise<void>;
409
+ /** Cancel an in-flight run. */
410
+ cancelRun(type: EntityType, id: string, runId: string, sessionId?: string): Promise<boolean>;
411
+ }
412
+
413
+ export { AgnoClient as A, type ChatMessage as C, type Entity as E, type ImageData as I, type Model as M, type Pagination as P, type ReasoningStep as R, type SessionEntry as S, TeamRunEvent as T, type UserInputField as U, type VideoData as V, WorkflowRunEvent as W, type AgnoClientOptions as a, type AnyRunEventName as b, type AudioData as c, type ChatRole as d, type ChatStatus as e, type Citations as f, type EntityType as g, type PauseType as h, type Reference as i, type ReferenceData as j, RunEvent as k, type RunEventData as l, type RunRequirement as m, type SessionsResponse as n, type SubRun as o, type SubRunStatus as p, type ToolExecution as q, type WorkflowStep as r, normaliseBaseUrl as s };
@@ -0,0 +1,94 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ var chunk2WM3CCFE_cjs = require('../chunk-2WM3CCFE.cjs');
5
+ var chunk55HQJGLP_cjs = require('../chunk-55HQJGLP.cjs');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, "RunEvent", {
10
+ enumerable: true,
11
+ get: function () { return chunk2WM3CCFE_cjs.RunEvent; }
12
+ });
13
+ Object.defineProperty(exports, "TeamRunEvent", {
14
+ enumerable: true,
15
+ get: function () { return chunk2WM3CCFE_cjs.TeamRunEvent; }
16
+ });
17
+ Object.defineProperty(exports, "WorkflowRunEvent", {
18
+ enumerable: true,
19
+ get: function () { return chunk2WM3CCFE_cjs.WorkflowRunEvent; }
20
+ });
21
+ Object.defineProperty(exports, "AgnoClient", {
22
+ enumerable: true,
23
+ get: function () { return chunk55HQJGLP_cjs.AgnoClient; }
24
+ });
25
+ Object.defineProperty(exports, "activityLabel", {
26
+ enumerable: true,
27
+ get: function () { return chunk55HQJGLP_cjs.activityLabel; }
28
+ });
29
+ Object.defineProperty(exports, "applyStepEvent", {
30
+ enumerable: true,
31
+ get: function () { return chunk55HQJGLP_cjs.applyStepEvent; }
32
+ });
33
+ Object.defineProperty(exports, "applySubRunEvent", {
34
+ enumerable: true,
35
+ get: function () { return chunk55HQJGLP_cjs.applySubRunEvent; }
36
+ });
37
+ Object.defineProperty(exports, "isCompletedEvent", {
38
+ enumerable: true,
39
+ get: function () { return chunk55HQJGLP_cjs.isCompletedEvent; }
40
+ });
41
+ Object.defineProperty(exports, "isContentEvent", {
42
+ enumerable: true,
43
+ get: function () { return chunk55HQJGLP_cjs.isContentEvent; }
44
+ });
45
+ Object.defineProperty(exports, "isErrorEvent", {
46
+ enumerable: true,
47
+ get: function () { return chunk55HQJGLP_cjs.isErrorEvent; }
48
+ });
49
+ Object.defineProperty(exports, "isFollowupsCompletedEvent", {
50
+ enumerable: true,
51
+ get: function () { return chunk55HQJGLP_cjs.isFollowupsCompletedEvent; }
52
+ });
53
+ Object.defineProperty(exports, "isPausedEvent", {
54
+ enumerable: true,
55
+ get: function () { return chunk55HQJGLP_cjs.isPausedEvent; }
56
+ });
57
+ Object.defineProperty(exports, "isReasoningStepEvent", {
58
+ enumerable: true,
59
+ get: function () { return chunk55HQJGLP_cjs.isReasoningStepEvent; }
60
+ });
61
+ Object.defineProperty(exports, "isStepEvent", {
62
+ enumerable: true,
63
+ get: function () { return chunk55HQJGLP_cjs.isStepEvent; }
64
+ });
65
+ Object.defineProperty(exports, "isSubRunEvent", {
66
+ enumerable: true,
67
+ get: function () { return chunk55HQJGLP_cjs.isSubRunEvent; }
68
+ });
69
+ Object.defineProperty(exports, "isToolEvent", {
70
+ enumerable: true,
71
+ get: function () { return chunk55HQJGLP_cjs.isToolEvent; }
72
+ });
73
+ Object.defineProperty(exports, "mergeTool", {
74
+ enumerable: true,
75
+ get: function () { return chunk55HQJGLP_cjs.mergeTool; }
76
+ });
77
+ Object.defineProperty(exports, "normaliseBaseUrl", {
78
+ enumerable: true,
79
+ get: function () { return chunk55HQJGLP_cjs.normaliseBaseUrl; }
80
+ });
81
+ Object.defineProperty(exports, "sessionRunsToMessages", {
82
+ enumerable: true,
83
+ get: function () { return chunk55HQJGLP_cjs.sessionRunsToMessages; }
84
+ });
85
+ Object.defineProperty(exports, "streamRun", {
86
+ enumerable: true,
87
+ get: function () { return chunk55HQJGLP_cjs.streamRun; }
88
+ });
89
+ Object.defineProperty(exports, "toolsFromEvent", {
90
+ enumerable: true,
91
+ get: function () { return chunk55HQJGLP_cjs.toolsFromEvent; }
92
+ });
93
+ //# sourceMappingURL=index.cjs.map
94
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
@@ -0,0 +1,108 @@
1
+ import { k as RunEvent, l as RunEventData, q as ToolExecution, C as ChatMessage, R as ReasoningStep, j as ReferenceData, o as SubRun } from '../client-DUyVqxU9.cjs';
2
+ export { A as AgnoClient, a as AgnoClientOptions, b as AnyRunEventName, c as AudioData, d as ChatRole, e as ChatStatus, f as Citations, E as Entity, g as EntityType, I as ImageData, M as Model, P as Pagination, h as PauseType, i as Reference, m as RunRequirement, S as SessionEntry, n as SessionsResponse, p as SubRunStatus, T as TeamRunEvent, U as UserInputField, V as VideoData, W as WorkflowRunEvent, r as WorkflowStep, s as normaliseBaseUrl } from '../client-DUyVqxU9.cjs';
3
+
4
+ /**
5
+ * Streaming parser for AgentOS run endpoints.
6
+ *
7
+ * AgentOS streams a run as a sequence of JSON objects concatenated on the wire
8
+ * (not strictly newline-delimited). Each object is one "run event". This module
9
+ * reads the response body incrementally, extracts complete JSON objects as they
10
+ * arrive, and hands each one to a callback.
11
+ *
12
+ * It supports both the legacy shape (the event object sent directly) and the
13
+ * newer envelope shape ({ event: string, data: string | object }), normalising
14
+ * both into a flat event object with an `event` discriminator field.
15
+ */
16
+
17
+ /** A parsed, normalised run event. Shape varies by `event` type — see types.ts. */
18
+ interface StreamEvent {
19
+ event: RunEvent | string;
20
+ [key: string]: unknown;
21
+ }
22
+ interface StreamRunOptions {
23
+ url: string;
24
+ body: FormData | Record<string, unknown>;
25
+ headers?: Record<string, string>;
26
+ signal?: AbortSignal;
27
+ onEvent: (event: StreamEvent) => void;
28
+ onError: (error: Error) => void;
29
+ onComplete: () => void;
30
+ }
31
+ /**
32
+ * POSTs a run request and streams the response, calling `onEvent` for every
33
+ * run event as it arrives. Resolves when the stream ends.
34
+ */
35
+ declare function streamRun(options: StreamRunOptions): Promise<void>;
36
+
37
+ /**
38
+ * Helpers for turning AgentOS session history into render-ready chat messages.
39
+ *
40
+ * `GET /sessions/{id}/runs` returns an array of run records. Each run carries
41
+ * the user input plus the agent's content, tools, reasoning, references and
42
+ * media — enough to reconstruct the transcript for a past session.
43
+ */
44
+
45
+ interface SessionRun {
46
+ run_id?: string;
47
+ session_id?: string;
48
+ run_input?: unknown;
49
+ content?: unknown;
50
+ created_at?: number;
51
+ status?: string;
52
+ /** Present when the agent was configured with `store_events`. */
53
+ events?: RunEventData[];
54
+ tools?: ToolExecution[];
55
+ images?: ChatMessage['images'];
56
+ videos?: ChatMessage['videos'];
57
+ audio?: ChatMessage['audio'];
58
+ response_audio?: ChatMessage['response_audio'];
59
+ extra_data?: {
60
+ reasoning_steps?: ReasoningStep[];
61
+ references?: ReferenceData[];
62
+ };
63
+ reasoning_steps?: ReasoningStep[];
64
+ references?: ReferenceData[];
65
+ followups?: string[];
66
+ }
67
+ /** Convert the runs of a session into an ordered list of chat messages. */
68
+ declare function sessionRunsToMessages(runs: SessionRun[]): ChatMessage[];
69
+
70
+ /**
71
+ * Helpers for classifying run events and turning them into UI labels.
72
+ *
73
+ * Agent, team and workflow events share shapes but use different name prefixes
74
+ * (e.g. `RunContent` vs `TeamRunContent`). These helpers let the rest of the
75
+ * library treat them uniformly.
76
+ */
77
+
78
+ declare const isContentEvent: (e: RunEventData) => boolean;
79
+ declare const isCompletedEvent: (e: RunEventData) => boolean;
80
+ declare const isErrorEvent: (e: RunEventData) => boolean;
81
+ declare const isPausedEvent: (e: RunEventData) => boolean;
82
+ declare const isToolEvent: (e: RunEventData) => boolean;
83
+ declare const isReasoningStepEvent: (e: RunEventData) => boolean;
84
+ /** The follow-up prompts an agent built with `followups=True` suggests. */
85
+ declare const isFollowupsCompletedEvent: (e: RunEventData) => boolean;
86
+ /**
87
+ * A nested-run event — a team member's turn or a workflow step executor.
88
+ * Identified by a `parent_run_id` on an agent/team content/tool/run event.
89
+ */
90
+ declare function isSubRunEvent(e: RunEventData): boolean;
91
+ /** A workflow step lifecycle event (start / output / complete / error). */
92
+ declare function isStepEvent(e: RunEventData): boolean;
93
+ /** Tool executions carried by an event, from either the single or array field. */
94
+ declare function toolsFromEvent(e: RunEventData): ToolExecution[];
95
+ /**
96
+ * A short human-readable label describing what a run is doing at the moment of
97
+ * this event — for a live status line ("Calling get_weather", "Reasoning…").
98
+ * Returns null for events that don't warrant a status change.
99
+ */
100
+ declare function activityLabel(e: RunEventData): string | null;
101
+ /** Apply a nested member/executor run event into a message's `members`. */
102
+ declare function applySubRunEvent(message: ChatMessage, e: RunEventData, kind: SubRun['kind']): ChatMessage;
103
+ /** Apply a workflow `Step*` event into a message's `steps`. */
104
+ declare function applyStepEvent(message: ChatMessage, e: RunEventData): ChatMessage;
105
+ /** Merge a tool execution into a list, updating an existing entry by id/name. */
106
+ declare function mergeTool(list: ToolExecution[], tool: ToolExecution): ToolExecution[];
107
+
108
+ export { ChatMessage, ReasoningStep, ReferenceData, RunEvent, RunEventData, type StreamEvent, type StreamRunOptions, SubRun, ToolExecution, activityLabel, applyStepEvent, applySubRunEvent, isCompletedEvent, isContentEvent, isErrorEvent, isFollowupsCompletedEvent, isPausedEvent, isReasoningStepEvent, isStepEvent, isSubRunEvent, isToolEvent, mergeTool, sessionRunsToMessages, streamRun, toolsFromEvent };