@distri/core 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.
@@ -0,0 +1,197 @@
1
+ import { AgentSkill, Message, TaskStatusUpdateEvent, TaskArtifactUpdateEvent, Task, MessageSendParams } from '@a2a-js/sdk/client';
2
+ export * from '@a2a-js/sdk/client';
3
+ export { AgentCard, Message, MessageSendParams, Task, TaskArtifactUpdateEvent, TaskStatus, TaskStatusUpdateEvent } from '@a2a-js/sdk/client';
4
+
5
+ /**
6
+ * Distri-specific Agent type that wraps A2A AgentCard
7
+ */
8
+ interface DistriAgent {
9
+ /** The name of the agent. */
10
+ name: string;
11
+ id: string;
12
+ /** A brief description of the agent's purpose. */
13
+ description?: string;
14
+ /** The version of the agent. */
15
+ version?: string;
16
+ /** The system prompt for the agent, if any. */
17
+ system_prompt?: string | null;
18
+ /** A list of MCP server definitions associated with the agent. */
19
+ mcp_servers?: McpDefinition[];
20
+ /** Settings related to the model used by the agent. */
21
+ model_settings?: ModelSettings;
22
+ /** The size of the history to maintain for the agent. */
23
+ history_size?: number;
24
+ /** The planning configuration for the agent, if any. */
25
+ plan?: any;
26
+ /** A2A-specific fields */
27
+ icon_url?: string;
28
+ max_iterations?: number;
29
+ skills?: AgentSkill[];
30
+ /** List of sub-agents that this agent can transfer control to */
31
+ sub_agents?: string[];
32
+ }
33
+ interface McpDefinition {
34
+ /** The filter applied to the tools in this MCP definition. */
35
+ filter?: string[];
36
+ /** The name of the MCP server. */
37
+ name: string;
38
+ /** The type of the MCP server (Tool or Agent). */
39
+ type?: McpServerType;
40
+ }
41
+ interface ModelSettings {
42
+ model: string;
43
+ temperature: number;
44
+ max_tokens: number;
45
+ top_p: number;
46
+ frequency_penalty: number;
47
+ presence_penalty: number;
48
+ max_iterations: number;
49
+ provider: ModelProvider;
50
+ /** Additional parameters for the agent, if any. */
51
+ parameters?: any;
52
+ /** The format of the response, if specified. */
53
+ response_format?: any;
54
+ }
55
+ type McpServerType = 'tool' | 'agent';
56
+ type ModelProvider = 'openai' | 'aigateway';
57
+ /**
58
+ * Distri Thread type for conversation management
59
+ */
60
+ interface DistriThread {
61
+ id: string;
62
+ title: string;
63
+ agent_id: string;
64
+ agent_name: string;
65
+ updated_at: string;
66
+ message_count: number;
67
+ last_message?: string;
68
+ }
69
+ interface Agent {
70
+ id: string;
71
+ name: string;
72
+ description: string;
73
+ status: 'online' | 'offline';
74
+ }
75
+ interface Thread {
76
+ id: string;
77
+ title: string;
78
+ agent_id: string;
79
+ agent_name: string;
80
+ updated_at: string;
81
+ message_count: number;
82
+ last_message?: string;
83
+ }
84
+ interface ChatProps {
85
+ thread: Thread;
86
+ agent: Agent;
87
+ onThreadUpdate?: () => void;
88
+ }
89
+ /**
90
+ * Connection Status
91
+ */
92
+ type ConnectionStatus = 'connecting' | 'connected' | 'disconnected' | 'error';
93
+ /**
94
+ * Distri Client Configuration
95
+ */
96
+ interface DistriClientConfig {
97
+ baseUrl: string;
98
+ apiVersion?: string;
99
+ timeout?: number;
100
+ retryAttempts?: number;
101
+ retryDelay?: number;
102
+ debug?: boolean;
103
+ headers?: Record<string, string>;
104
+ }
105
+ /**
106
+ * Error Types
107
+ */
108
+ declare class DistriError extends Error {
109
+ code: string;
110
+ details?: any | undefined;
111
+ constructor(message: string, code: string, details?: any | undefined);
112
+ }
113
+ declare class A2AProtocolError extends DistriError {
114
+ constructor(message: string, details?: any);
115
+ }
116
+ declare class ApiError extends DistriError {
117
+ statusCode: number;
118
+ constructor(message: string, statusCode: number, details?: any);
119
+ }
120
+ declare class ConnectionError extends DistriError {
121
+ constructor(message: string, details?: any);
122
+ }
123
+
124
+ type A2AStreamEventData = Message | TaskStatusUpdateEvent | TaskArtifactUpdateEvent | Task;
125
+
126
+ /**
127
+ * Enhanced Distri Client that wraps A2AClient and adds Distri-specific features
128
+ */
129
+ declare class DistriClient {
130
+ private config;
131
+ private agentClients;
132
+ constructor(config: DistriClientConfig);
133
+ /**
134
+ * Get all available agents from the Distri server
135
+ */
136
+ getAgents(): Promise<DistriAgent[]>;
137
+ /**
138
+ * Get specific agent by ID
139
+ */
140
+ getAgent(agentId: string): Promise<DistriAgent>;
141
+ /**
142
+ * Get or create A2AClient for an agent
143
+ */
144
+ private getA2AClient;
145
+ /**
146
+ * Send a message to an agent
147
+ */
148
+ sendMessage(agentId: string, params: MessageSendParams): Promise<Message | Task>;
149
+ /**
150
+ * Send a streaming message to an agent
151
+ */
152
+ sendMessageStream(agentId: string, params: MessageSendParams): AsyncGenerator<A2AStreamEventData>;
153
+ /**
154
+ * Get task details
155
+ */
156
+ getTask(agentId: string, taskId: string): Promise<Task>;
157
+ /**
158
+ * Cancel a task
159
+ */
160
+ cancelTask(agentId: string, taskId: string): Promise<void>;
161
+ /**
162
+ * Get threads from Distri server
163
+ */
164
+ getThreads(): Promise<DistriThread[]>;
165
+ getThread(threadId: string): Promise<DistriThread>;
166
+ /**
167
+ * Get thread messages
168
+ */
169
+ getThreadMessages(threadId: string): Promise<Message[]>;
170
+ /**
171
+ * Get the base URL for making direct requests
172
+ */
173
+ get baseUrl(): string;
174
+ /**
175
+ * Enhanced fetch with retry logic
176
+ */
177
+ private fetch;
178
+ /**
179
+ * Delay utility
180
+ */
181
+ private delay;
182
+ /**
183
+ * Debug logging
184
+ */
185
+ private debug;
186
+ /**
187
+ * Helper method to create A2A messages
188
+ */
189
+ static initMessage(input: string, role?: 'agent' | 'user', contextId?: string, messageId?: string, taskId?: string): Message;
190
+ /**
191
+ * Helper method to create message send parameters
192
+ */
193
+ static initMessageParams(message: Message, configuration?: MessageSendParams['configuration']): MessageSendParams;
194
+ }
195
+ declare function uuidv4(): string;
196
+
197
+ export { A2AProtocolError, type A2AStreamEventData, type Agent, ApiError, type ChatProps, ConnectionError, type ConnectionStatus, type DistriAgent, DistriClient, type DistriClientConfig, DistriError, type DistriThread, type McpDefinition, type McpServerType, type ModelProvider, type ModelSettings, type Thread, uuidv4 };
@@ -0,0 +1,197 @@
1
+ import { AgentSkill, Message, TaskStatusUpdateEvent, TaskArtifactUpdateEvent, Task, MessageSendParams } from '@a2a-js/sdk/client';
2
+ export * from '@a2a-js/sdk/client';
3
+ export { AgentCard, Message, MessageSendParams, Task, TaskArtifactUpdateEvent, TaskStatus, TaskStatusUpdateEvent } from '@a2a-js/sdk/client';
4
+
5
+ /**
6
+ * Distri-specific Agent type that wraps A2A AgentCard
7
+ */
8
+ interface DistriAgent {
9
+ /** The name of the agent. */
10
+ name: string;
11
+ id: string;
12
+ /** A brief description of the agent's purpose. */
13
+ description?: string;
14
+ /** The version of the agent. */
15
+ version?: string;
16
+ /** The system prompt for the agent, if any. */
17
+ system_prompt?: string | null;
18
+ /** A list of MCP server definitions associated with the agent. */
19
+ mcp_servers?: McpDefinition[];
20
+ /** Settings related to the model used by the agent. */
21
+ model_settings?: ModelSettings;
22
+ /** The size of the history to maintain for the agent. */
23
+ history_size?: number;
24
+ /** The planning configuration for the agent, if any. */
25
+ plan?: any;
26
+ /** A2A-specific fields */
27
+ icon_url?: string;
28
+ max_iterations?: number;
29
+ skills?: AgentSkill[];
30
+ /** List of sub-agents that this agent can transfer control to */
31
+ sub_agents?: string[];
32
+ }
33
+ interface McpDefinition {
34
+ /** The filter applied to the tools in this MCP definition. */
35
+ filter?: string[];
36
+ /** The name of the MCP server. */
37
+ name: string;
38
+ /** The type of the MCP server (Tool or Agent). */
39
+ type?: McpServerType;
40
+ }
41
+ interface ModelSettings {
42
+ model: string;
43
+ temperature: number;
44
+ max_tokens: number;
45
+ top_p: number;
46
+ frequency_penalty: number;
47
+ presence_penalty: number;
48
+ max_iterations: number;
49
+ provider: ModelProvider;
50
+ /** Additional parameters for the agent, if any. */
51
+ parameters?: any;
52
+ /** The format of the response, if specified. */
53
+ response_format?: any;
54
+ }
55
+ type McpServerType = 'tool' | 'agent';
56
+ type ModelProvider = 'openai' | 'aigateway';
57
+ /**
58
+ * Distri Thread type for conversation management
59
+ */
60
+ interface DistriThread {
61
+ id: string;
62
+ title: string;
63
+ agent_id: string;
64
+ agent_name: string;
65
+ updated_at: string;
66
+ message_count: number;
67
+ last_message?: string;
68
+ }
69
+ interface Agent {
70
+ id: string;
71
+ name: string;
72
+ description: string;
73
+ status: 'online' | 'offline';
74
+ }
75
+ interface Thread {
76
+ id: string;
77
+ title: string;
78
+ agent_id: string;
79
+ agent_name: string;
80
+ updated_at: string;
81
+ message_count: number;
82
+ last_message?: string;
83
+ }
84
+ interface ChatProps {
85
+ thread: Thread;
86
+ agent: Agent;
87
+ onThreadUpdate?: () => void;
88
+ }
89
+ /**
90
+ * Connection Status
91
+ */
92
+ type ConnectionStatus = 'connecting' | 'connected' | 'disconnected' | 'error';
93
+ /**
94
+ * Distri Client Configuration
95
+ */
96
+ interface DistriClientConfig {
97
+ baseUrl: string;
98
+ apiVersion?: string;
99
+ timeout?: number;
100
+ retryAttempts?: number;
101
+ retryDelay?: number;
102
+ debug?: boolean;
103
+ headers?: Record<string, string>;
104
+ }
105
+ /**
106
+ * Error Types
107
+ */
108
+ declare class DistriError extends Error {
109
+ code: string;
110
+ details?: any | undefined;
111
+ constructor(message: string, code: string, details?: any | undefined);
112
+ }
113
+ declare class A2AProtocolError extends DistriError {
114
+ constructor(message: string, details?: any);
115
+ }
116
+ declare class ApiError extends DistriError {
117
+ statusCode: number;
118
+ constructor(message: string, statusCode: number, details?: any);
119
+ }
120
+ declare class ConnectionError extends DistriError {
121
+ constructor(message: string, details?: any);
122
+ }
123
+
124
+ type A2AStreamEventData = Message | TaskStatusUpdateEvent | TaskArtifactUpdateEvent | Task;
125
+
126
+ /**
127
+ * Enhanced Distri Client that wraps A2AClient and adds Distri-specific features
128
+ */
129
+ declare class DistriClient {
130
+ private config;
131
+ private agentClients;
132
+ constructor(config: DistriClientConfig);
133
+ /**
134
+ * Get all available agents from the Distri server
135
+ */
136
+ getAgents(): Promise<DistriAgent[]>;
137
+ /**
138
+ * Get specific agent by ID
139
+ */
140
+ getAgent(agentId: string): Promise<DistriAgent>;
141
+ /**
142
+ * Get or create A2AClient for an agent
143
+ */
144
+ private getA2AClient;
145
+ /**
146
+ * Send a message to an agent
147
+ */
148
+ sendMessage(agentId: string, params: MessageSendParams): Promise<Message | Task>;
149
+ /**
150
+ * Send a streaming message to an agent
151
+ */
152
+ sendMessageStream(agentId: string, params: MessageSendParams): AsyncGenerator<A2AStreamEventData>;
153
+ /**
154
+ * Get task details
155
+ */
156
+ getTask(agentId: string, taskId: string): Promise<Task>;
157
+ /**
158
+ * Cancel a task
159
+ */
160
+ cancelTask(agentId: string, taskId: string): Promise<void>;
161
+ /**
162
+ * Get threads from Distri server
163
+ */
164
+ getThreads(): Promise<DistriThread[]>;
165
+ getThread(threadId: string): Promise<DistriThread>;
166
+ /**
167
+ * Get thread messages
168
+ */
169
+ getThreadMessages(threadId: string): Promise<Message[]>;
170
+ /**
171
+ * Get the base URL for making direct requests
172
+ */
173
+ get baseUrl(): string;
174
+ /**
175
+ * Enhanced fetch with retry logic
176
+ */
177
+ private fetch;
178
+ /**
179
+ * Delay utility
180
+ */
181
+ private delay;
182
+ /**
183
+ * Debug logging
184
+ */
185
+ private debug;
186
+ /**
187
+ * Helper method to create A2A messages
188
+ */
189
+ static initMessage(input: string, role?: 'agent' | 'user', contextId?: string, messageId?: string, taskId?: string): Message;
190
+ /**
191
+ * Helper method to create message send parameters
192
+ */
193
+ static initMessageParams(message: Message, configuration?: MessageSendParams['configuration']): MessageSendParams;
194
+ }
195
+ declare function uuidv4(): string;
196
+
197
+ export { A2AProtocolError, type A2AStreamEventData, type Agent, ApiError, type ChatProps, ConnectionError, type ConnectionStatus, type DistriAgent, DistriClient, type DistriClientConfig, DistriError, type DistriThread, type McpDefinition, type McpServerType, type ModelProvider, type ModelSettings, type Thread, uuidv4 };