@distri/core 0.2.2 → 0.2.4

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.d.mts CHANGED
@@ -1,4 +1,5 @@
1
- import { AgentSkill, Message, TaskStatusUpdateEvent, TaskArtifactUpdateEvent, Task, MessageSendParams, Part } from '@a2a-js/sdk/client';
1
+ import { AgentSkill, Message, TaskStatusUpdateEvent, TaskArtifactUpdateEvent, Task, MessageSendParams, Part, Artifact } from '@a2a-js/sdk/client';
2
+ export { AgentCard, Message, MessageSendParams, Task, TaskArtifactUpdateEvent, TaskStatus, TaskStatusUpdateEvent } from '@a2a-js/sdk/client';
2
3
 
3
4
  type Role = 'user' | 'system' | 'assistant';
4
5
  interface RunStartedEvent {
@@ -16,6 +17,24 @@ interface RunErrorEvent {
16
17
  code?: string;
17
18
  };
18
19
  }
20
+ interface PlanStartedEvent {
21
+ type: 'plan_started';
22
+ data: {
23
+ initial_plan?: boolean;
24
+ };
25
+ }
26
+ interface PlanFinishedEvent {
27
+ type: 'plan_finished';
28
+ data: {
29
+ total_steps?: number;
30
+ };
31
+ }
32
+ interface PlanPrunedEvent {
33
+ type: 'plan_pruned';
34
+ data: {
35
+ removed_steps?: any;
36
+ };
37
+ }
19
38
  interface TextMessageStartEvent {
20
39
  type: 'text_message_start';
21
40
  data: {
@@ -42,7 +61,6 @@ interface ToolCallStartEvent {
42
61
  tool_call_id: string;
43
62
  tool_call_name: string;
44
63
  parent_message_id?: string;
45
- is_external?: boolean;
46
64
  };
47
65
  }
48
66
  interface ToolCallArgsEvent {
@@ -65,6 +83,22 @@ interface ToolCallResultEvent {
65
83
  result: string;
66
84
  };
67
85
  }
86
+ interface ToolRejectedEvent {
87
+ type: 'tool_rejected';
88
+ data: {
89
+ reason?: string;
90
+ tool_call_id?: string;
91
+ };
92
+ }
93
+ interface TaskArtifactEvent {
94
+ type: 'task_artifact';
95
+ data: {
96
+ artifact_id: string;
97
+ artifact_type: string;
98
+ resolution?: any;
99
+ content?: any;
100
+ };
101
+ }
68
102
  interface AgentHandoverEvent {
69
103
  type: 'agent_handover';
70
104
  data: {
@@ -73,7 +107,29 @@ interface AgentHandoverEvent {
73
107
  reason?: string;
74
108
  };
75
109
  }
76
- type DistriEvent = RunStartedEvent | RunFinishedEvent | RunErrorEvent | TextMessageStartEvent | TextMessageContentEvent | TextMessageEndEvent | ToolCallStartEvent | ToolCallArgsEvent | ToolCallEndEvent | ToolCallResultEvent | AgentHandoverEvent;
110
+ interface StepStartedEvent {
111
+ type: 'step_started';
112
+ data: {
113
+ step_id: string;
114
+ step_title: string;
115
+ step_index: number;
116
+ };
117
+ }
118
+ interface StepCompletedEvent {
119
+ type: 'step_completed';
120
+ data: {
121
+ step_id: string;
122
+ step_title: string;
123
+ step_index: number;
124
+ };
125
+ }
126
+ interface FeedbackReceivedEvent {
127
+ type: 'feedback_received';
128
+ data: {
129
+ feedback: string;
130
+ };
131
+ }
132
+ type DistriEvent = RunStartedEvent | RunFinishedEvent | RunErrorEvent | PlanStartedEvent | PlanFinishedEvent | PlanPrunedEvent | TextMessageStartEvent | TextMessageContentEvent | TextMessageEndEvent | ToolCallStartEvent | ToolCallArgsEvent | ToolCallEndEvent | ToolCallResultEvent | ToolRejectedEvent | StepStartedEvent | StepCompletedEvent | TaskArtifactEvent | AgentHandoverEvent | FeedbackReceivedEvent;
77
133
 
78
134
  /**
79
135
  * Message roles supported by Distri
@@ -88,14 +144,81 @@ interface DistriMessage {
88
144
  parts: DistriPart[];
89
145
  created_at?: string;
90
146
  }
91
- type DistriStreamEvent = DistriMessage | DistriEvent;
147
+ interface AssistantWithToolCalls {
148
+ id: string;
149
+ type: 'llm_response';
150
+ timestamp: number;
151
+ content: string;
152
+ tool_calls: any[];
153
+ step_id?: string;
154
+ success: boolean;
155
+ rejected: boolean;
156
+ is_external: boolean;
157
+ reason: string | null;
158
+ }
159
+ interface ToolResults {
160
+ id: string;
161
+ type: 'tool_results';
162
+ timestamp: number;
163
+ results: any[];
164
+ step_id?: string;
165
+ success: boolean;
166
+ rejected: boolean;
167
+ reason: string | null;
168
+ }
169
+ interface GenericArtifact {
170
+ id: string;
171
+ type: 'artifact';
172
+ timestamp: number;
173
+ data: any;
174
+ artifactId: string;
175
+ name: string;
176
+ description: string | null;
177
+ }
178
+ interface DistriPlan {
179
+ id: string;
180
+ type: 'plan';
181
+ timestamp: number;
182
+ reasoning: string;
183
+ steps: PlanStep[];
184
+ }
185
+ interface BasePlanStep {
186
+ id: string;
187
+ title: string;
188
+ }
189
+ interface LlmPlanStep extends BasePlanStep {
190
+ type: 'llm_call';
191
+ prompt: string;
192
+ context: any[];
193
+ }
194
+ interface BatchToolCallsStep extends BasePlanStep {
195
+ type: 'batch_tool_calls';
196
+ tool_calls: any[];
197
+ }
198
+ interface ThoughtStep extends BasePlanStep {
199
+ type: 'thought';
200
+ message: string;
201
+ }
202
+ interface ReactStep extends BasePlanStep {
203
+ type: 'react_step';
204
+ thought: string;
205
+ action: string;
206
+ }
207
+ interface FinalResultStep extends BasePlanStep {
208
+ type: 'final_result';
209
+ content: string;
210
+ tool_calls: any[];
211
+ }
212
+ type PlanStep = LlmPlanStep | BatchToolCallsStep | ThoughtStep | ReactStep | FinalResultStep;
213
+ type DistriArtifact = AssistantWithToolCalls | ToolResults | GenericArtifact | DistriPlan;
214
+ type DistriStreamEvent = DistriMessage | DistriEvent | DistriArtifact;
92
215
  /**
93
216
  * Context required for constructing A2A messages from DistriMessage
94
217
  */
95
218
  interface InvokeContext {
96
219
  thread_id: string;
97
220
  run_id?: string;
98
- metadata?: any;
221
+ getMetadata?: () => any;
99
222
  }
100
223
  /**
101
224
  * Distri message parts - equivalent to Rust enum Part
@@ -182,6 +305,7 @@ interface ToolCall {
182
305
  */
183
306
  interface ToolResult {
184
307
  tool_call_id: string;
308
+ tool_name: string;
185
309
  result: string | number | boolean | null;
186
310
  success: boolean;
187
311
  error?: string;
@@ -189,7 +313,7 @@ interface ToolResult {
189
313
  /**
190
314
  * Distri-specific Agent type that wraps A2A AgentCard
191
315
  */
192
- interface DistriAgent {
316
+ interface AgentDefinition {
193
317
  /** The name of the agent. */
194
318
  name: string;
195
319
  id: string;
@@ -261,7 +385,7 @@ interface Thread {
261
385
  }
262
386
  interface ChatProps {
263
387
  thread: Thread;
264
- agent: DistriAgent;
388
+ agent: AgentDefinition;
265
389
  onThreadUpdate?: () => void;
266
390
  }
267
391
  /**
@@ -281,9 +405,31 @@ interface DistriClientConfig {
281
405
  headers?: Record<string, string>;
282
406
  interceptor?: (init?: RequestInit) => Promise<RequestInit | undefined>;
283
407
  }
408
+ /**
409
+ * Error Types
410
+ */
411
+ declare class DistriError extends Error {
412
+ code: string;
413
+ details?: any | undefined;
414
+ constructor(message: string, code: string, details?: any | undefined);
415
+ }
416
+ declare class A2AProtocolError extends DistriError {
417
+ constructor(message: string, details?: any);
418
+ }
419
+ declare class ApiError extends DistriError {
420
+ statusCode: number;
421
+ constructor(message: string, statusCode: number, details?: any);
422
+ }
423
+ declare class ConnectionError extends DistriError {
424
+ constructor(message: string, details?: any);
425
+ }
426
+
284
427
  type A2AStreamEventData = Message | TaskStatusUpdateEvent | TaskArtifactUpdateEvent | Task;
285
428
  declare function isDistriMessage(event: DistriStreamEvent): event is DistriMessage;
286
429
  declare function isDistriEvent(event: DistriStreamEvent): event is DistriEvent;
430
+ declare function isDistriPlan(event: DistriStreamEvent): event is DistriPlan;
431
+ declare function isDistriArtifact(event: DistriStreamEvent): event is DistriArtifact;
432
+ type DistriChatMessage = DistriEvent | DistriMessage | DistriArtifact;
287
433
 
288
434
  /**
289
435
  * Enhanced Distri Client that wraps A2AClient and adds Distri-specific features
@@ -295,11 +441,11 @@ declare class DistriClient {
295
441
  /**
296
442
  * Get all available agents from the Distri server
297
443
  */
298
- getAgents(): Promise<DistriAgent[]>;
444
+ getAgents(): Promise<AgentDefinition[]>;
299
445
  /**
300
446
  * Get specific agent by ID
301
447
  */
302
- getAgent(agentId: string): Promise<DistriAgent>;
448
+ getAgent(agentId: string): Promise<AgentDefinition>;
303
449
  /**
304
450
  * Get or create A2AClient for an agent
305
451
  */
@@ -405,7 +551,7 @@ declare class Agent {
405
551
  private client;
406
552
  private agentDefinition;
407
553
  private tools;
408
- constructor(agentDefinition: DistriAgent, client: DistriClient);
554
+ constructor(agentDefinition: AgentDefinition, client: DistriClient);
409
555
  /**
410
556
  * Add a tool to the agent (AG-UI style)
411
557
  */
@@ -444,7 +590,7 @@ declare class Agent {
444
590
  /**
445
591
  * Streaming invoke
446
592
  */
447
- invokeStream(params: MessageSendParams): Promise<AsyncGenerator<DistriEvent | DistriMessage>>;
593
+ invokeStream(params: MessageSendParams): Promise<AsyncGenerator<DistriChatMessage>>;
448
594
  /**
449
595
  * Enhance message params with tool definitions
450
596
  */
@@ -452,7 +598,7 @@ declare class Agent {
452
598
  /**
453
599
  * Create an agent instance from an agent ID
454
600
  */
455
- static create(agentId: string, client: DistriClient): Promise<Agent>;
601
+ static create(agentIdOrDef: string | AgentDefinition, client: DistriClient): Promise<Agent>;
456
602
  /**
457
603
  * List all available agents
458
604
  */
@@ -463,6 +609,26 @@ declare class Agent {
463
609
  * Converts an A2A Message to a DistriMessage
464
610
  */
465
611
  declare function convertA2AMessageToDistri(a2aMessage: Message): DistriMessage;
612
+ /**
613
+ * Converts A2A status-update events to DistriEvent based on metadata type
614
+ */
615
+ declare function convertA2AStatusUpdateToDistri(statusUpdate: any): DistriEvent | null;
616
+ /**
617
+ * Converts A2A artifacts to DistriArtifact, DistriPlan, or DistriMessage based on content
618
+ */
619
+ declare function convertA2AArtifactToDistri(artifact: Artifact): DistriArtifact | DistriMessage | null;
620
+ /**
621
+ * Enhanced decoder for A2A stream events that properly handles all event types
622
+ */
623
+ declare function decodeA2AStreamEvent(event: any): DistriChatMessage | null;
624
+ /**
625
+ * Process A2A stream data (like from stream.json) and convert to DistriMessage/DistriEvent/DistriArtifact array
626
+ */
627
+ declare function processA2AStreamData(streamData: any[]): (DistriMessage | DistriEvent | DistriArtifact)[];
628
+ /**
629
+ * Process A2A messages.json data and convert to DistriMessage array
630
+ */
631
+ declare function processA2AMessagesData(data: any[]): DistriMessage[];
466
632
  /**
467
633
  * Converts an A2A Part to a DistriPart
468
634
  */
@@ -488,4 +654,4 @@ declare function extractToolCallsFromDistriMessage(message: DistriMessage): any[
488
654
  */
489
655
  declare function extractToolResultsFromDistriMessage(message: DistriMessage): any[];
490
656
 
491
- export { Agent, type AgentHandoverEvent, type ChatProps, type CodeObservationPart, type ConnectionStatus, type DataPart, type DistriAgent, type DistriBaseTool, DistriClient, type DistriClientConfig, type DistriEvent, type DistriFnTool, type DistriMessage, type DistriPart, type DistriStreamEvent, type DistriThread, type FileType, type ImagePart, type InvokeConfig, type InvokeContext, type InvokeResult, type McpDefinition, type McpServerType, type MessageRole, type ModelProvider, type ModelSettings, type PlanPart, type RunErrorEvent, type RunFinishedEvent, type RunStartedEvent, type TextMessageContentEvent, type TextMessageEndEvent, type TextMessageStartEvent, type TextPart, type Thread, type ToolCall, type ToolCallArgsEvent, type ToolCallEndEvent, type ToolCallPart, type ToolCallResultEvent, type ToolCallStartEvent, type ToolResult, type ToolResultPart, convertA2AMessageToDistri, convertA2APartToDistri, convertDistriMessageToA2A, convertDistriPartToA2A, extractTextFromDistriMessage, extractToolCallsFromDistriMessage, extractToolResultsFromDistriMessage, isDistriEvent, isDistriMessage, uuidv4 };
657
+ export { A2AProtocolError, type A2AStreamEventData, Agent, type AgentDefinition, type AgentHandoverEvent, ApiError, type AssistantWithToolCalls, type BasePlanStep, type BatchToolCallsStep, type ChatProps, type CodeObservationPart, ConnectionError, type ConnectionStatus, type DataPart, type DistriArtifact, type DistriBaseTool, type DistriChatMessage, DistriClient, type DistriClientConfig, DistriError, type DistriEvent, type DistriFnTool, type DistriMessage, type DistriPart, type DistriPlan, type DistriStreamEvent, type DistriThread, type FeedbackReceivedEvent, type FileBytes, type FileType, type FileUrl, type FinalResultStep, type GenericArtifact, type ImageBytesPart, type ImagePart, type ImageUrlPart, type InvokeConfig, type InvokeContext, type InvokeResult, type LlmPlanStep, type McpDefinition, type McpServerType, type MessageRole, type ModelProvider, type ModelSettings, type PlanFinishedEvent, type PlanPart, type PlanPrunedEvent, type PlanStartedEvent, type PlanStep, type ReactStep, type Role, type RunErrorEvent, type RunFinishedEvent, type RunStartedEvent, type StepCompletedEvent, type StepStartedEvent, type TaskArtifactEvent, type TextMessageContentEvent, type TextMessageEndEvent, type TextMessageStartEvent, type TextPart, type ThoughtStep, type Thread, type ToolCall, type ToolCallArgsEvent, type ToolCallEndEvent, type ToolCallPart, type ToolCallResultEvent, type ToolCallStartEvent, type ToolHandler, type ToolRejectedEvent, type ToolResult, type ToolResultPart, type ToolResults, convertA2AArtifactToDistri, convertA2AMessageToDistri, convertA2APartToDistri, convertA2AStatusUpdateToDistri, convertDistriMessageToA2A, convertDistriPartToA2A, decodeA2AStreamEvent, extractTextFromDistriMessage, extractToolCallsFromDistriMessage, extractToolResultsFromDistriMessage, isDistriArtifact, isDistriEvent, isDistriMessage, isDistriPlan, processA2AMessagesData, processA2AStreamData, uuidv4 };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { AgentSkill, Message, TaskStatusUpdateEvent, TaskArtifactUpdateEvent, Task, MessageSendParams, Part } from '@a2a-js/sdk/client';
1
+ import { AgentSkill, Message, TaskStatusUpdateEvent, TaskArtifactUpdateEvent, Task, MessageSendParams, Part, Artifact } from '@a2a-js/sdk/client';
2
+ export { AgentCard, Message, MessageSendParams, Task, TaskArtifactUpdateEvent, TaskStatus, TaskStatusUpdateEvent } from '@a2a-js/sdk/client';
2
3
 
3
4
  type Role = 'user' | 'system' | 'assistant';
4
5
  interface RunStartedEvent {
@@ -16,6 +17,24 @@ interface RunErrorEvent {
16
17
  code?: string;
17
18
  };
18
19
  }
20
+ interface PlanStartedEvent {
21
+ type: 'plan_started';
22
+ data: {
23
+ initial_plan?: boolean;
24
+ };
25
+ }
26
+ interface PlanFinishedEvent {
27
+ type: 'plan_finished';
28
+ data: {
29
+ total_steps?: number;
30
+ };
31
+ }
32
+ interface PlanPrunedEvent {
33
+ type: 'plan_pruned';
34
+ data: {
35
+ removed_steps?: any;
36
+ };
37
+ }
19
38
  interface TextMessageStartEvent {
20
39
  type: 'text_message_start';
21
40
  data: {
@@ -42,7 +61,6 @@ interface ToolCallStartEvent {
42
61
  tool_call_id: string;
43
62
  tool_call_name: string;
44
63
  parent_message_id?: string;
45
- is_external?: boolean;
46
64
  };
47
65
  }
48
66
  interface ToolCallArgsEvent {
@@ -65,6 +83,22 @@ interface ToolCallResultEvent {
65
83
  result: string;
66
84
  };
67
85
  }
86
+ interface ToolRejectedEvent {
87
+ type: 'tool_rejected';
88
+ data: {
89
+ reason?: string;
90
+ tool_call_id?: string;
91
+ };
92
+ }
93
+ interface TaskArtifactEvent {
94
+ type: 'task_artifact';
95
+ data: {
96
+ artifact_id: string;
97
+ artifact_type: string;
98
+ resolution?: any;
99
+ content?: any;
100
+ };
101
+ }
68
102
  interface AgentHandoverEvent {
69
103
  type: 'agent_handover';
70
104
  data: {
@@ -73,7 +107,29 @@ interface AgentHandoverEvent {
73
107
  reason?: string;
74
108
  };
75
109
  }
76
- type DistriEvent = RunStartedEvent | RunFinishedEvent | RunErrorEvent | TextMessageStartEvent | TextMessageContentEvent | TextMessageEndEvent | ToolCallStartEvent | ToolCallArgsEvent | ToolCallEndEvent | ToolCallResultEvent | AgentHandoverEvent;
110
+ interface StepStartedEvent {
111
+ type: 'step_started';
112
+ data: {
113
+ step_id: string;
114
+ step_title: string;
115
+ step_index: number;
116
+ };
117
+ }
118
+ interface StepCompletedEvent {
119
+ type: 'step_completed';
120
+ data: {
121
+ step_id: string;
122
+ step_title: string;
123
+ step_index: number;
124
+ };
125
+ }
126
+ interface FeedbackReceivedEvent {
127
+ type: 'feedback_received';
128
+ data: {
129
+ feedback: string;
130
+ };
131
+ }
132
+ type DistriEvent = RunStartedEvent | RunFinishedEvent | RunErrorEvent | PlanStartedEvent | PlanFinishedEvent | PlanPrunedEvent | TextMessageStartEvent | TextMessageContentEvent | TextMessageEndEvent | ToolCallStartEvent | ToolCallArgsEvent | ToolCallEndEvent | ToolCallResultEvent | ToolRejectedEvent | StepStartedEvent | StepCompletedEvent | TaskArtifactEvent | AgentHandoverEvent | FeedbackReceivedEvent;
77
133
 
78
134
  /**
79
135
  * Message roles supported by Distri
@@ -88,14 +144,81 @@ interface DistriMessage {
88
144
  parts: DistriPart[];
89
145
  created_at?: string;
90
146
  }
91
- type DistriStreamEvent = DistriMessage | DistriEvent;
147
+ interface AssistantWithToolCalls {
148
+ id: string;
149
+ type: 'llm_response';
150
+ timestamp: number;
151
+ content: string;
152
+ tool_calls: any[];
153
+ step_id?: string;
154
+ success: boolean;
155
+ rejected: boolean;
156
+ is_external: boolean;
157
+ reason: string | null;
158
+ }
159
+ interface ToolResults {
160
+ id: string;
161
+ type: 'tool_results';
162
+ timestamp: number;
163
+ results: any[];
164
+ step_id?: string;
165
+ success: boolean;
166
+ rejected: boolean;
167
+ reason: string | null;
168
+ }
169
+ interface GenericArtifact {
170
+ id: string;
171
+ type: 'artifact';
172
+ timestamp: number;
173
+ data: any;
174
+ artifactId: string;
175
+ name: string;
176
+ description: string | null;
177
+ }
178
+ interface DistriPlan {
179
+ id: string;
180
+ type: 'plan';
181
+ timestamp: number;
182
+ reasoning: string;
183
+ steps: PlanStep[];
184
+ }
185
+ interface BasePlanStep {
186
+ id: string;
187
+ title: string;
188
+ }
189
+ interface LlmPlanStep extends BasePlanStep {
190
+ type: 'llm_call';
191
+ prompt: string;
192
+ context: any[];
193
+ }
194
+ interface BatchToolCallsStep extends BasePlanStep {
195
+ type: 'batch_tool_calls';
196
+ tool_calls: any[];
197
+ }
198
+ interface ThoughtStep extends BasePlanStep {
199
+ type: 'thought';
200
+ message: string;
201
+ }
202
+ interface ReactStep extends BasePlanStep {
203
+ type: 'react_step';
204
+ thought: string;
205
+ action: string;
206
+ }
207
+ interface FinalResultStep extends BasePlanStep {
208
+ type: 'final_result';
209
+ content: string;
210
+ tool_calls: any[];
211
+ }
212
+ type PlanStep = LlmPlanStep | BatchToolCallsStep | ThoughtStep | ReactStep | FinalResultStep;
213
+ type DistriArtifact = AssistantWithToolCalls | ToolResults | GenericArtifact | DistriPlan;
214
+ type DistriStreamEvent = DistriMessage | DistriEvent | DistriArtifact;
92
215
  /**
93
216
  * Context required for constructing A2A messages from DistriMessage
94
217
  */
95
218
  interface InvokeContext {
96
219
  thread_id: string;
97
220
  run_id?: string;
98
- metadata?: any;
221
+ getMetadata?: () => any;
99
222
  }
100
223
  /**
101
224
  * Distri message parts - equivalent to Rust enum Part
@@ -182,6 +305,7 @@ interface ToolCall {
182
305
  */
183
306
  interface ToolResult {
184
307
  tool_call_id: string;
308
+ tool_name: string;
185
309
  result: string | number | boolean | null;
186
310
  success: boolean;
187
311
  error?: string;
@@ -189,7 +313,7 @@ interface ToolResult {
189
313
  /**
190
314
  * Distri-specific Agent type that wraps A2A AgentCard
191
315
  */
192
- interface DistriAgent {
316
+ interface AgentDefinition {
193
317
  /** The name of the agent. */
194
318
  name: string;
195
319
  id: string;
@@ -261,7 +385,7 @@ interface Thread {
261
385
  }
262
386
  interface ChatProps {
263
387
  thread: Thread;
264
- agent: DistriAgent;
388
+ agent: AgentDefinition;
265
389
  onThreadUpdate?: () => void;
266
390
  }
267
391
  /**
@@ -281,9 +405,31 @@ interface DistriClientConfig {
281
405
  headers?: Record<string, string>;
282
406
  interceptor?: (init?: RequestInit) => Promise<RequestInit | undefined>;
283
407
  }
408
+ /**
409
+ * Error Types
410
+ */
411
+ declare class DistriError extends Error {
412
+ code: string;
413
+ details?: any | undefined;
414
+ constructor(message: string, code: string, details?: any | undefined);
415
+ }
416
+ declare class A2AProtocolError extends DistriError {
417
+ constructor(message: string, details?: any);
418
+ }
419
+ declare class ApiError extends DistriError {
420
+ statusCode: number;
421
+ constructor(message: string, statusCode: number, details?: any);
422
+ }
423
+ declare class ConnectionError extends DistriError {
424
+ constructor(message: string, details?: any);
425
+ }
426
+
284
427
  type A2AStreamEventData = Message | TaskStatusUpdateEvent | TaskArtifactUpdateEvent | Task;
285
428
  declare function isDistriMessage(event: DistriStreamEvent): event is DistriMessage;
286
429
  declare function isDistriEvent(event: DistriStreamEvent): event is DistriEvent;
430
+ declare function isDistriPlan(event: DistriStreamEvent): event is DistriPlan;
431
+ declare function isDistriArtifact(event: DistriStreamEvent): event is DistriArtifact;
432
+ type DistriChatMessage = DistriEvent | DistriMessage | DistriArtifact;
287
433
 
288
434
  /**
289
435
  * Enhanced Distri Client that wraps A2AClient and adds Distri-specific features
@@ -295,11 +441,11 @@ declare class DistriClient {
295
441
  /**
296
442
  * Get all available agents from the Distri server
297
443
  */
298
- getAgents(): Promise<DistriAgent[]>;
444
+ getAgents(): Promise<AgentDefinition[]>;
299
445
  /**
300
446
  * Get specific agent by ID
301
447
  */
302
- getAgent(agentId: string): Promise<DistriAgent>;
448
+ getAgent(agentId: string): Promise<AgentDefinition>;
303
449
  /**
304
450
  * Get or create A2AClient for an agent
305
451
  */
@@ -405,7 +551,7 @@ declare class Agent {
405
551
  private client;
406
552
  private agentDefinition;
407
553
  private tools;
408
- constructor(agentDefinition: DistriAgent, client: DistriClient);
554
+ constructor(agentDefinition: AgentDefinition, client: DistriClient);
409
555
  /**
410
556
  * Add a tool to the agent (AG-UI style)
411
557
  */
@@ -444,7 +590,7 @@ declare class Agent {
444
590
  /**
445
591
  * Streaming invoke
446
592
  */
447
- invokeStream(params: MessageSendParams): Promise<AsyncGenerator<DistriEvent | DistriMessage>>;
593
+ invokeStream(params: MessageSendParams): Promise<AsyncGenerator<DistriChatMessage>>;
448
594
  /**
449
595
  * Enhance message params with tool definitions
450
596
  */
@@ -452,7 +598,7 @@ declare class Agent {
452
598
  /**
453
599
  * Create an agent instance from an agent ID
454
600
  */
455
- static create(agentId: string, client: DistriClient): Promise<Agent>;
601
+ static create(agentIdOrDef: string | AgentDefinition, client: DistriClient): Promise<Agent>;
456
602
  /**
457
603
  * List all available agents
458
604
  */
@@ -463,6 +609,26 @@ declare class Agent {
463
609
  * Converts an A2A Message to a DistriMessage
464
610
  */
465
611
  declare function convertA2AMessageToDistri(a2aMessage: Message): DistriMessage;
612
+ /**
613
+ * Converts A2A status-update events to DistriEvent based on metadata type
614
+ */
615
+ declare function convertA2AStatusUpdateToDistri(statusUpdate: any): DistriEvent | null;
616
+ /**
617
+ * Converts A2A artifacts to DistriArtifact, DistriPlan, or DistriMessage based on content
618
+ */
619
+ declare function convertA2AArtifactToDistri(artifact: Artifact): DistriArtifact | DistriMessage | null;
620
+ /**
621
+ * Enhanced decoder for A2A stream events that properly handles all event types
622
+ */
623
+ declare function decodeA2AStreamEvent(event: any): DistriChatMessage | null;
624
+ /**
625
+ * Process A2A stream data (like from stream.json) and convert to DistriMessage/DistriEvent/DistriArtifact array
626
+ */
627
+ declare function processA2AStreamData(streamData: any[]): (DistriMessage | DistriEvent | DistriArtifact)[];
628
+ /**
629
+ * Process A2A messages.json data and convert to DistriMessage array
630
+ */
631
+ declare function processA2AMessagesData(data: any[]): DistriMessage[];
466
632
  /**
467
633
  * Converts an A2A Part to a DistriPart
468
634
  */
@@ -488,4 +654,4 @@ declare function extractToolCallsFromDistriMessage(message: DistriMessage): any[
488
654
  */
489
655
  declare function extractToolResultsFromDistriMessage(message: DistriMessage): any[];
490
656
 
491
- export { Agent, type AgentHandoverEvent, type ChatProps, type CodeObservationPart, type ConnectionStatus, type DataPart, type DistriAgent, type DistriBaseTool, DistriClient, type DistriClientConfig, type DistriEvent, type DistriFnTool, type DistriMessage, type DistriPart, type DistriStreamEvent, type DistriThread, type FileType, type ImagePart, type InvokeConfig, type InvokeContext, type InvokeResult, type McpDefinition, type McpServerType, type MessageRole, type ModelProvider, type ModelSettings, type PlanPart, type RunErrorEvent, type RunFinishedEvent, type RunStartedEvent, type TextMessageContentEvent, type TextMessageEndEvent, type TextMessageStartEvent, type TextPart, type Thread, type ToolCall, type ToolCallArgsEvent, type ToolCallEndEvent, type ToolCallPart, type ToolCallResultEvent, type ToolCallStartEvent, type ToolResult, type ToolResultPart, convertA2AMessageToDistri, convertA2APartToDistri, convertDistriMessageToA2A, convertDistriPartToA2A, extractTextFromDistriMessage, extractToolCallsFromDistriMessage, extractToolResultsFromDistriMessage, isDistriEvent, isDistriMessage, uuidv4 };
657
+ export { A2AProtocolError, type A2AStreamEventData, Agent, type AgentDefinition, type AgentHandoverEvent, ApiError, type AssistantWithToolCalls, type BasePlanStep, type BatchToolCallsStep, type ChatProps, type CodeObservationPart, ConnectionError, type ConnectionStatus, type DataPart, type DistriArtifact, type DistriBaseTool, type DistriChatMessage, DistriClient, type DistriClientConfig, DistriError, type DistriEvent, type DistriFnTool, type DistriMessage, type DistriPart, type DistriPlan, type DistriStreamEvent, type DistriThread, type FeedbackReceivedEvent, type FileBytes, type FileType, type FileUrl, type FinalResultStep, type GenericArtifact, type ImageBytesPart, type ImagePart, type ImageUrlPart, type InvokeConfig, type InvokeContext, type InvokeResult, type LlmPlanStep, type McpDefinition, type McpServerType, type MessageRole, type ModelProvider, type ModelSettings, type PlanFinishedEvent, type PlanPart, type PlanPrunedEvent, type PlanStartedEvent, type PlanStep, type ReactStep, type Role, type RunErrorEvent, type RunFinishedEvent, type RunStartedEvent, type StepCompletedEvent, type StepStartedEvent, type TaskArtifactEvent, type TextMessageContentEvent, type TextMessageEndEvent, type TextMessageStartEvent, type TextPart, type ThoughtStep, type Thread, type ToolCall, type ToolCallArgsEvent, type ToolCallEndEvent, type ToolCallPart, type ToolCallResultEvent, type ToolCallStartEvent, type ToolHandler, type ToolRejectedEvent, type ToolResult, type ToolResultPart, type ToolResults, convertA2AArtifactToDistri, convertA2AMessageToDistri, convertA2APartToDistri, convertA2AStatusUpdateToDistri, convertDistriMessageToA2A, convertDistriPartToA2A, decodeA2AStreamEvent, extractTextFromDistriMessage, extractToolCallsFromDistriMessage, extractToolResultsFromDistriMessage, isDistriArtifact, isDistriEvent, isDistriMessage, isDistriPlan, processA2AMessagesData, processA2AStreamData, uuidv4 };