@distri/core 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -101,6 +101,7 @@ interface DistriClientConfig {
101
101
  retryDelay?: number;
102
102
  debug?: boolean;
103
103
  headers?: Record<string, string>;
104
+ interceptor?: (input: RequestInfo | URL, init?: RequestInit) => Promise<RequestInfo | URL>;
104
105
  }
105
106
  /**
106
107
  * Error Types
package/dist/index.d.ts CHANGED
@@ -101,6 +101,7 @@ interface DistriClientConfig {
101
101
  retryDelay?: number;
102
102
  debug?: boolean;
103
103
  headers?: Record<string, string>;
104
+ interceptor?: (input: RequestInfo | URL, init?: RequestInit) => Promise<RequestInfo | URL>;
104
105
  }
105
106
  /**
106
107
  * Error Types
package/dist/index.js CHANGED
@@ -35,9 +35,8 @@ __export(src_exports, {
35
35
  });
36
36
  module.exports = __toCommonJS(src_exports);
37
37
 
38
- // ../../node_modules/.pnpm/@a2a-js+sdk@https+++codeload.github.com+v3g42+a2a-js+tar.gz+86c9de0/node_modules/@a2a-js/sdk/dist/chunk-MMZDL2A3.js
38
+ // ../../node_modules/.pnpm/@a2a-js+sdk@https+++codeload.github.com+v3g42+a2a-js+tar.gz+1bed58e/node_modules/@a2a-js/sdk/dist/chunk-IOYJGLJK.js
39
39
  var A2AClient = class {
40
- // To be populated from AgentCard after fetching
41
40
  /**
42
41
  * Constructs an A2AClient instance.
43
42
  * It initiates fetching the agent card from the provided agent baseUrl.
@@ -45,13 +44,16 @@ var A2AClient = class {
45
44
  * The `url` field from the Agent Card will be used as the RPC service endpoint.
46
45
  * @param agentBaseUrl The base URL of the A2A agent (e.g., https://agent.example.com).
47
46
  */
48
- constructor(agentBaseUrl) {
47
+ constructor(agentBaseUrl, fetchFn) {
49
48
  __publicField(this, "agentBaseUrl");
50
49
  __publicField(this, "agentCardPromise");
51
50
  __publicField(this, "requestIdCounter", 1);
52
51
  __publicField(this, "serviceEndpointUrl");
52
+ // To be populated from AgentCard after fetching
53
+ __publicField(this, "fetchFn");
53
54
  this.agentBaseUrl = agentBaseUrl.replace(/\/$/, "");
54
55
  this.agentCardPromise = this._fetchAndCacheAgentCard();
56
+ this.fetchFn = fetchFn || globalThis.fetch;
55
57
  }
56
58
  /**
57
59
  * Fetches the Agent Card from the agent's well-known URI and caches its service endpoint URL.
@@ -61,7 +63,7 @@ var A2AClient = class {
61
63
  async _fetchAndCacheAgentCard() {
62
64
  const agentCardUrl = `${this.agentBaseUrl}/.well-known/agent.json`;
63
65
  try {
64
- const response = await fetch(agentCardUrl, {
66
+ const response = await this.fetchFn(agentCardUrl, {
65
67
  headers: { "Accept": "application/json" }
66
68
  });
67
69
  if (!response.ok) {
@@ -90,7 +92,7 @@ var A2AClient = class {
90
92
  if (agentBaseUrl) {
91
93
  const specificAgentBaseUrl = agentBaseUrl.replace(/\/$/, "");
92
94
  const agentCardUrl = `${specificAgentBaseUrl}/.well-known/agent.json`;
93
- const response = await fetch(agentCardUrl, {
95
+ const response = await this.fetchFn(agentCardUrl, {
94
96
  headers: { "Accept": "application/json" }
95
97
  });
96
98
  if (!response.ok) {
@@ -130,7 +132,7 @@ var A2AClient = class {
130
132
  // Cast because TParams structure varies per method
131
133
  id: requestId
132
134
  };
133
- const httpResponse = await fetch(endpoint, {
135
+ const httpResponse = await this.fetchFn(endpoint, {
134
136
  method: "POST",
135
137
  headers: {
136
138
  "Content-Type": "application/json",
@@ -195,7 +197,7 @@ var A2AClient = class {
195
197
  params,
196
198
  id: clientRequestId
197
199
  };
198
- const response = await fetch(endpoint, {
200
+ const response = await this.fetchFn(endpoint, {
199
201
  method: "POST",
200
202
  headers: {
201
203
  "Content-Type": "application/json",
@@ -288,7 +290,7 @@ var A2AClient = class {
288
290
  params,
289
291
  id: clientRequestId
290
292
  };
291
- const response = await fetch(endpoint, {
293
+ const response = await this.fetchFn(endpoint, {
292
294
  method: "POST",
293
295
  headers: {
294
296
  "Content-Type": "application/json",
@@ -446,7 +448,8 @@ var DistriClient = class {
446
448
  retryAttempts: config.retryAttempts || 3,
447
449
  retryDelay: config.retryDelay || 1e3,
448
450
  debug: config.debug || false,
449
- headers: config.headers || {}
451
+ headers: config.headers || {},
452
+ interceptor: config.interceptor || ((input, _init) => Promise.resolve(input))
450
453
  };
451
454
  this.debug("DistriClient initialized with config:", this.config);
452
455
  }
@@ -508,8 +511,9 @@ var DistriClient = class {
508
511
  */
509
512
  getA2AClient(agentId) {
510
513
  if (!this.agentClients.has(agentId)) {
514
+ const fetchFn = this.fetch;
511
515
  const agentUrl = `${this.config.baseUrl}/agents/${agentId}`;
512
- const client = new A2AClient(agentUrl);
516
+ const client = new A2AClient(agentUrl, fetchFn);
513
517
  this.agentClients.set(agentId, client);
514
518
  this.debug(`Created A2AClient for agent ${agentId} at ${agentUrl}`);
515
519
  }
@@ -639,19 +643,20 @@ var DistriClient = class {
639
643
  /**
640
644
  * Enhanced fetch with retry logic
641
645
  */
642
- async fetch(path, options) {
643
- const url = `${this.config.baseUrl}${path}`;
646
+ async fetch(request, init) {
647
+ const input = await this.config.interceptor(request, init);
648
+ const url = `${this.config.baseUrl}${input}`;
644
649
  let lastError;
645
650
  for (let attempt = 0; attempt <= this.config.retryAttempts; attempt++) {
646
651
  try {
647
652
  const controller = new AbortController();
648
653
  const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
649
654
  const response = await fetch(url, {
650
- ...options,
655
+ ...init,
651
656
  signal: controller.signal,
652
657
  headers: {
653
658
  ...this.config.headers,
654
- ...options?.headers
659
+ ...init?.headers
655
660
  }
656
661
  });
657
662
  clearTimeout(timeoutId);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../../../node_modules/.pnpm/@a2a-js+sdk@https+++codeload.github.com+v3g42+a2a-js+tar.gz+86c9de0/node_modules/@a2a-js/sdk/dist/chunk-MMZDL2A3.js","../src/types.ts","../src/distri-client.ts"],"sourcesContent":["// Main exports for @distri/core package\n\nexport { DistriClient, uuidv4 } from './distri-client';\n\nexport * from './types';\nexport * from \"@a2a-js/sdk/client\";\n","// src/client/client.ts\nvar A2AClient = class {\n agentBaseUrl;\n agentCardPromise;\n requestIdCounter = 1;\n serviceEndpointUrl;\n // To be populated from AgentCard after fetching\n /**\n * Constructs an A2AClient instance.\n * It initiates fetching the agent card from the provided agent baseUrl.\n * The Agent Card is expected at `${agentBaseUrl}/.well-known/agent.json`.\n * The `url` field from the Agent Card will be used as the RPC service endpoint.\n * @param agentBaseUrl The base URL of the A2A agent (e.g., https://agent.example.com).\n */\n constructor(agentBaseUrl) {\n this.agentBaseUrl = agentBaseUrl.replace(/\\/$/, \"\");\n this.agentCardPromise = this._fetchAndCacheAgentCard();\n }\n /**\n * Fetches the Agent Card from the agent's well-known URI and caches its service endpoint URL.\n * This method is called by the constructor.\n * @returns A Promise that resolves to the AgentCard.\n */\n async _fetchAndCacheAgentCard() {\n const agentCardUrl = `${this.agentBaseUrl}/.well-known/agent.json`;\n try {\n const response = await fetch(agentCardUrl, {\n headers: { \"Accept\": \"application/json\" }\n });\n if (!response.ok) {\n throw new Error(`Failed to fetch Agent Card from ${agentCardUrl}: ${response.status} ${response.statusText}`);\n }\n const agentCard = await response.json();\n if (!agentCard.url) {\n throw new Error(\"Fetched Agent Card does not contain a valid 'url' for the service endpoint.\");\n }\n this.serviceEndpointUrl = agentCard.url;\n return agentCard;\n } catch (error) {\n console.error(\"Error fetching or parsing Agent Card:\");\n throw error;\n }\n }\n /**\n * Retrieves the Agent Card.\n * If an `agentBaseUrl` is provided, it fetches the card from that specific URL.\n * Otherwise, it returns the card fetched and cached during client construction.\n * @param agentBaseUrl Optional. The base URL of the agent to fetch the card from.\n * If provided, this will fetch a new card, not use the cached one from the constructor's URL.\n * @returns A Promise that resolves to the AgentCard.\n */\n async getAgentCard(agentBaseUrl) {\n if (agentBaseUrl) {\n const specificAgentBaseUrl = agentBaseUrl.replace(/\\/$/, \"\");\n const agentCardUrl = `${specificAgentBaseUrl}/.well-known/agent.json`;\n const response = await fetch(agentCardUrl, {\n headers: { \"Accept\": \"application/json\" }\n });\n if (!response.ok) {\n throw new Error(`Failed to fetch Agent Card from ${agentCardUrl}: ${response.status} ${response.statusText}`);\n }\n return await response.json();\n }\n return this.agentCardPromise;\n }\n /**\n * Gets the RPC service endpoint URL. Ensures the agent card has been fetched first.\n * @returns A Promise that resolves to the service endpoint URL string.\n */\n async _getServiceEndpoint() {\n if (this.serviceEndpointUrl) {\n return this.serviceEndpointUrl;\n }\n await this.agentCardPromise;\n if (!this.serviceEndpointUrl) {\n throw new Error(\"Agent Card URL for RPC endpoint is not available. Fetching might have failed.\");\n }\n return this.serviceEndpointUrl;\n }\n /**\n * Helper method to make a generic JSON-RPC POST request.\n * @param method The RPC method name.\n * @param params The parameters for the RPC method.\n * @returns A Promise that resolves to the RPC response.\n */\n async _postRpcRequest(method, params) {\n const endpoint = await this._getServiceEndpoint();\n const requestId = this.requestIdCounter++;\n const rpcRequest = {\n jsonrpc: \"2.0\",\n method,\n params,\n // Cast because TParams structure varies per method\n id: requestId\n };\n const httpResponse = await fetch(endpoint, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"Accept\": \"application/json\"\n // Expect JSON response for non-streaming requests\n },\n body: JSON.stringify(rpcRequest)\n });\n if (!httpResponse.ok) {\n let errorBodyText = \"(empty or non-JSON response)\";\n try {\n errorBodyText = await httpResponse.text();\n const errorJson = JSON.parse(errorBodyText);\n if (!errorJson.jsonrpc && errorJson.error) {\n throw new Error(`RPC error for ${method}: ${errorJson.error.message} (Code: ${errorJson.error.code}, HTTP Status: ${httpResponse.status}) Data: ${JSON.stringify(errorJson.error.data)}`);\n } else if (!errorJson.jsonrpc) {\n throw new Error(`HTTP error for ${method}! Status: ${httpResponse.status} ${httpResponse.statusText}. Response: ${errorBodyText}`);\n }\n } catch (e) {\n if (e.message.startsWith(\"RPC error for\") || e.message.startsWith(\"HTTP error for\")) throw e;\n throw new Error(`HTTP error for ${method}! Status: ${httpResponse.status} ${httpResponse.statusText}. Response: ${errorBodyText}`);\n }\n }\n const rpcResponse = await httpResponse.json();\n if (rpcResponse.id !== requestId) {\n console.error(`CRITICAL: RPC response ID mismatch for method ${method}. Expected ${requestId}, got ${rpcResponse.id}. This may lead to incorrect response handling.`);\n }\n return rpcResponse;\n }\n /**\n * Sends a message to the agent.\n * The behavior (blocking/non-blocking) and push notification configuration\n * are specified within the `params.configuration` object.\n * Optionally, `params.message.contextId` or `params.message.taskId` can be provided.\n * @param params The parameters for sending the message, including the message content and configuration.\n * @returns A Promise resolving to SendMessageResponse, which can be a Message, Task, or an error.\n */\n async sendMessage(params) {\n return this._postRpcRequest(\"message/send\", params);\n }\n /**\n * Sends a message to the agent and streams back responses using Server-Sent Events (SSE).\n * Push notification configuration can be specified in `params.configuration`.\n * Optionally, `params.message.contextId` or `params.message.taskId` can be provided.\n * Requires the agent to support streaming (`capabilities.streaming: true` in AgentCard).\n * @param params The parameters for sending the message.\n * @returns An AsyncGenerator yielding A2AStreamEventData (Message, Task, TaskStatusUpdateEvent, or TaskArtifactUpdateEvent).\n * The generator throws an error if streaming is not supported or if an HTTP/SSE error occurs.\n */\n async *sendMessageStream(params) {\n const agentCard = await this.agentCardPromise;\n if (!agentCard.capabilities?.streaming) {\n throw new Error(\"Agent does not support streaming (AgentCard.capabilities.streaming is not true).\");\n }\n const endpoint = await this._getServiceEndpoint();\n const clientRequestId = this.requestIdCounter++;\n const rpcRequest = {\n // This is the initial JSON-RPC request to establish the stream\n jsonrpc: \"2.0\",\n method: \"message/stream\",\n params,\n id: clientRequestId\n };\n const response = await fetch(endpoint, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"Accept\": \"text/event-stream\"\n // Crucial for SSE\n },\n body: JSON.stringify(rpcRequest)\n });\n if (!response.ok) {\n let errorBody = \"\";\n try {\n errorBody = await response.text();\n const errorJson = JSON.parse(errorBody);\n if (errorJson.error) {\n throw new Error(`HTTP error establishing stream for message/stream: ${response.status} ${response.statusText}. RPC Error: ${errorJson.error.message} (Code: ${errorJson.error.code})`);\n }\n } catch (e) {\n if (e.message.startsWith(\"HTTP error establishing stream\")) throw e;\n throw new Error(`HTTP error establishing stream for message/stream: ${response.status} ${response.statusText}. Response: ${errorBody || \"(empty)\"}`);\n }\n throw new Error(`HTTP error establishing stream for message/stream: ${response.status} ${response.statusText}`);\n }\n if (!response.headers.get(\"Content-Type\")?.startsWith(\"text/event-stream\")) {\n throw new Error(\"Invalid response Content-Type for SSE stream. Expected 'text/event-stream'.\");\n }\n yield* this._parseA2ASseStream(response, clientRequestId);\n }\n /**\n * Sets or updates the push notification configuration for a given task.\n * Requires the agent to support push notifications (`capabilities.pushNotifications: true` in AgentCard).\n * @param params Parameters containing the taskId and the TaskPushNotificationConfig.\n * @returns A Promise resolving to SetTaskPushNotificationConfigResponse.\n */\n async setTaskPushNotificationConfig(params) {\n const agentCard = await this.agentCardPromise;\n if (!agentCard.capabilities?.pushNotifications) {\n throw new Error(\"Agent does not support push notifications (AgentCard.capabilities.pushNotifications is not true).\");\n }\n return this._postRpcRequest(\n \"tasks/pushNotificationConfig/set\",\n params\n );\n }\n /**\n * Gets the push notification configuration for a given task.\n * @param params Parameters containing the taskId.\n * @returns A Promise resolving to GetTaskPushNotificationConfigResponse.\n */\n async getTaskPushNotificationConfig(params) {\n return this._postRpcRequest(\n \"tasks/pushNotificationConfig/get\",\n params\n );\n }\n /**\n * Retrieves a task by its ID.\n * @param params Parameters containing the taskId and optional historyLength.\n * @returns A Promise resolving to GetTaskResponse, which contains the Task object or an error.\n */\n async getTask(params) {\n return this._postRpcRequest(\"tasks/get\", params);\n }\n /**\n * Cancels a task by its ID.\n * @param params Parameters containing the taskId.\n * @returns A Promise resolving to CancelTaskResponse, which contains the updated Task object or an error.\n */\n async cancelTask(params) {\n return this._postRpcRequest(\"tasks/cancel\", params);\n }\n /**\n * Resubscribes to a task's event stream using Server-Sent Events (SSE).\n * This is used if a previous SSE connection for an active task was broken.\n * Requires the agent to support streaming (`capabilities.streaming: true` in AgentCard).\n * @param params Parameters containing the taskId.\n * @returns An AsyncGenerator yielding A2AStreamEventData (Message, Task, TaskStatusUpdateEvent, or TaskArtifactUpdateEvent).\n */\n async *resubscribeTask(params) {\n const agentCard = await this.agentCardPromise;\n if (!agentCard.capabilities?.streaming) {\n throw new Error(\"Agent does not support streaming (required for tasks/resubscribe).\");\n }\n const endpoint = await this._getServiceEndpoint();\n const clientRequestId = this.requestIdCounter++;\n const rpcRequest = {\n // Initial JSON-RPC request to establish the stream\n jsonrpc: \"2.0\",\n method: \"tasks/resubscribe\",\n params,\n id: clientRequestId\n };\n const response = await fetch(endpoint, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"Accept\": \"text/event-stream\"\n },\n body: JSON.stringify(rpcRequest)\n });\n if (!response.ok) {\n let errorBody = \"\";\n try {\n errorBody = await response.text();\n const errorJson = JSON.parse(errorBody);\n if (errorJson.error) {\n throw new Error(`HTTP error establishing stream for tasks/resubscribe: ${response.status} ${response.statusText}. RPC Error: ${errorJson.error.message} (Code: ${errorJson.error.code})`);\n }\n } catch (e) {\n if (e.message.startsWith(\"HTTP error establishing stream\")) throw e;\n throw new Error(`HTTP error establishing stream for tasks/resubscribe: ${response.status} ${response.statusText}. Response: ${errorBody || \"(empty)\"}`);\n }\n throw new Error(`HTTP error establishing stream for tasks/resubscribe: ${response.status} ${response.statusText}`);\n }\n if (!response.headers.get(\"Content-Type\")?.startsWith(\"text/event-stream\")) {\n throw new Error(\"Invalid response Content-Type for SSE stream on resubscribe. Expected 'text/event-stream'.\");\n }\n yield* this._parseA2ASseStream(response, clientRequestId);\n }\n /**\n * Parses an HTTP response body as an A2A Server-Sent Event stream.\n * Each 'data' field of an SSE event is expected to be a JSON-RPC 2.0 Response object,\n * specifically a SendStreamingMessageResponse (or similar structure for resubscribe).\n * @param response The HTTP Response object whose body is the SSE stream.\n * @param originalRequestId The ID of the client's JSON-RPC request that initiated this stream.\n * Used to validate the `id` in the streamed JSON-RPC responses.\n * @returns An AsyncGenerator yielding the `result` field of each valid JSON-RPC success response from the stream.\n */\n async *_parseA2ASseStream(response, originalRequestId) {\n if (!response.body) {\n throw new Error(\"SSE response body is undefined. Cannot read stream.\");\n }\n const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();\n let buffer = \"\";\n let eventDataBuffer = \"\";\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n if (eventDataBuffer.trim()) {\n const result = this._processSseEventData(eventDataBuffer, originalRequestId);\n yield result;\n }\n break;\n }\n buffer += value;\n let lineEndIndex;\n while ((lineEndIndex = buffer.indexOf(\"\\n\")) >= 0) {\n const line = buffer.substring(0, lineEndIndex).trim();\n buffer = buffer.substring(lineEndIndex + 1);\n if (line === \"\") {\n if (eventDataBuffer) {\n const result = this._processSseEventData(eventDataBuffer, originalRequestId);\n yield result;\n eventDataBuffer = \"\";\n }\n } else if (line.startsWith(\"data:\")) {\n eventDataBuffer += line.substring(5).trimStart() + \"\\n\";\n } else if (line.startsWith(\":\")) {\n } else if (line.includes(\":\")) {\n }\n }\n }\n } catch (error) {\n console.error(\"Error reading or parsing SSE stream:\", error.message);\n throw error;\n } finally {\n reader.releaseLock();\n }\n }\n /**\n * Processes a single SSE event's data string, expecting it to be a JSON-RPC response.\n * @param jsonData The string content from one or more 'data:' lines of an SSE event.\n * @param originalRequestId The ID of the client's request that initiated the stream.\n * @returns The `result` field of the parsed JSON-RPC success response.\n * @throws Error if data is not valid JSON, not a valid JSON-RPC response, an error response, or ID mismatch.\n */\n _processSseEventData(jsonData, originalRequestId) {\n if (!jsonData.trim()) {\n throw new Error(\"Attempted to process empty SSE event data.\");\n }\n try {\n const sseJsonRpcResponse = JSON.parse(jsonData.replace(/\\n$/, \"\"));\n const a2aStreamResponse = sseJsonRpcResponse;\n if (a2aStreamResponse.id !== originalRequestId) {\n console.warn(`SSE Event's JSON-RPC response ID mismatch. Client request ID: ${originalRequestId}, event response ID: ${a2aStreamResponse.id}.`);\n }\n if (this.isErrorResponse(a2aStreamResponse)) {\n const err = a2aStreamResponse.error;\n throw new Error(`SSE event contained an error: ${err.message} (Code: ${err.code}) Data: ${JSON.stringify(err.data)}`);\n }\n if (!(\"result\" in a2aStreamResponse) || typeof a2aStreamResponse.result === \"undefined\") {\n throw new Error(`SSE event JSON-RPC response is missing 'result' field. Data: ${jsonData}`);\n }\n const successResponse = a2aStreamResponse;\n return successResponse.result;\n } catch (e) {\n if (e.message.startsWith(\"SSE event contained an error\") || e.message.startsWith(\"SSE event JSON-RPC response is missing 'result' field\")) {\n throw e;\n }\n console.error(\"Failed to parse SSE event data string or unexpected JSON-RPC structure:\", jsonData, e);\n throw new Error(`Failed to parse SSE event data: \"${jsonData.substring(0, 100)}...\". Original error: ${e.message}`);\n }\n }\n isErrorResponse(response) {\n return \"error\" in response;\n }\n};\n\nexport {\n A2AClient\n};\n","// Distri Framework Types - Based on A2A Protocol and SSE\nimport { AgentSkill, Message, Task, TaskArtifactUpdateEvent, TaskStatusUpdateEvent } from '@a2a-js/sdk/client';\n\n/**\n * Distri-specific Agent type that wraps A2A AgentCard\n */\nexport interface DistriAgent {\n /** The name of the agent. */\n name: string;\n\n id: string;\n\n /** A brief description of the agent's purpose. */\n description?: string;\n\n /** The version of the agent. */\n version?: string;\n\n /** The system prompt for the agent, if any. */\n system_prompt?: string | null;\n\n /** A list of MCP server definitions associated with the agent. */\n mcp_servers?: McpDefinition[];\n\n /** Settings related to the model used by the agent. */\n model_settings?: ModelSettings;\n\n /** The size of the history to maintain for the agent. */\n history_size?: number;\n\n /** The planning configuration for the agent, if any. */\n plan?: any;\n\n /** A2A-specific fields */\n icon_url?: string;\n\n max_iterations?: number;\n\n skills?: AgentSkill[];\n\n /** List of sub-agents that this agent can transfer control to */\n sub_agents?: string[];\n}\n\nexport interface McpDefinition {\n /** The filter applied to the tools in this MCP definition. */\n filter?: string[];\n\n /** The name of the MCP server. */\n name: string;\n\n /** The type of the MCP server (Tool or Agent). */\n type?: McpServerType; // Use 'type' here instead of 'r#type'\n}\n\n\nexport interface ModelSettings {\n model: string;\n temperature: number;\n max_tokens: number;\n top_p: number;\n frequency_penalty: number;\n presence_penalty: number;\n max_iterations: number;\n provider: ModelProvider;\n /** Additional parameters for the agent, if any. */\n parameters?: any;\n\n /** The format of the response, if specified. */\n response_format?: any;\n}\n\nexport type McpServerType = 'tool' | 'agent';\n\nexport type ModelProvider = 'openai' | 'aigateway';\n\n/**\n * Distri Thread type for conversation management\n */\nexport interface DistriThread {\n id: string;\n title: string;\n agent_id: string;\n agent_name: string;\n updated_at: string;\n message_count: number;\n last_message?: string;\n}\n\nexport interface Agent {\n id: string;\n name: string;\n description: string;\n status: 'online' | 'offline';\n}\n\nexport interface Thread {\n id: string;\n title: string;\n agent_id: string;\n agent_name: string;\n updated_at: string;\n message_count: number;\n last_message?: string;\n}\n\nexport interface ChatProps {\n thread: Thread;\n agent: Agent;\n onThreadUpdate?: () => void;\n}\n\n/**\n * Connection Status\n */\nexport type ConnectionStatus = 'connecting' | 'connected' | 'disconnected' | 'error';\n\n/**\n * Distri Client Configuration\n */\nexport interface DistriClientConfig {\n baseUrl: string;\n apiVersion?: string;\n timeout?: number;\n retryAttempts?: number;\n retryDelay?: number;\n debug?: boolean;\n headers?: Record<string, string>;\n}\n\n/**\n * Error Types\n */\nexport class DistriError extends Error {\n constructor(\n message: string,\n public code: string,\n public details?: any\n ) {\n super(message);\n this.name = 'DistriError';\n }\n}\n\nexport class A2AProtocolError extends DistriError {\n constructor(message: string, details?: any) {\n super(message, 'A2A_PROTOCOL_ERROR', details);\n this.name = 'A2AProtocolError';\n }\n}\n\nexport class ApiError extends DistriError {\n constructor(message: string, public statusCode: number, details?: any) {\n super(message, 'API_ERROR', details);\n this.name = 'ApiError';\n }\n}\n\nexport class ConnectionError extends DistriError {\n constructor(message: string, details?: any) {\n super(message, 'CONNECTION_ERROR', details);\n this.name = 'ConnectionError';\n }\n}\n\n// Re-export A2A types for convenience\nexport type { AgentCard, Message, Task, TaskStatus, MessageSendParams, TaskStatusUpdateEvent, TaskArtifactUpdateEvent } from '@a2a-js/sdk/client';\n\nexport type A2AStreamEventData = Message | TaskStatusUpdateEvent | TaskArtifactUpdateEvent | Task;","import {\n A2AClient,\n Message,\n MessageSendParams,\n Task,\n SendMessageResponse,\n GetTaskResponse,\n\n} from '@a2a-js/sdk/client';\nimport {\n DistriClientConfig,\n DistriError,\n ApiError,\n A2AProtocolError,\n DistriAgent,\n DistriThread,\n A2AStreamEventData\n} from './types';\n/**\n * Enhanced Distri Client that wraps A2AClient and adds Distri-specific features\n */\nexport class DistriClient {\n private config: Required<DistriClientConfig>;\n private agentClients = new Map<string, A2AClient>();\n\n constructor(config: DistriClientConfig) {\n this.config = {\n baseUrl: config.baseUrl.replace(/\\/$/, ''),\n apiVersion: config.apiVersion || 'v1',\n timeout: config.timeout || 30000,\n retryAttempts: config.retryAttempts || 3,\n retryDelay: config.retryDelay || 1000,\n debug: config.debug || false,\n headers: config.headers || {}\n };\n\n this.debug('DistriClient initialized with config:', this.config);\n }\n\n /**\n * Get all available agents from the Distri server\n */\n async getAgents(): Promise<DistriAgent[]> {\n try {\n const response = await this.fetch(`/agents`, {\n headers: {\n ...this.config.headers,\n }\n });\n if (!response.ok) {\n throw new ApiError(`Failed to fetch agents: ${response.statusText}`, response.status);\n }\n\n const agents: DistriAgent[] = await response.json();\n // Temporary fix for agents without an id\n agents.forEach(agent => {\n if (!agent.id) {\n agent.id = agent.name;\n }\n });\n\n return agents;\n } catch (error) {\n if (error instanceof ApiError) throw error;\n throw new DistriError('Failed to fetch agents', 'FETCH_ERROR', error);\n }\n }\n\n /**\n * Get specific agent by ID\n */\n async getAgent(agentId: string): Promise<DistriAgent> {\n try {\n const response = await this.fetch(`/agents/${agentId}`, {\n headers: {\n ...this.config.headers,\n }\n });\n if (!response.ok) {\n if (response.status === 404) {\n throw new ApiError(`Agent not found: ${agentId}`, 404);\n }\n throw new ApiError(`Failed to fetch agent: ${response.statusText}`, response.status);\n }\n\n const agent: DistriAgent = await response.json();\n // If the agent doesn't have an id, set it to the agentId\n if (!agent.id) {\n agent.id = agentId;\n }\n return agent;\n } catch (error) {\n if (error instanceof ApiError) throw error;\n throw new DistriError(`Failed to fetch agent ${agentId}`, 'FETCH_ERROR', error);\n }\n }\n\n /**\n * Get or create A2AClient for an agent\n */\n private getA2AClient(agentId: string): A2AClient {\n if (!this.agentClients.has(agentId)) {\n // Use agent's URL from the configured baseUrl\n const agentUrl = `${this.config.baseUrl}/agents/${agentId}`;\n const client = new A2AClient(agentUrl);\n this.agentClients.set(agentId, client);\n this.debug(`Created A2AClient for agent ${agentId} at ${agentUrl}`);\n }\n return this.agentClients.get(agentId)!;\n }\n\n /**\n * Send a message to an agent\n */\n async sendMessage(agentId: string, params: MessageSendParams): Promise<Message | Task> {\n try {\n const client = this.getA2AClient(agentId);\n\n const response: SendMessageResponse = await client.sendMessage(params);\n\n if ('error' in response && response.error) {\n throw new A2AProtocolError(response.error.message, response.error);\n }\n\n if ('result' in response) {\n const result = response.result;\n this.debug(`Message sent to ${agentId}, got ${result.kind}:`, result);\n return result;\n }\n\n throw new DistriError('Invalid response format', 'INVALID_RESPONSE');\n } catch (error) {\n if (error instanceof A2AProtocolError || error instanceof DistriError) throw error;\n throw new DistriError(`Failed to send message to agent ${agentId}`, 'SEND_MESSAGE_ERROR', error);\n }\n }\n\n /**\n * Send a streaming message to an agent\n */\n async * sendMessageStream(agentId: string, params: MessageSendParams): AsyncGenerator<A2AStreamEventData> {\n try {\n const client = this.getA2AClient(agentId);\n yield* await client.sendMessageStream(params);\n } catch (error) {\n throw new DistriError(`Failed to stream message to agent ${agentId}`, 'STREAM_MESSAGE_ERROR', error);\n }\n }\n\n /**\n * Get task details\n */\n async getTask(agentId: string, taskId: string): Promise<Task> {\n try {\n const client = this.getA2AClient(agentId);\n const response: GetTaskResponse = await client.getTask({ id: taskId });\n\n if ('error' in response && response.error) {\n throw new A2AProtocolError(response.error.message, response.error);\n }\n\n if ('result' in response) {\n const result = response.result;\n this.debug(`Got task ${taskId} from ${agentId}:`, result);\n return result;\n }\n\n throw new DistriError('Invalid response format', 'INVALID_RESPONSE');\n } catch (error) {\n if (error instanceof A2AProtocolError || error instanceof DistriError) throw error;\n throw new DistriError(`Failed to get task ${taskId} from agent ${agentId}`, 'GET_TASK_ERROR', error);\n }\n }\n\n /**\n * Cancel a task\n */\n async cancelTask(agentId: string, taskId: string): Promise<void> {\n try {\n const client = this.getA2AClient(agentId);\n await client.cancelTask({ id: taskId });\n this.debug(`Cancelled task ${taskId} on agent ${agentId}`);\n } catch (error) {\n throw new DistriError(`Failed to cancel task ${taskId} on agent ${agentId}`, 'CANCEL_TASK_ERROR', error);\n }\n }\n\n /**\n * Get threads from Distri server\n */\n async getThreads(): Promise<DistriThread[]> {\n try {\n const response = await this.fetch(`/threads`);\n if (!response.ok) {\n throw new ApiError(`Failed to fetch threads: ${response.statusText}`, response.status);\n }\n\n return await response.json();\n } catch (error) {\n if (error instanceof ApiError) throw error;\n throw new DistriError('Failed to fetch threads', 'FETCH_ERROR', error);\n }\n }\n\n async getThread(threadId: string): Promise<DistriThread> {\n try {\n const response = await this.fetch(`/threads/${threadId}`);\n if (!response.ok) {\n throw new ApiError(`Failed to fetch thread: ${response.statusText}`, response.status);\n }\n return await response.json();\n } catch (error) {\n if (error instanceof ApiError) throw error;\n throw new DistriError(`Failed to fetch thread ${threadId}`, 'FETCH_ERROR', error);\n }\n }\n\n /**\n * Get thread messages\n */\n async getThreadMessages(threadId: string): Promise<Message[]> {\n try {\n const response = await this.fetch(`/threads/${threadId}/messages`);\n if (!response.ok) {\n if (response.status === 404) {\n return []; // Thread not found, return empty messages\n }\n throw new ApiError(`Failed to fetch thread messages: ${response.statusText}`, response.status);\n }\n\n return await response.json();\n } catch (error) {\n if (error instanceof ApiError) throw error;\n throw new DistriError(`Failed to fetch messages for thread ${threadId}`, 'FETCH_ERROR', error);\n }\n }\n\n /**\n * Get the base URL for making direct requests\n */\n get baseUrl(): string {\n return this.config.baseUrl;\n }\n\n /**\n * Enhanced fetch with retry logic\n */\n private async fetch(path: string, options?: RequestInit): Promise<Response> {\n // Construct the full URL using baseUrl\n const url = `${this.config.baseUrl}${path}`;\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= this.config.retryAttempts; attempt++) {\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);\n\n const response = await fetch(url, {\n ...options,\n signal: controller.signal,\n headers: {\n ...this.config.headers,\n ...options?.headers\n }\n });\n\n clearTimeout(timeoutId);\n return response;\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n\n if (attempt < this.config.retryAttempts) {\n this.debug(`Request failed (attempt ${attempt + 1}), retrying in ${this.config.retryDelay}ms...`);\n await this.delay(this.config.retryDelay);\n }\n }\n }\n\n throw lastError!;\n }\n\n /**\n * Delay utility\n */\n private delay(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n }\n\n /**\n * Debug logging\n */\n private debug(...args: any[]): void {\n if (this.config.debug) {\n console.log('[DistriClient]', ...args);\n }\n }\n\n /**\n * Helper method to create A2A messages\n */\n static initMessage(\n\n input: string,\n role: 'agent' | 'user' = 'user',\n contextId?: string,\n messageId?: string,\n taskId?: string\n ): Message {\n return {\n messageId: messageId || uuidv4(),\n role,\n parts: [{ kind: 'text', text: input.trim() }],\n contextId,\n taskId: taskId || uuidv4(),\n kind: 'message'\n };\n }\n\n /**\n * Helper method to create message send parameters\n */\n static initMessageParams(\n message: Message,\n configuration?: MessageSendParams['configuration']\n ): MessageSendParams {\n return {\n message,\n configuration: {\n acceptedOutputModes: ['text/plain'],\n blocking: false, // Default to non-blocking for streaming\n ...configuration\n }\n };\n }\n}\nexport function uuidv4(): string {\n if (typeof crypto?.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n // Fallback for older browsers\n const array = new Uint8Array(16);\n crypto.getRandomValues(array);\n // Per RFC4122 v4\n array[6] = (array[6] & 0x0f) | 0x40;\n array[8] = (array[8] & 0x3f) | 0x80;\n return [...array].map((b, i) =>\n ([4, 6, 8, 10].includes(i) ? '-' : '') + b.toString(16).padStart(2, '0')\n ).join('');\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,IAAI,YAAY,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAapB,YAAY,cAAc;AAZ1B;AACA;AACA,4CAAmB;AACnB;AAUE,SAAK,eAAe,aAAa,QAAQ,OAAO,EAAE;AAClD,SAAK,mBAAmB,KAAK,wBAAwB;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,0BAA0B;AAC9B,UAAM,eAAe,GAAG,KAAK,YAAY;AACzC,QAAI;AACF,YAAM,WAAW,MAAM,MAAM,cAAc;AAAA,QACzC,SAAS,EAAE,UAAU,mBAAmB;AAAA,MAC1C,CAAC;AACD,UAAI,CAAC,SAAS,IAAI;AAChB,cAAM,IAAI,MAAM,mCAAmC,YAAY,KAAK,SAAS,MAAM,IAAI,SAAS,UAAU,EAAE;AAAA,MAC9G;AACA,YAAM,YAAY,MAAM,SAAS,KAAK;AACtC,UAAI,CAAC,UAAU,KAAK;AAClB,cAAM,IAAI,MAAM,6EAA6E;AAAA,MAC/F;AACA,WAAK,qBAAqB,UAAU;AACpC,aAAO;AAAA,IACT,SAAS,OAAO;AACd,cAAQ,MAAM,uCAAuC;AACrD,YAAM;AAAA,IACR;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,aAAa,cAAc;AAC/B,QAAI,cAAc;AAChB,YAAM,uBAAuB,aAAa,QAAQ,OAAO,EAAE;AAC3D,YAAM,eAAe,GAAG,oBAAoB;AAC5C,YAAM,WAAW,MAAM,MAAM,cAAc;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A;AAAA;AAAA,EAKQ,SAAS,MAAmB;AAClC,QAAI,KAAK,OAAO,OAAO;AACrB,cAAQ,IAAI,kBAAkB,GAAG,IAAI;AAAA,IACvC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,YAEL,OACA,OAAyB,QACzB,WACA,WACA,QACS;AACT,WAAO;AAAA,MACL,WAAW,aAAa,OAAO;AAAA,MAC/B;AAAA,MACA,OAAO,CAAC,EAAE,MAAM,QAAQ,MAAM,MAAM,KAAK,EAAE,CAAC;AAAA,MAC5C;AAAA,MACA,QAAQ,UAAU,OAAO;AAAA,MACzB,MAAM;AAAA,IACR;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,kBACL,SACA,eACmB;AACnB,WAAO;AAAA,MACL;AAAA,MACA,eAAe;AAAA,QACb,qBAAqB,CAAC,YAAY;AAAA,QAClC,UAAU;AAAA;AAAA,QACV,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF;AACO,SAAS,SAAiB;AAC/B,MAAI,OAAO,QAAQ,eAAe,YAAY;AAC5C,WAAO,OAAO,WAAW;AAAA,EAC3B;AAEA,QAAM,QAAQ,IAAI,WAAW,EAAE;AAC/B,SAAO,gBAAgB,KAAK;AAE5B,QAAM,CAAC,IAAK,MAAM,CAAC,IAAI,KAAQ;AAC/B,QAAM,CAAC,IAAK,MAAM,CAAC,IAAI,KAAQ;AAC/B,SAAO,CAAC,GAAG,KAAK,EAAE;AAAA,IAAI,CAAC,GAAG,OACvB,CAAC,GAAG,GAAG,GAAG,EAAE,EAAE,SAAS,CAAC,IAAI,MAAM,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AAAA,EACzE,EAAE,KAAK,EAAE;AACX;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../../../node_modules/.pnpm/@a2a-js+sdk@https+++codeload.github.com+v3g42+a2a-js+tar.gz+1bed58e/node_modules/@a2a-js/sdk/dist/chunk-IOYJGLJK.js","../src/types.ts","../src/distri-client.ts"],"sourcesContent":["// Main exports for @distri/core package\n\nexport { DistriClient, uuidv4 } from './distri-client';\n\nexport * from './types';\nexport * from \"@a2a-js/sdk/client\";\n","// src/client/client.ts\nvar A2AClient = class {\n agentBaseUrl;\n agentCardPromise;\n requestIdCounter = 1;\n serviceEndpointUrl;\n // To be populated from AgentCard after fetching\n fetchFn;\n /**\n * Constructs an A2AClient instance.\n * It initiates fetching the agent card from the provided agent baseUrl.\n * The Agent Card is expected at `${agentBaseUrl}/.well-known/agent.json`.\n * The `url` field from the Agent Card will be used as the RPC service endpoint.\n * @param agentBaseUrl The base URL of the A2A agent (e.g., https://agent.example.com).\n */\n constructor(agentBaseUrl, fetchFn) {\n this.agentBaseUrl = agentBaseUrl.replace(/\\/$/, \"\");\n this.agentCardPromise = this._fetchAndCacheAgentCard();\n this.fetchFn = fetchFn || globalThis.fetch;\n }\n /**\n * Fetches the Agent Card from the agent's well-known URI and caches its service endpoint URL.\n * This method is called by the constructor.\n * @returns A Promise that resolves to the AgentCard.\n */\n async _fetchAndCacheAgentCard() {\n const agentCardUrl = `${this.agentBaseUrl}/.well-known/agent.json`;\n try {\n const response = await this.fetchFn(agentCardUrl, {\n headers: { \"Accept\": \"application/json\" }\n });\n if (!response.ok) {\n throw new Error(`Failed to fetch Agent Card from ${agentCardUrl}: ${response.status} ${response.statusText}`);\n }\n const agentCard = await response.json();\n if (!agentCard.url) {\n throw new Error(\"Fetched Agent Card does not contain a valid 'url' for the service endpoint.\");\n }\n this.serviceEndpointUrl = agentCard.url;\n return agentCard;\n } catch (error) {\n console.error(\"Error fetching or parsing Agent Card:\");\n throw error;\n }\n }\n /**\n * Retrieves the Agent Card.\n * If an `agentBaseUrl` is provided, it fetches the card from that specific URL.\n * Otherwise, it returns the card fetched and cached during client construction.\n * @param agentBaseUrl Optional. The base URL of the agent to fetch the card from.\n * If provided, this will fetch a new card, not use the cached one from the constructor's URL.\n * @returns A Promise that resolves to the AgentCard.\n */\n async getAgentCard(agentBaseUrl) {\n if (agentBaseUrl) {\n const specificAgentBaseUrl = agentBaseUrl.replace(/\\/$/, \"\");\n const agentCardUrl = `${specificAgentBaseUrl}/.well-known/agent.json`;\n const response = await this.fetchFn(agentCardUrl, {\n headers: { \"Accept\": \"application/json\" }\n });\n if (!response.ok) {\n throw new Error(`Failed to fetch Agent Card from ${agentCardUrl}: ${response.status} ${response.statusText}`);\n }\n return await response.json();\n }\n return this.agentCardPromise;\n }\n /**\n * Gets the RPC service endpoint URL. Ensures the agent card has been fetched first.\n * @returns A Promise that resolves to the service endpoint URL string.\n */\n async _getServiceEndpoint() {\n if (this.serviceEndpointUrl) {\n return this.serviceEndpointUrl;\n }\n await this.agentCardPromise;\n if (!this.serviceEndpointUrl) {\n throw new Error(\"Agent Card URL for RPC endpoint is not available. Fetching might have failed.\");\n }\n return this.serviceEndpointUrl;\n }\n /**\n * Helper method to make a generic JSON-RPC POST request.\n * @param method The RPC method name.\n * @param params The parameters for the RPC method.\n * @returns A Promise that resolves to the RPC response.\n */\n async _postRpcRequest(method, params) {\n const endpoint = await this._getServiceEndpoint();\n const requestId = this.requestIdCounter++;\n const rpcRequest = {\n jsonrpc: \"2.0\",\n method,\n params,\n // Cast because TParams structure varies per method\n id: requestId\n };\n const httpResponse = await this.fetchFn(endpoint, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"Accept\": \"application/json\"\n // Expect JSON response for non-streaming requests\n },\n body: JSON.stringify(rpcRequest)\n });\n if (!httpResponse.ok) {\n let errorBodyText = \"(empty or non-JSON response)\";\n try {\n errorBodyText = await httpResponse.text();\n const errorJson = JSON.parse(errorBodyText);\n if (!errorJson.jsonrpc && errorJson.error) {\n throw new Error(`RPC error for ${method}: ${errorJson.error.message} (Code: ${errorJson.error.code}, HTTP Status: ${httpResponse.status}) Data: ${JSON.stringify(errorJson.error.data)}`);\n } else if (!errorJson.jsonrpc) {\n throw new Error(`HTTP error for ${method}! Status: ${httpResponse.status} ${httpResponse.statusText}. Response: ${errorBodyText}`);\n }\n } catch (e) {\n if (e.message.startsWith(\"RPC error for\") || e.message.startsWith(\"HTTP error for\")) throw e;\n throw new Error(`HTTP error for ${method}! Status: ${httpResponse.status} ${httpResponse.statusText}. Response: ${errorBodyText}`);\n }\n }\n const rpcResponse = await httpResponse.json();\n if (rpcResponse.id !== requestId) {\n console.error(`CRITICAL: RPC response ID mismatch for method ${method}. Expected ${requestId}, got ${rpcResponse.id}. This may lead to incorrect response handling.`);\n }\n return rpcResponse;\n }\n /**\n * Sends a message to the agent.\n * The behavior (blocking/non-blocking) and push notification configuration\n * are specified within the `params.configuration` object.\n * Optionally, `params.message.contextId` or `params.message.taskId` can be provided.\n * @param params The parameters for sending the message, including the message content and configuration.\n * @returns A Promise resolving to SendMessageResponse, which can be a Message, Task, or an error.\n */\n async sendMessage(params) {\n return this._postRpcRequest(\"message/send\", params);\n }\n /**\n * Sends a message to the agent and streams back responses using Server-Sent Events (SSE).\n * Push notification configuration can be specified in `params.configuration`.\n * Optionally, `params.message.contextId` or `params.message.taskId` can be provided.\n * Requires the agent to support streaming (`capabilities.streaming: true` in AgentCard).\n * @param params The parameters for sending the message.\n * @returns An AsyncGenerator yielding A2AStreamEventData (Message, Task, TaskStatusUpdateEvent, or TaskArtifactUpdateEvent).\n * The generator throws an error if streaming is not supported or if an HTTP/SSE error occurs.\n */\n async *sendMessageStream(params) {\n const agentCard = await this.agentCardPromise;\n if (!agentCard.capabilities?.streaming) {\n throw new Error(\"Agent does not support streaming (AgentCard.capabilities.streaming is not true).\");\n }\n const endpoint = await this._getServiceEndpoint();\n const clientRequestId = this.requestIdCounter++;\n const rpcRequest = {\n // This is the initial JSON-RPC request to establish the stream\n jsonrpc: \"2.0\",\n method: \"message/stream\",\n params,\n id: clientRequestId\n };\n const response = await this.fetchFn(endpoint, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"Accept\": \"text/event-stream\"\n // Crucial for SSE\n },\n body: JSON.stringify(rpcRequest)\n });\n if (!response.ok) {\n let errorBody = \"\";\n try {\n errorBody = await response.text();\n const errorJson = JSON.parse(errorBody);\n if (errorJson.error) {\n throw new Error(`HTTP error establishing stream for message/stream: ${response.status} ${response.statusText}. RPC Error: ${errorJson.error.message} (Code: ${errorJson.error.code})`);\n }\n } catch (e) {\n if (e.message.startsWith(\"HTTP error establishing stream\")) throw e;\n throw new Error(`HTTP error establishing stream for message/stream: ${response.status} ${response.statusText}. Response: ${errorBody || \"(empty)\"}`);\n }\n throw new Error(`HTTP error establishing stream for message/stream: ${response.status} ${response.statusText}`);\n }\n if (!response.headers.get(\"Content-Type\")?.startsWith(\"text/event-stream\")) {\n throw new Error(\"Invalid response Content-Type for SSE stream. Expected 'text/event-stream'.\");\n }\n yield* this._parseA2ASseStream(response, clientRequestId);\n }\n /**\n * Sets or updates the push notification configuration for a given task.\n * Requires the agent to support push notifications (`capabilities.pushNotifications: true` in AgentCard).\n * @param params Parameters containing the taskId and the TaskPushNotificationConfig.\n * @returns A Promise resolving to SetTaskPushNotificationConfigResponse.\n */\n async setTaskPushNotificationConfig(params) {\n const agentCard = await this.agentCardPromise;\n if (!agentCard.capabilities?.pushNotifications) {\n throw new Error(\"Agent does not support push notifications (AgentCard.capabilities.pushNotifications is not true).\");\n }\n return this._postRpcRequest(\n \"tasks/pushNotificationConfig/set\",\n params\n );\n }\n /**\n * Gets the push notification configuration for a given task.\n * @param params Parameters containing the taskId.\n * @returns A Promise resolving to GetTaskPushNotificationConfigResponse.\n */\n async getTaskPushNotificationConfig(params) {\n return this._postRpcRequest(\n \"tasks/pushNotificationConfig/get\",\n params\n );\n }\n /**\n * Retrieves a task by its ID.\n * @param params Parameters containing the taskId and optional historyLength.\n * @returns A Promise resolving to GetTaskResponse, which contains the Task object or an error.\n */\n async getTask(params) {\n return this._postRpcRequest(\"tasks/get\", params);\n }\n /**\n * Cancels a task by its ID.\n * @param params Parameters containing the taskId.\n * @returns A Promise resolving to CancelTaskResponse, which contains the updated Task object or an error.\n */\n async cancelTask(params) {\n return this._postRpcRequest(\"tasks/cancel\", params);\n }\n /**\n * Resubscribes to a task's event stream using Server-Sent Events (SSE).\n * This is used if a previous SSE connection for an active task was broken.\n * Requires the agent to support streaming (`capabilities.streaming: true` in AgentCard).\n * @param params Parameters containing the taskId.\n * @returns An AsyncGenerator yielding A2AStreamEventData (Message, Task, TaskStatusUpdateEvent, or TaskArtifactUpdateEvent).\n */\n async *resubscribeTask(params) {\n const agentCard = await this.agentCardPromise;\n if (!agentCard.capabilities?.streaming) {\n throw new Error(\"Agent does not support streaming (required for tasks/resubscribe).\");\n }\n const endpoint = await this._getServiceEndpoint();\n const clientRequestId = this.requestIdCounter++;\n const rpcRequest = {\n // Initial JSON-RPC request to establish the stream\n jsonrpc: \"2.0\",\n method: \"tasks/resubscribe\",\n params,\n id: clientRequestId\n };\n const response = await this.fetchFn(endpoint, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"Accept\": \"text/event-stream\"\n },\n body: JSON.stringify(rpcRequest)\n });\n if (!response.ok) {\n let errorBody = \"\";\n try {\n errorBody = await response.text();\n const errorJson = JSON.parse(errorBody);\n if (errorJson.error) {\n throw new Error(`HTTP error establishing stream for tasks/resubscribe: ${response.status} ${response.statusText}. RPC Error: ${errorJson.error.message} (Code: ${errorJson.error.code})`);\n }\n } catch (e) {\n if (e.message.startsWith(\"HTTP error establishing stream\")) throw e;\n throw new Error(`HTTP error establishing stream for tasks/resubscribe: ${response.status} ${response.statusText}. Response: ${errorBody || \"(empty)\"}`);\n }\n throw new Error(`HTTP error establishing stream for tasks/resubscribe: ${response.status} ${response.statusText}`);\n }\n if (!response.headers.get(\"Content-Type\")?.startsWith(\"text/event-stream\")) {\n throw new Error(\"Invalid response Content-Type for SSE stream on resubscribe. Expected 'text/event-stream'.\");\n }\n yield* this._parseA2ASseStream(response, clientRequestId);\n }\n /**\n * Parses an HTTP response body as an A2A Server-Sent Event stream.\n * Each 'data' field of an SSE event is expected to be a JSON-RPC 2.0 Response object,\n * specifically a SendStreamingMessageResponse (or similar structure for resubscribe).\n * @param response The HTTP Response object whose body is the SSE stream.\n * @param originalRequestId The ID of the client's JSON-RPC request that initiated this stream.\n * Used to validate the `id` in the streamed JSON-RPC responses.\n * @returns An AsyncGenerator yielding the `result` field of each valid JSON-RPC success response from the stream.\n */\n async *_parseA2ASseStream(response, originalRequestId) {\n if (!response.body) {\n throw new Error(\"SSE response body is undefined. Cannot read stream.\");\n }\n const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();\n let buffer = \"\";\n let eventDataBuffer = \"\";\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n if (eventDataBuffer.trim()) {\n const result = this._processSseEventData(eventDataBuffer, originalRequestId);\n yield result;\n }\n break;\n }\n buffer += value;\n let lineEndIndex;\n while ((lineEndIndex = buffer.indexOf(\"\\n\")) >= 0) {\n const line = buffer.substring(0, lineEndIndex).trim();\n buffer = buffer.substring(lineEndIndex + 1);\n if (line === \"\") {\n if (eventDataBuffer) {\n const result = this._processSseEventData(eventDataBuffer, originalRequestId);\n yield result;\n eventDataBuffer = \"\";\n }\n } else if (line.startsWith(\"data:\")) {\n eventDataBuffer += line.substring(5).trimStart() + \"\\n\";\n } else if (line.startsWith(\":\")) {\n } else if (line.includes(\":\")) {\n }\n }\n }\n } catch (error) {\n console.error(\"Error reading or parsing SSE stream:\", error.message);\n throw error;\n } finally {\n reader.releaseLock();\n }\n }\n /**\n * Processes a single SSE event's data string, expecting it to be a JSON-RPC response.\n * @param jsonData The string content from one or more 'data:' lines of an SSE event.\n * @param originalRequestId The ID of the client's request that initiated the stream.\n * @returns The `result` field of the parsed JSON-RPC success response.\n * @throws Error if data is not valid JSON, not a valid JSON-RPC response, an error response, or ID mismatch.\n */\n _processSseEventData(jsonData, originalRequestId) {\n if (!jsonData.trim()) {\n throw new Error(\"Attempted to process empty SSE event data.\");\n }\n try {\n const sseJsonRpcResponse = JSON.parse(jsonData.replace(/\\n$/, \"\"));\n const a2aStreamResponse = sseJsonRpcResponse;\n if (a2aStreamResponse.id !== originalRequestId) {\n console.warn(`SSE Event's JSON-RPC response ID mismatch. Client request ID: ${originalRequestId}, event response ID: ${a2aStreamResponse.id}.`);\n }\n if (this.isErrorResponse(a2aStreamResponse)) {\n const err = a2aStreamResponse.error;\n throw new Error(`SSE event contained an error: ${err.message} (Code: ${err.code}) Data: ${JSON.stringify(err.data)}`);\n }\n if (!(\"result\" in a2aStreamResponse) || typeof a2aStreamResponse.result === \"undefined\") {\n throw new Error(`SSE event JSON-RPC response is missing 'result' field. Data: ${jsonData}`);\n }\n const successResponse = a2aStreamResponse;\n return successResponse.result;\n } catch (e) {\n if (e.message.startsWith(\"SSE event contained an error\") || e.message.startsWith(\"SSE event JSON-RPC response is missing 'result' field\")) {\n throw e;\n }\n console.error(\"Failed to parse SSE event data string or unexpected JSON-RPC structure:\", jsonData, e);\n throw new Error(`Failed to parse SSE event data: \"${jsonData.substring(0, 100)}...\". Original error: ${e.message}`);\n }\n }\n isErrorResponse(response) {\n return \"error\" in response;\n }\n};\n\nexport {\n A2AClient\n};\n","// Distri Framework Types - Based on A2A Protocol and SSE\nimport { AgentSkill, Message, Task, TaskArtifactUpdateEvent, TaskStatusUpdateEvent } from '@a2a-js/sdk/client';\n\n/**\n * Distri-specific Agent type that wraps A2A AgentCard\n */\nexport interface DistriAgent {\n /** The name of the agent. */\n name: string;\n\n id: string;\n\n /** A brief description of the agent's purpose. */\n description?: string;\n\n /** The version of the agent. */\n version?: string;\n\n /** The system prompt for the agent, if any. */\n system_prompt?: string | null;\n\n /** A list of MCP server definitions associated with the agent. */\n mcp_servers?: McpDefinition[];\n\n /** Settings related to the model used by the agent. */\n model_settings?: ModelSettings;\n\n /** The size of the history to maintain for the agent. */\n history_size?: number;\n\n /** The planning configuration for the agent, if any. */\n plan?: any;\n\n /** A2A-specific fields */\n icon_url?: string;\n\n max_iterations?: number;\n\n skills?: AgentSkill[];\n\n /** List of sub-agents that this agent can transfer control to */\n sub_agents?: string[];\n}\n\nexport interface McpDefinition {\n /** The filter applied to the tools in this MCP definition. */\n filter?: string[];\n\n /** The name of the MCP server. */\n name: string;\n\n /** The type of the MCP server (Tool or Agent). */\n type?: McpServerType; // Use 'type' here instead of 'r#type'\n}\n\n\nexport interface ModelSettings {\n model: string;\n temperature: number;\n max_tokens: number;\n top_p: number;\n frequency_penalty: number;\n presence_penalty: number;\n max_iterations: number;\n provider: ModelProvider;\n /** Additional parameters for the agent, if any. */\n parameters?: any;\n\n /** The format of the response, if specified. */\n response_format?: any;\n}\n\nexport type McpServerType = 'tool' | 'agent';\n\nexport type ModelProvider = 'openai' | 'aigateway';\n\n/**\n * Distri Thread type for conversation management\n */\nexport interface DistriThread {\n id: string;\n title: string;\n agent_id: string;\n agent_name: string;\n updated_at: string;\n message_count: number;\n last_message?: string;\n}\n\nexport interface Agent {\n id: string;\n name: string;\n description: string;\n status: 'online' | 'offline';\n}\n\nexport interface Thread {\n id: string;\n title: string;\n agent_id: string;\n agent_name: string;\n updated_at: string;\n message_count: number;\n last_message?: string;\n}\n\nexport interface ChatProps {\n thread: Thread;\n agent: Agent;\n onThreadUpdate?: () => void;\n}\n\n/**\n * Connection Status\n */\nexport type ConnectionStatus = 'connecting' | 'connected' | 'disconnected' | 'error';\n\n/**\n * Distri Client Configuration\n */\nexport interface DistriClientConfig {\n baseUrl: string;\n apiVersion?: string;\n timeout?: number;\n retryAttempts?: number;\n retryDelay?: number;\n debug?: boolean;\n headers?: Record<string, string>;\n interceptor?: (input: RequestInfo | URL, init?: RequestInit) => Promise<RequestInfo | URL>;\n}\n\n/**\n * Error Types\n */\nexport class DistriError extends Error {\n constructor(\n message: string,\n public code: string,\n public details?: any\n ) {\n super(message);\n this.name = 'DistriError';\n }\n}\n\nexport class A2AProtocolError extends DistriError {\n constructor(message: string, details?: any) {\n super(message, 'A2A_PROTOCOL_ERROR', details);\n this.name = 'A2AProtocolError';\n }\n}\n\nexport class ApiError extends DistriError {\n constructor(message: string, public statusCode: number, details?: any) {\n super(message, 'API_ERROR', details);\n this.name = 'ApiError';\n }\n}\n\nexport class ConnectionError extends DistriError {\n constructor(message: string, details?: any) {\n super(message, 'CONNECTION_ERROR', details);\n this.name = 'ConnectionError';\n }\n}\n\n// Re-export A2A types for convenience\nexport type { AgentCard, Message, Task, TaskStatus, MessageSendParams, TaskStatusUpdateEvent, TaskArtifactUpdateEvent } from '@a2a-js/sdk/client';\n\nexport type A2AStreamEventData = Message | TaskStatusUpdateEvent | TaskArtifactUpdateEvent | Task;","import {\n A2AClient,\n Message,\n MessageSendParams,\n Task,\n SendMessageResponse,\n GetTaskResponse,\n\n} from '@a2a-js/sdk/client';\nimport {\n DistriClientConfig,\n DistriError,\n ApiError,\n A2AProtocolError,\n DistriAgent,\n DistriThread,\n A2AStreamEventData\n} from './types';\n/**\n * Enhanced Distri Client that wraps A2AClient and adds Distri-specific features\n */\nexport class DistriClient {\n private config: Required<DistriClientConfig>;\n private agentClients = new Map<string, A2AClient>();\n\n constructor(config: DistriClientConfig) {\n this.config = {\n baseUrl: config.baseUrl.replace(/\\/$/, ''),\n apiVersion: config.apiVersion || 'v1',\n timeout: config.timeout || 30000,\n retryAttempts: config.retryAttempts || 3,\n retryDelay: config.retryDelay || 1000,\n debug: config.debug || false,\n headers: config.headers || {},\n interceptor: config.interceptor || ((input: RequestInfo | URL, _init?: RequestInit) => Promise.resolve(input))\n };\n\n this.debug('DistriClient initialized with config:', this.config);\n }\n\n\n /**\n * Get all available agents from the Distri server\n */\n async getAgents(): Promise<DistriAgent[]> {\n try {\n const response = await this.fetch(`/agents`, {\n headers: {\n ...this.config.headers,\n }\n });\n if (!response.ok) {\n throw new ApiError(`Failed to fetch agents: ${response.statusText}`, response.status);\n }\n\n const agents: DistriAgent[] = await response.json();\n // Temporary fix for agents without an id\n agents.forEach(agent => {\n if (!agent.id) {\n agent.id = agent.name;\n }\n });\n\n return agents;\n } catch (error) {\n if (error instanceof ApiError) throw error;\n throw new DistriError('Failed to fetch agents', 'FETCH_ERROR', error);\n }\n }\n\n /**\n * Get specific agent by ID\n */\n async getAgent(agentId: string): Promise<DistriAgent> {\n try {\n const response = await this.fetch(`/agents/${agentId}`, {\n headers: {\n ...this.config.headers,\n }\n });\n if (!response.ok) {\n if (response.status === 404) {\n throw new ApiError(`Agent not found: ${agentId}`, 404);\n }\n throw new ApiError(`Failed to fetch agent: ${response.statusText}`, response.status);\n }\n\n const agent: DistriAgent = await response.json();\n // If the agent doesn't have an id, set it to the agentId\n if (!agent.id) {\n agent.id = agentId;\n }\n return agent;\n } catch (error) {\n if (error instanceof ApiError) throw error;\n throw new DistriError(`Failed to fetch agent ${agentId}`, 'FETCH_ERROR', error);\n }\n }\n\n /**\n * Get or create A2AClient for an agent\n */\n private getA2AClient(agentId: string): A2AClient {\n if (!this.agentClients.has(agentId)) {\n // Use agent's URL from the configured baseUrl\n const fetchFn = this.fetch;\n const agentUrl = `${this.config.baseUrl}/agents/${agentId}`;\n const client = new A2AClient(agentUrl, fetchFn);\n this.agentClients.set(agentId, client);\n this.debug(`Created A2AClient for agent ${agentId} at ${agentUrl}`);\n }\n return this.agentClients.get(agentId)!;\n }\n\n /**\n * Send a message to an agent\n */\n async sendMessage(agentId: string, params: MessageSendParams): Promise<Message | Task> {\n try {\n const client = this.getA2AClient(agentId);\n\n const response: SendMessageResponse = await client.sendMessage(params);\n\n if ('error' in response && response.error) {\n throw new A2AProtocolError(response.error.message, response.error);\n }\n\n if ('result' in response) {\n const result = response.result;\n this.debug(`Message sent to ${agentId}, got ${result.kind}:`, result);\n return result;\n }\n\n throw new DistriError('Invalid response format', 'INVALID_RESPONSE');\n } catch (error) {\n if (error instanceof A2AProtocolError || error instanceof DistriError) throw error;\n throw new DistriError(`Failed to send message to agent ${agentId}`, 'SEND_MESSAGE_ERROR', error);\n }\n }\n\n /**\n * Send a streaming message to an agent\n */\n async * sendMessageStream(agentId: string, params: MessageSendParams): AsyncGenerator<A2AStreamEventData> {\n try {\n const client = this.getA2AClient(agentId);\n yield* await client.sendMessageStream(params);\n } catch (error) {\n throw new DistriError(`Failed to stream message to agent ${agentId}`, 'STREAM_MESSAGE_ERROR', error);\n }\n }\n\n /**\n * Get task details\n */\n async getTask(agentId: string, taskId: string): Promise<Task> {\n try {\n const client = this.getA2AClient(agentId);\n const response: GetTaskResponse = await client.getTask({ id: taskId });\n\n if ('error' in response && response.error) {\n throw new A2AProtocolError(response.error.message, response.error);\n }\n\n if ('result' in response) {\n const result = response.result;\n this.debug(`Got task ${taskId} from ${agentId}:`, result);\n return result;\n }\n\n throw new DistriError('Invalid response format', 'INVALID_RESPONSE');\n } catch (error) {\n if (error instanceof A2AProtocolError || error instanceof DistriError) throw error;\n throw new DistriError(`Failed to get task ${taskId} from agent ${agentId}`, 'GET_TASK_ERROR', error);\n }\n }\n\n /**\n * Cancel a task\n */\n async cancelTask(agentId: string, taskId: string): Promise<void> {\n try {\n const client = this.getA2AClient(agentId);\n await client.cancelTask({ id: taskId });\n this.debug(`Cancelled task ${taskId} on agent ${agentId}`);\n } catch (error) {\n throw new DistriError(`Failed to cancel task ${taskId} on agent ${agentId}`, 'CANCEL_TASK_ERROR', error);\n }\n }\n\n /**\n * Get threads from Distri server\n */\n async getThreads(): Promise<DistriThread[]> {\n try {\n const response = await this.fetch(`/threads`);\n if (!response.ok) {\n throw new ApiError(`Failed to fetch threads: ${response.statusText}`, response.status);\n }\n\n return await response.json();\n } catch (error) {\n if (error instanceof ApiError) throw error;\n throw new DistriError('Failed to fetch threads', 'FETCH_ERROR', error);\n }\n }\n\n async getThread(threadId: string): Promise<DistriThread> {\n try {\n const response = await this.fetch(`/threads/${threadId}`);\n if (!response.ok) {\n throw new ApiError(`Failed to fetch thread: ${response.statusText}`, response.status);\n }\n return await response.json();\n } catch (error) {\n if (error instanceof ApiError) throw error;\n throw new DistriError(`Failed to fetch thread ${threadId}`, 'FETCH_ERROR', error);\n }\n }\n\n /**\n * Get thread messages\n */\n async getThreadMessages(threadId: string): Promise<Message[]> {\n try {\n const response = await this.fetch(`/threads/${threadId}/messages`);\n if (!response.ok) {\n if (response.status === 404) {\n return []; // Thread not found, return empty messages\n }\n throw new ApiError(`Failed to fetch thread messages: ${response.statusText}`, response.status);\n }\n\n return await response.json();\n } catch (error) {\n if (error instanceof ApiError) throw error;\n throw new DistriError(`Failed to fetch messages for thread ${threadId}`, 'FETCH_ERROR', error);\n }\n }\n\n /**\n * Get the base URL for making direct requests\n */\n get baseUrl(): string {\n return this.config.baseUrl;\n }\n\n /**\n * Enhanced fetch with retry logic\n */\n private async fetch(request: RequestInfo | URL, init?: RequestInit): Promise<Response> {\n const input = await this.config.interceptor(request, init);\n // Construct the full URL using baseUrl\n const url = `${this.config.baseUrl}${input}`;\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= this.config.retryAttempts; attempt++) {\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);\n\n const response = await fetch(url, {\n ...init,\n signal: controller.signal,\n headers: {\n ...this.config.headers,\n ...init?.headers\n }\n });\n\n clearTimeout(timeoutId);\n return response;\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n\n if (attempt < this.config.retryAttempts) {\n this.debug(`Request failed (attempt ${attempt + 1}), retrying in ${this.config.retryDelay}ms...`);\n await this.delay(this.config.retryDelay);\n }\n }\n }\n\n throw lastError!;\n }\n\n /**\n * Delay utility\n */\n private delay(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n }\n\n /**\n * Debug logging\n */\n private debug(...args: any[]): void {\n if (this.config.debug) {\n console.log('[DistriClient]', ...args);\n }\n }\n\n /**\n * Helper method to create A2A messages\n */\n static initMessage(\n\n input: string,\n role: 'agent' | 'user' = 'user',\n contextId?: string,\n messageId?: string,\n taskId?: string\n ): Message {\n return {\n messageId: messageId || uuidv4(),\n role,\n parts: [{ kind: 'text', text: input.trim() }],\n contextId,\n taskId: taskId || uuidv4(),\n kind: 'message'\n };\n }\n\n /**\n * Helper method to create message send parameters\n */\n static initMessageParams(\n message: Message,\n configuration?: MessageSendParams['configuration']\n ): MessageSendParams {\n return {\n message,\n configuration: {\n acceptedOutputModes: ['text/plain'],\n blocking: false, // Default to non-blocking for streaming\n ...configuration\n }\n };\n }\n}\nexport function uuidv4(): string {\n if (typeof crypto?.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n // Fallback for older browsers\n const array = new Uint8Array(16);\n crypto.getRandomValues(array);\n // Per RFC4122 v4\n array[6] = (array[6] & 0x0f) | 0x40;\n array[8] = (array[8] & 0x3f) | 0x80;\n return [...array].map((b, i) =>\n ([4, 6, 8, 10].includes(i) ? '-' : '') + b.toString(16).padStart(2, '0')\n ).join('');\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,IAAI,YAAY,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcpB,YAAY,cAAc,SAAS;AAbnC;AACA;AACA,4CAAmB;AACnB;AAEA;AAAA;AASE,SAAK,eAAe,aAAa,QAAQ,OAAO,EAAE;AAClD,SAAK,mBAAmB,KAAK,wBAAwB;AACrD,SAAK,UAAU,WAAW,WAAW;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,0BAA0B;AAC9B,UAAM,eAAe,GAAG,KAAK,YAAY;AACzC,QAAI;AACF,YAAM,WAAW,MAAM,KAAK,QAAQ,cAAc;AAAA,QAChD,SAAS,EAAE,UAAU,mBAAmB;AAAA,MAC1C,CAAC;AACD,UAAI,CAAC,SAAS,IAAI;AAChB,cAAM,IAAI,MAAM,mCAAmC,YAAY,KAAK,SAAS,MAAM,IAAI,SAAS,UAAU,EAAE;AAAA,MAC9G;AACA,YAAM,YAAY,MAAM,SAAS,KAAK;AACtC,UAAI,CAAC,UAAU,KAAK;AAClB,cAAM,IAAI,MAAM,6EAA6E;AAAA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AA,EAC3B;AAEA,QAAM,QAAQ,IAAI,WAAW,EAAE;AAC/B,SAAO,gBAAgB,KAAK;AAE5B,QAAM,CAAC,IAAK,MAAM,CAAC,IAAI,KAAQ;AAC/B,QAAM,CAAC,IAAK,MAAM,CAAC,IAAI,KAAQ;AAC/B,SAAO,CAAC,GAAG,KAAK,EAAE;AAAA,IAAI,CAAC,GAAG,OACvB,CAAC,GAAG,GAAG,GAAG,EAAE,EAAE,SAAS,CAAC,IAAI,MAAM,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AAAA,EACzE,EAAE,KAAK,EAAE;AACX;","names":[]}
package/dist/index.mjs CHANGED
@@ -5,9 +5,8 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
 
8
- // ../../node_modules/.pnpm/@a2a-js+sdk@https+++codeload.github.com+v3g42+a2a-js+tar.gz+86c9de0/node_modules/@a2a-js/sdk/dist/chunk-MMZDL2A3.js
8
+ // ../../node_modules/.pnpm/@a2a-js+sdk@https+++codeload.github.com+v3g42+a2a-js+tar.gz+1bed58e/node_modules/@a2a-js/sdk/dist/chunk-IOYJGLJK.js
9
9
  var A2AClient = class {
10
- // To be populated from AgentCard after fetching
11
10
  /**
12
11
  * Constructs an A2AClient instance.
13
12
  * It initiates fetching the agent card from the provided agent baseUrl.
@@ -15,13 +14,16 @@ var A2AClient = class {
15
14
  * The `url` field from the Agent Card will be used as the RPC service endpoint.
16
15
  * @param agentBaseUrl The base URL of the A2A agent (e.g., https://agent.example.com).
17
16
  */
18
- constructor(agentBaseUrl) {
17
+ constructor(agentBaseUrl, fetchFn) {
19
18
  __publicField(this, "agentBaseUrl");
20
19
  __publicField(this, "agentCardPromise");
21
20
  __publicField(this, "requestIdCounter", 1);
22
21
  __publicField(this, "serviceEndpointUrl");
22
+ // To be populated from AgentCard after fetching
23
+ __publicField(this, "fetchFn");
23
24
  this.agentBaseUrl = agentBaseUrl.replace(/\/$/, "");
24
25
  this.agentCardPromise = this._fetchAndCacheAgentCard();
26
+ this.fetchFn = fetchFn || globalThis.fetch;
25
27
  }
26
28
  /**
27
29
  * Fetches the Agent Card from the agent's well-known URI and caches its service endpoint URL.
@@ -31,7 +33,7 @@ var A2AClient = class {
31
33
  async _fetchAndCacheAgentCard() {
32
34
  const agentCardUrl = `${this.agentBaseUrl}/.well-known/agent.json`;
33
35
  try {
34
- const response = await fetch(agentCardUrl, {
36
+ const response = await this.fetchFn(agentCardUrl, {
35
37
  headers: { "Accept": "application/json" }
36
38
  });
37
39
  if (!response.ok) {
@@ -60,7 +62,7 @@ var A2AClient = class {
60
62
  if (agentBaseUrl) {
61
63
  const specificAgentBaseUrl = agentBaseUrl.replace(/\/$/, "");
62
64
  const agentCardUrl = `${specificAgentBaseUrl}/.well-known/agent.json`;
63
- const response = await fetch(agentCardUrl, {
65
+ const response = await this.fetchFn(agentCardUrl, {
64
66
  headers: { "Accept": "application/json" }
65
67
  });
66
68
  if (!response.ok) {
@@ -100,7 +102,7 @@ var A2AClient = class {
100
102
  // Cast because TParams structure varies per method
101
103
  id: requestId
102
104
  };
103
- const httpResponse = await fetch(endpoint, {
105
+ const httpResponse = await this.fetchFn(endpoint, {
104
106
  method: "POST",
105
107
  headers: {
106
108
  "Content-Type": "application/json",
@@ -165,7 +167,7 @@ var A2AClient = class {
165
167
  params,
166
168
  id: clientRequestId
167
169
  };
168
- const response = await fetch(endpoint, {
170
+ const response = await this.fetchFn(endpoint, {
169
171
  method: "POST",
170
172
  headers: {
171
173
  "Content-Type": "application/json",
@@ -258,7 +260,7 @@ var A2AClient = class {
258
260
  params,
259
261
  id: clientRequestId
260
262
  };
261
- const response = await fetch(endpoint, {
263
+ const response = await this.fetchFn(endpoint, {
262
264
  method: "POST",
263
265
  headers: {
264
266
  "Content-Type": "application/json",
@@ -416,7 +418,8 @@ var DistriClient = class {
416
418
  retryAttempts: config.retryAttempts || 3,
417
419
  retryDelay: config.retryDelay || 1e3,
418
420
  debug: config.debug || false,
419
- headers: config.headers || {}
421
+ headers: config.headers || {},
422
+ interceptor: config.interceptor || ((input, _init) => Promise.resolve(input))
420
423
  };
421
424
  this.debug("DistriClient initialized with config:", this.config);
422
425
  }
@@ -478,8 +481,9 @@ var DistriClient = class {
478
481
  */
479
482
  getA2AClient(agentId) {
480
483
  if (!this.agentClients.has(agentId)) {
484
+ const fetchFn = this.fetch;
481
485
  const agentUrl = `${this.config.baseUrl}/agents/${agentId}`;
482
- const client = new A2AClient(agentUrl);
486
+ const client = new A2AClient(agentUrl, fetchFn);
483
487
  this.agentClients.set(agentId, client);
484
488
  this.debug(`Created A2AClient for agent ${agentId} at ${agentUrl}`);
485
489
  }
@@ -609,19 +613,20 @@ var DistriClient = class {
609
613
  /**
610
614
  * Enhanced fetch with retry logic
611
615
  */
612
- async fetch(path, options) {
613
- const url = `${this.config.baseUrl}${path}`;
616
+ async fetch(request, init) {
617
+ const input = await this.config.interceptor(request, init);
618
+ const url = `${this.config.baseUrl}${input}`;
614
619
  let lastError;
615
620
  for (let attempt = 0; attempt <= this.config.retryAttempts; attempt++) {
616
621
  try {
617
622
  const controller = new AbortController();
618
623
  const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
619
624
  const response = await fetch(url, {
620
- ...options,
625
+ ...init,
621
626
  signal: controller.signal,
622
627
  headers: {
623
628
  ...this.config.headers,
624
- ...options?.headers
629
+ ...init?.headers
625
630
  }
626
631
  });
627
632
  clearTimeout(timeoutId);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../node_modules/.pnpm/@a2a-js+sdk@https+++codeload.github.com+v3g42+a2a-js+tar.gz+86c9de0/node_modules/@a2a-js/sdk/dist/chunk-MMZDL2A3.js","../src/types.ts","../src/distri-client.ts"],"sourcesContent":["// src/client/client.ts\nvar A2AClient = class {\n agentBaseUrl;\n agentCardPromise;\n requestIdCounter = 1;\n serviceEndpointUrl;\n // To be populated from AgentCard after fetching\n /**\n * Constructs an A2AClient instance.\n * It initiates fetching the agent card from the provided agent baseUrl.\n * The Agent Card is expected at `${agentBaseUrl}/.well-known/agent.json`.\n * The `url` field from the Agent Card will be used as the RPC service endpoint.\n * @param agentBaseUrl The base URL of the A2A agent (e.g., https://agent.example.com).\n */\n constructor(agentBaseUrl) {\n this.agentBaseUrl = agentBaseUrl.replace(/\\/$/, \"\");\n this.agentCardPromise = this._fetchAndCacheAgentCard();\n }\n /**\n * Fetches the Agent Card from the agent's well-known URI and caches its service endpoint URL.\n * This method is called by the constructor.\n * @returns A Promise that resolves to the AgentCard.\n */\n async _fetchAndCacheAgentCard() {\n const agentCardUrl = `${this.agentBaseUrl}/.well-known/agent.json`;\n try {\n const response = await fetch(agentCardUrl, {\n headers: { \"Accept\": \"application/json\" }\n });\n if (!response.ok) {\n throw new Error(`Failed to fetch Agent Card from ${agentCardUrl}: ${response.status} ${response.statusText}`);\n }\n const agentCard = await response.json();\n if (!agentCard.url) {\n throw new Error(\"Fetched Agent Card does not contain a valid 'url' for the service endpoint.\");\n }\n this.serviceEndpointUrl = agentCard.url;\n return agentCard;\n } catch (error) {\n console.error(\"Error fetching or parsing Agent Card:\");\n throw error;\n }\n }\n /**\n * Retrieves the Agent Card.\n * If an `agentBaseUrl` is provided, it fetches the card from that specific URL.\n * Otherwise, it returns the card fetched and cached during client construction.\n * @param agentBaseUrl Optional. The base URL of the agent to fetch the card from.\n * If provided, this will fetch a new card, not use the cached one from the constructor's URL.\n * @returns A Promise that resolves to the AgentCard.\n */\n async getAgentCard(agentBaseUrl) {\n if (agentBaseUrl) {\n const specificAgentBaseUrl = agentBaseUrl.replace(/\\/$/, \"\");\n const agentCardUrl = `${specificAgentBaseUrl}/.well-known/agent.json`;\n const response = await fetch(agentCardUrl, {\n headers: { \"Accept\": \"application/json\" }\n });\n if (!response.ok) {\n throw new Error(`Failed to fetch Agent Card from ${agentCardUrl}: ${response.status} ${response.statusText}`);\n }\n return await response.json();\n }\n return this.agentCardPromise;\n }\n /**\n * Gets the RPC service endpoint URL. Ensures the agent card has been fetched first.\n * @returns A Promise that resolves to the service endpoint URL string.\n */\n async _getServiceEndpoint() {\n if (this.serviceEndpointUrl) {\n return this.serviceEndpointUrl;\n }\n await this.agentCardPromise;\n if (!this.serviceEndpointUrl) {\n throw new Error(\"Agent Card URL for RPC endpoint is not available. Fetching might have failed.\");\n }\n return this.serviceEndpointUrl;\n }\n /**\n * Helper method to make a generic JSON-RPC POST request.\n * @param method The RPC method name.\n * @param params The parameters for the RPC method.\n * @returns A Promise that resolves to the RPC response.\n */\n async _postRpcRequest(method, params) {\n const endpoint = await this._getServiceEndpoint();\n const requestId = this.requestIdCounter++;\n const rpcRequest = {\n jsonrpc: \"2.0\",\n method,\n params,\n // Cast because TParams structure varies per method\n id: requestId\n };\n const httpResponse = await fetch(endpoint, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"Accept\": \"application/json\"\n // Expect JSON response for non-streaming requests\n },\n body: JSON.stringify(rpcRequest)\n });\n if (!httpResponse.ok) {\n let errorBodyText = \"(empty or non-JSON response)\";\n try {\n errorBodyText = await httpResponse.text();\n const errorJson = JSON.parse(errorBodyText);\n if (!errorJson.jsonrpc && errorJson.error) {\n throw new Error(`RPC error for ${method}: ${errorJson.error.message} (Code: ${errorJson.error.code}, HTTP Status: ${httpResponse.status}) Data: ${JSON.stringify(errorJson.error.data)}`);\n } else if (!errorJson.jsonrpc) {\n throw new Error(`HTTP error for ${method}! Status: ${httpResponse.status} ${httpResponse.statusText}. Response: ${errorBodyText}`);\n }\n } catch (e) {\n if (e.message.startsWith(\"RPC error for\") || e.message.startsWith(\"HTTP error for\")) throw e;\n throw new Error(`HTTP error for ${method}! Status: ${httpResponse.status} ${httpResponse.statusText}. Response: ${errorBodyText}`);\n }\n }\n const rpcResponse = await httpResponse.json();\n if (rpcResponse.id !== requestId) {\n console.error(`CRITICAL: RPC response ID mismatch for method ${method}. Expected ${requestId}, got ${rpcResponse.id}. This may lead to incorrect response handling.`);\n }\n return rpcResponse;\n }\n /**\n * Sends a message to the agent.\n * The behavior (blocking/non-blocking) and push notification configuration\n * are specified within the `params.configuration` object.\n * Optionally, `params.message.contextId` or `params.message.taskId` can be provided.\n * @param params The parameters for sending the message, including the message content and configuration.\n * @returns A Promise resolving to SendMessageResponse, which can be a Message, Task, or an error.\n */\n async sendMessage(params) {\n return this._postRpcRequest(\"message/send\", params);\n }\n /**\n * Sends a message to the agent and streams back responses using Server-Sent Events (SSE).\n * Push notification configuration can be specified in `params.configuration`.\n * Optionally, `params.message.contextId` or `params.message.taskId` can be provided.\n * Requires the agent to support streaming (`capabilities.streaming: true` in AgentCard).\n * @param params The parameters for sending the message.\n * @returns An AsyncGenerator yielding A2AStreamEventData (Message, Task, TaskStatusUpdateEvent, or TaskArtifactUpdateEvent).\n * The generator throws an error if streaming is not supported or if an HTTP/SSE error occurs.\n */\n async *sendMessageStream(params) {\n const agentCard = await this.agentCardPromise;\n if (!agentCard.capabilities?.streaming) {\n throw new Error(\"Agent does not support streaming (AgentCard.capabilities.streaming is not true).\");\n }\n const endpoint = await this._getServiceEndpoint();\n const clientRequestId = this.requestIdCounter++;\n const rpcRequest = {\n // This is the initial JSON-RPC request to establish the stream\n jsonrpc: \"2.0\",\n method: \"message/stream\",\n params,\n id: clientRequestId\n };\n const response = await fetch(endpoint, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"Accept\": \"text/event-stream\"\n // Crucial for SSE\n },\n body: JSON.stringify(rpcRequest)\n });\n if (!response.ok) {\n let errorBody = \"\";\n try {\n errorBody = await response.text();\n const errorJson = JSON.parse(errorBody);\n if (errorJson.error) {\n throw new Error(`HTTP error establishing stream for message/stream: ${response.status} ${response.statusText}. RPC Error: ${errorJson.error.message} (Code: ${errorJson.error.code})`);\n }\n } catch (e) {\n if (e.message.startsWith(\"HTTP error establishing stream\")) throw e;\n throw new Error(`HTTP error establishing stream for message/stream: ${response.status} ${response.statusText}. Response: ${errorBody || \"(empty)\"}`);\n }\n throw new Error(`HTTP error establishing stream for message/stream: ${response.status} ${response.statusText}`);\n }\n if (!response.headers.get(\"Content-Type\")?.startsWith(\"text/event-stream\")) {\n throw new Error(\"Invalid response Content-Type for SSE stream. Expected 'text/event-stream'.\");\n }\n yield* this._parseA2ASseStream(response, clientRequestId);\n }\n /**\n * Sets or updates the push notification configuration for a given task.\n * Requires the agent to support push notifications (`capabilities.pushNotifications: true` in AgentCard).\n * @param params Parameters containing the taskId and the TaskPushNotificationConfig.\n * @returns A Promise resolving to SetTaskPushNotificationConfigResponse.\n */\n async setTaskPushNotificationConfig(params) {\n const agentCard = await this.agentCardPromise;\n if (!agentCard.capabilities?.pushNotifications) {\n throw new Error(\"Agent does not support push notifications (AgentCard.capabilities.pushNotifications is not true).\");\n }\n return this._postRpcRequest(\n \"tasks/pushNotificationConfig/set\",\n params\n );\n }\n /**\n * Gets the push notification configuration for a given task.\n * @param params Parameters containing the taskId.\n * @returns A Promise resolving to GetTaskPushNotificationConfigResponse.\n */\n async getTaskPushNotificationConfig(params) {\n return this._postRpcRequest(\n \"tasks/pushNotificationConfig/get\",\n params\n );\n }\n /**\n * Retrieves a task by its ID.\n * @param params Parameters containing the taskId and optional historyLength.\n * @returns A Promise resolving to GetTaskResponse, which contains the Task object or an error.\n */\n async getTask(params) {\n return this._postRpcRequest(\"tasks/get\", params);\n }\n /**\n * Cancels a task by its ID.\n * @param params Parameters containing the taskId.\n * @returns A Promise resolving to CancelTaskResponse, which contains the updated Task object or an error.\n */\n async cancelTask(params) {\n return this._postRpcRequest(\"tasks/cancel\", params);\n }\n /**\n * Resubscribes to a task's event stream using Server-Sent Events (SSE).\n * This is used if a previous SSE connection for an active task was broken.\n * Requires the agent to support streaming (`capabilities.streaming: true` in AgentCard).\n * @param params Parameters containing the taskId.\n * @returns An AsyncGenerator yielding A2AStreamEventData (Message, Task, TaskStatusUpdateEvent, or TaskArtifactUpdateEvent).\n */\n async *resubscribeTask(params) {\n const agentCard = await this.agentCardPromise;\n if (!agentCard.capabilities?.streaming) {\n throw new Error(\"Agent does not support streaming (required for tasks/resubscribe).\");\n }\n const endpoint = await this._getServiceEndpoint();\n const clientRequestId = this.requestIdCounter++;\n const rpcRequest = {\n // Initial JSON-RPC request to establish the stream\n jsonrpc: \"2.0\",\n method: \"tasks/resubscribe\",\n params,\n id: clientRequestId\n };\n const response = await fetch(endpoint, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"Accept\": \"text/event-stream\"\n },\n body: JSON.stringify(rpcRequest)\n });\n if (!response.ok) {\n let errorBody = \"\";\n try {\n errorBody = await response.text();\n const errorJson = JSON.parse(errorBody);\n if (errorJson.error) {\n throw new Error(`HTTP error establishing stream for tasks/resubscribe: ${response.status} ${response.statusText}. RPC Error: ${errorJson.error.message} (Code: ${errorJson.error.code})`);\n }\n } catch (e) {\n if (e.message.startsWith(\"HTTP error establishing stream\")) throw e;\n throw new Error(`HTTP error establishing stream for tasks/resubscribe: ${response.status} ${response.statusText}. Response: ${errorBody || \"(empty)\"}`);\n }\n throw new Error(`HTTP error establishing stream for tasks/resubscribe: ${response.status} ${response.statusText}`);\n }\n if (!response.headers.get(\"Content-Type\")?.startsWith(\"text/event-stream\")) {\n throw new Error(\"Invalid response Content-Type for SSE stream on resubscribe. Expected 'text/event-stream'.\");\n }\n yield* this._parseA2ASseStream(response, clientRequestId);\n }\n /**\n * Parses an HTTP response body as an A2A Server-Sent Event stream.\n * Each 'data' field of an SSE event is expected to be a JSON-RPC 2.0 Response object,\n * specifically a SendStreamingMessageResponse (or similar structure for resubscribe).\n * @param response The HTTP Response object whose body is the SSE stream.\n * @param originalRequestId The ID of the client's JSON-RPC request that initiated this stream.\n * Used to validate the `id` in the streamed JSON-RPC responses.\n * @returns An AsyncGenerator yielding the `result` field of each valid JSON-RPC success response from the stream.\n */\n async *_parseA2ASseStream(response, originalRequestId) {\n if (!response.body) {\n throw new Error(\"SSE response body is undefined. Cannot read stream.\");\n }\n const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();\n let buffer = \"\";\n let eventDataBuffer = \"\";\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n if (eventDataBuffer.trim()) {\n const result = this._processSseEventData(eventDataBuffer, originalRequestId);\n yield result;\n }\n break;\n }\n buffer += value;\n let lineEndIndex;\n while ((lineEndIndex = buffer.indexOf(\"\\n\")) >= 0) {\n const line = buffer.substring(0, lineEndIndex).trim();\n buffer = buffer.substring(lineEndIndex + 1);\n if (line === \"\") {\n if (eventDataBuffer) {\n const result = this._processSseEventData(eventDataBuffer, originalRequestId);\n yield result;\n eventDataBuffer = \"\";\n }\n } else if (line.startsWith(\"data:\")) {\n eventDataBuffer += line.substring(5).trimStart() + \"\\n\";\n } else if (line.startsWith(\":\")) {\n } else if (line.includes(\":\")) {\n }\n }\n }\n } catch (error) {\n console.error(\"Error reading or parsing SSE stream:\", error.message);\n throw error;\n } finally {\n reader.releaseLock();\n }\n }\n /**\n * Processes a single SSE event's data string, expecting it to be a JSON-RPC response.\n * @param jsonData The string content from one or more 'data:' lines of an SSE event.\n * @param originalRequestId The ID of the client's request that initiated the stream.\n * @returns The `result` field of the parsed JSON-RPC success response.\n * @throws Error if data is not valid JSON, not a valid JSON-RPC response, an error response, or ID mismatch.\n */\n _processSseEventData(jsonData, originalRequestId) {\n if (!jsonData.trim()) {\n throw new Error(\"Attempted to process empty SSE event data.\");\n }\n try {\n const sseJsonRpcResponse = JSON.parse(jsonData.replace(/\\n$/, \"\"));\n const a2aStreamResponse = sseJsonRpcResponse;\n if (a2aStreamResponse.id !== originalRequestId) {\n console.warn(`SSE Event's JSON-RPC response ID mismatch. Client request ID: ${originalRequestId}, event response ID: ${a2aStreamResponse.id}.`);\n }\n if (this.isErrorResponse(a2aStreamResponse)) {\n const err = a2aStreamResponse.error;\n throw new Error(`SSE event contained an error: ${err.message} (Code: ${err.code}) Data: ${JSON.stringify(err.data)}`);\n }\n if (!(\"result\" in a2aStreamResponse) || typeof a2aStreamResponse.result === \"undefined\") {\n throw new Error(`SSE event JSON-RPC response is missing 'result' field. Data: ${jsonData}`);\n }\n const successResponse = a2aStreamResponse;\n return successResponse.result;\n } catch (e) {\n if (e.message.startsWith(\"SSE event contained an error\") || e.message.startsWith(\"SSE event JSON-RPC response is missing 'result' field\")) {\n throw e;\n }\n console.error(\"Failed to parse SSE event data string or unexpected JSON-RPC structure:\", jsonData, e);\n throw new Error(`Failed to parse SSE event data: \"${jsonData.substring(0, 100)}...\". Original error: ${e.message}`);\n }\n }\n isErrorResponse(response) {\n return \"error\" in response;\n }\n};\n\nexport {\n A2AClient\n};\n","// Distri Framework Types - Based on A2A Protocol and SSE\nimport { AgentSkill, Message, Task, TaskArtifactUpdateEvent, TaskStatusUpdateEvent } from '@a2a-js/sdk/client';\n\n/**\n * Distri-specific Agent type that wraps A2A AgentCard\n */\nexport interface DistriAgent {\n /** The name of the agent. */\n name: string;\n\n id: string;\n\n /** A brief description of the agent's purpose. */\n description?: string;\n\n /** The version of the agent. */\n version?: string;\n\n /** The system prompt for the agent, if any. */\n system_prompt?: string | null;\n\n /** A list of MCP server definitions associated with the agent. */\n mcp_servers?: McpDefinition[];\n\n /** Settings related to the model used by the agent. */\n model_settings?: ModelSettings;\n\n /** The size of the history to maintain for the agent. */\n history_size?: number;\n\n /** The planning configuration for the agent, if any. */\n plan?: any;\n\n /** A2A-specific fields */\n icon_url?: string;\n\n max_iterations?: number;\n\n skills?: AgentSkill[];\n\n /** List of sub-agents that this agent can transfer control to */\n sub_agents?: string[];\n}\n\nexport interface McpDefinition {\n /** The filter applied to the tools in this MCP definition. */\n filter?: string[];\n\n /** The name of the MCP server. */\n name: string;\n\n /** The type of the MCP server (Tool or Agent). */\n type?: McpServerType; // Use 'type' here instead of 'r#type'\n}\n\n\nexport interface ModelSettings {\n model: string;\n temperature: number;\n max_tokens: number;\n top_p: number;\n frequency_penalty: number;\n presence_penalty: number;\n max_iterations: number;\n provider: ModelProvider;\n /** Additional parameters for the agent, if any. */\n parameters?: any;\n\n /** The format of the response, if specified. */\n response_format?: any;\n}\n\nexport type McpServerType = 'tool' | 'agent';\n\nexport type ModelProvider = 'openai' | 'aigateway';\n\n/**\n * Distri Thread type for conversation management\n */\nexport interface DistriThread {\n id: string;\n title: string;\n agent_id: string;\n agent_name: string;\n updated_at: string;\n message_count: number;\n last_message?: string;\n}\n\nexport interface Agent {\n id: string;\n name: string;\n description: string;\n status: 'online' | 'offline';\n}\n\nexport interface Thread {\n id: string;\n title: string;\n agent_id: string;\n agent_name: string;\n updated_at: string;\n message_count: number;\n last_message?: string;\n}\n\nexport interface ChatProps {\n thread: Thread;\n agent: Agent;\n onThreadUpdate?: () => void;\n}\n\n/**\n * Connection Status\n */\nexport type ConnectionStatus = 'connecting' | 'connected' | 'disconnected' | 'error';\n\n/**\n * Distri Client Configuration\n */\nexport interface DistriClientConfig {\n baseUrl: string;\n apiVersion?: string;\n timeout?: number;\n retryAttempts?: number;\n retryDelay?: number;\n debug?: boolean;\n headers?: Record<string, string>;\n}\n\n/**\n * Error Types\n */\nexport class DistriError extends Error {\n constructor(\n message: string,\n public code: string,\n public details?: any\n ) {\n super(message);\n this.name = 'DistriError';\n }\n}\n\nexport class A2AProtocolError extends DistriError {\n constructor(message: string, details?: any) {\n super(message, 'A2A_PROTOCOL_ERROR', details);\n this.name = 'A2AProtocolError';\n }\n}\n\nexport class ApiError extends DistriError {\n constructor(message: string, public statusCode: number, details?: any) {\n super(message, 'API_ERROR', details);\n this.name = 'ApiError';\n }\n}\n\nexport class ConnectionError extends DistriError {\n constructor(message: string, details?: any) {\n super(message, 'CONNECTION_ERROR', details);\n this.name = 'ConnectionError';\n }\n}\n\n// Re-export A2A types for convenience\nexport type { AgentCard, Message, Task, TaskStatus, MessageSendParams, TaskStatusUpdateEvent, TaskArtifactUpdateEvent } from '@a2a-js/sdk/client';\n\nexport type A2AStreamEventData = Message | TaskStatusUpdateEvent | TaskArtifactUpdateEvent | Task;","import {\n A2AClient,\n Message,\n MessageSendParams,\n Task,\n SendMessageResponse,\n GetTaskResponse,\n\n} from '@a2a-js/sdk/client';\nimport {\n DistriClientConfig,\n DistriError,\n ApiError,\n A2AProtocolError,\n DistriAgent,\n DistriThread,\n A2AStreamEventData\n} from './types';\n/**\n * Enhanced Distri Client that wraps A2AClient and adds Distri-specific features\n */\nexport class DistriClient {\n private config: Required<DistriClientConfig>;\n private agentClients = new Map<string, A2AClient>();\n\n constructor(config: DistriClientConfig) {\n this.config = {\n baseUrl: config.baseUrl.replace(/\\/$/, ''),\n apiVersion: config.apiVersion || 'v1',\n timeout: config.timeout || 30000,\n retryAttempts: config.retryAttempts || 3,\n retryDelay: config.retryDelay || 1000,\n debug: config.debug || false,\n headers: config.headers || {}\n };\n\n this.debug('DistriClient initialized with config:', this.config);\n }\n\n /**\n * Get all available agents from the Distri server\n */\n async getAgents(): Promise<DistriAgent[]> {\n try {\n const response = await this.fetch(`/agents`, {\n headers: {\n ...this.config.headers,\n }\n });\n if (!response.ok) {\n throw new ApiError(`Failed to fetch agents: ${response.statusText}`, response.status);\n }\n\n const agents: DistriAgent[] = await response.json();\n // Temporary fix for agents without an id\n agents.forEach(agent => {\n if (!agent.id) {\n agent.id = agent.name;\n }\n });\n\n return agents;\n } catch (error) {\n if (error instanceof ApiError) throw error;\n throw new DistriError('Failed to fetch agents', 'FETCH_ERROR', error);\n }\n }\n\n /**\n * Get specific agent by ID\n */\n async getAgent(agentId: string): Promise<DistriAgent> {\n try {\n const response = await this.fetch(`/agents/${agentId}`, {\n headers: {\n ...this.config.headers,\n }\n });\n if (!response.ok) {\n if (response.status === 404) {\n throw new ApiError(`Agent not found: ${agentId}`, 404);\n }\n throw new ApiError(`Failed to fetch agent: ${response.statusText}`, response.status);\n }\n\n const agent: DistriAgent = await response.json();\n // If the agent doesn't have an id, set it to the agentId\n if (!agent.id) {\n agent.id = agentId;\n }\n return agent;\n } catch (error) {\n if (error instanceof ApiError) throw error;\n throw new DistriError(`Failed to fetch agent ${agentId}`, 'FETCH_ERROR', error);\n }\n }\n\n /**\n * Get or create A2AClient for an agent\n */\n private getA2AClient(agentId: string): A2AClient {\n if (!this.agentClients.has(agentId)) {\n // Use agent's URL from the configured baseUrl\n const agentUrl = `${this.config.baseUrl}/agents/${agentId}`;\n const client = new A2AClient(agentUrl);\n this.agentClients.set(agentId, client);\n this.debug(`Created A2AClient for agent ${agentId} at ${agentUrl}`);\n }\n return this.agentClients.get(agentId)!;\n }\n\n /**\n * Send a message to an agent\n */\n async sendMessage(agentId: string, params: MessageSendParams): Promise<Message | Task> {\n try {\n const client = this.getA2AClient(agentId);\n\n const response: SendMessageResponse = await client.sendMessage(params);\n\n if ('error' in response && response.error) {\n throw new A2AProtocolError(response.error.message, response.error);\n }\n\n if ('result' in response) {\n const result = response.result;\n this.debug(`Message sent to ${agentId}, got ${result.kind}:`, result);\n return result;\n }\n\n throw new DistriError('Invalid response format', 'INVALID_RESPONSE');\n } catch (error) {\n if (error instanceof A2AProtocolError || error instanceof DistriError) throw error;\n throw new DistriError(`Failed to send message to agent ${agentId}`, 'SEND_MESSAGE_ERROR', error);\n }\n }\n\n /**\n * Send a streaming message to an agent\n */\n async * sendMessageStream(agentId: string, params: MessageSendParams): AsyncGenerator<A2AStreamEventData> {\n try {\n const client = this.getA2AClient(agentId);\n yield* await client.sendMessageStream(params);\n } catch (error) {\n throw new DistriError(`Failed to stream message to agent ${agentId}`, 'STREAM_MESSAGE_ERROR', error);\n }\n }\n\n /**\n * Get task details\n */\n async getTask(agentId: string, taskId: string): Promise<Task> {\n try {\n const client = this.getA2AClient(agentId);\n const response: GetTaskResponse = await client.getTask({ id: taskId });\n\n if ('error' in response && response.error) {\n throw new A2AProtocolError(response.error.message, response.error);\n }\n\n if ('result' in response) {\n const result = response.result;\n this.debug(`Got task ${taskId} from ${agentId}:`, result);\n return result;\n }\n\n throw new DistriError('Invalid response format', 'INVALID_RESPONSE');\n } catch (error) {\n if (error instanceof A2AProtocolError || error instanceof DistriError) throw error;\n throw new DistriError(`Failed to get task ${taskId} from agent ${agentId}`, 'GET_TASK_ERROR', error);\n }\n }\n\n /**\n * Cancel a task\n */\n async cancelTask(agentId: string, taskId: string): Promise<void> {\n try {\n const client = this.getA2AClient(agentId);\n await client.cancelTask({ id: taskId });\n this.debug(`Cancelled task ${taskId} on agent ${agentId}`);\n } catch (error) {\n throw new DistriError(`Failed to cancel task ${taskId} on agent ${agentId}`, 'CANCEL_TASK_ERROR', error);\n }\n }\n\n /**\n * Get threads from Distri server\n */\n async getThreads(): Promise<DistriThread[]> {\n try {\n const response = await this.fetch(`/threads`);\n if (!response.ok) {\n throw new ApiError(`Failed to fetch threads: ${response.statusText}`, response.status);\n }\n\n return await response.json();\n } catch (error) {\n if (error instanceof ApiError) throw error;\n throw new DistriError('Failed to fetch threads', 'FETCH_ERROR', error);\n }\n }\n\n async getThread(threadId: string): Promise<DistriThread> {\n try {\n const response = await this.fetch(`/threads/${threadId}`);\n if (!response.ok) {\n throw new ApiError(`Failed to fetch thread: ${response.statusText}`, response.status);\n }\n return await response.json();\n } catch (error) {\n if (error instanceof ApiError) throw error;\n throw new DistriError(`Failed to fetch thread ${threadId}`, 'FETCH_ERROR', error);\n }\n }\n\n /**\n * Get thread messages\n */\n async getThreadMessages(threadId: string): Promise<Message[]> {\n try {\n const response = await this.fetch(`/threads/${threadId}/messages`);\n if (!response.ok) {\n if (response.status === 404) {\n return []; // Thread not found, return empty messages\n }\n throw new ApiError(`Failed to fetch thread messages: ${response.statusText}`, response.status);\n }\n\n return await response.json();\n } catch (error) {\n if (error instanceof ApiError) throw error;\n throw new DistriError(`Failed to fetch messages for thread ${threadId}`, 'FETCH_ERROR', error);\n }\n }\n\n /**\n * Get the base URL for making direct requests\n */\n get baseUrl(): string {\n return this.config.baseUrl;\n }\n\n /**\n * Enhanced fetch with retry logic\n */\n private async fetch(path: string, options?: RequestInit): Promise<Response> {\n // Construct the full URL using baseUrl\n const url = `${this.config.baseUrl}${path}`;\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= this.config.retryAttempts; attempt++) {\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);\n\n const response = await fetch(url, {\n ...options,\n signal: controller.signal,\n headers: {\n ...this.config.headers,\n ...options?.headers\n }\n });\n\n clearTimeout(timeoutId);\n return response;\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n\n if (attempt < this.config.retryAttempts) {\n this.debug(`Request failed (attempt ${attempt + 1}), retrying in ${this.config.retryDelay}ms...`);\n await this.delay(this.config.retryDelay);\n }\n }\n }\n\n throw lastError!;\n }\n\n /**\n * Delay utility\n */\n private delay(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n }\n\n /**\n * Debug logging\n */\n private debug(...args: any[]): void {\n if (this.config.debug) {\n console.log('[DistriClient]', ...args);\n }\n }\n\n /**\n * Helper method to create A2A messages\n */\n static initMessage(\n\n input: string,\n role: 'agent' | 'user' = 'user',\n contextId?: string,\n messageId?: string,\n taskId?: string\n ): Message {\n return {\n messageId: messageId || uuidv4(),\n role,\n parts: [{ kind: 'text', text: input.trim() }],\n contextId,\n taskId: taskId || uuidv4(),\n kind: 'message'\n };\n }\n\n /**\n * Helper method to create message send parameters\n */\n static initMessageParams(\n message: Message,\n configuration?: MessageSendParams['configuration']\n ): MessageSendParams {\n return {\n message,\n configuration: {\n acceptedOutputModes: ['text/plain'],\n blocking: false, // Default to non-blocking for streaming\n ...configuration\n }\n };\n }\n}\nexport function uuidv4(): string {\n if (typeof crypto?.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n // Fallback for older browsers\n const array = new Uint8Array(16);\n crypto.getRandomValues(array);\n // Per RFC4122 v4\n array[6] = (array[6] & 0x0f) | 0x40;\n array[8] = (array[8] & 0x3f) | 0x80;\n return [...array].map((b, i) =>\n ([4, 6, 8, 10].includes(i) ? '-' : '') + b.toString(16).padStart(2, '0')\n ).join('');\n}"],"mappings":";;;;;;;;AACA,IAAI,YAAY,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAap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AA,MAC5C;AAAA,MACA,QAAQ,UAAU,OAAO;AAAA,MACzB,MAAM;AAAA,IACR;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,kBACL,SACA,eACmB;AACnB,WAAO;AAAA,MACL;AAAA,MACA,eAAe;AAAA,QACb,qBAAqB,CAAC,YAAY;AAAA,QAClC,UAAU;AAAA;AAAA,QACV,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF;AACO,SAAS,SAAiB;AAC/B,MAAI,OAAO,QAAQ,eAAe,YAAY;AAC5C,WAAO,OAAO,WAAW;AAAA,EAC3B;AAEA,QAAM,QAAQ,IAAI,WAAW,EAAE;AAC/B,SAAO,gBAAgB,KAAK;AAE5B,QAAM,CAAC,IAAK,MAAM,CAAC,IAAI,KAAQ;AAC/B,QAAM,CAAC,IAAK,MAAM,CAAC,IAAI,KAAQ;AAC/B,SAAO,CAAC,GAAG,KAAK,EAAE;AAAA,IAAI,CAAC,GAAG,OACvB,CAAC,GAAG,GAAG,GAAG,EAAE,EAAE,SAAS,CAAC,IAAI,MAAM,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AAAA,EACzE,EAAE,KAAK,EAAE;AACX;","names":[]}
1
+ {"version":3,"sources":["../../../node_modules/.pnpm/@a2a-js+sdk@https+++codeload.github.com+v3g42+a2a-js+tar.gz+1bed58e/node_modules/@a2a-js/sdk/dist/chunk-IOYJGLJK.js","../src/types.ts","../src/distri-client.ts"],"sourcesContent":["// src/client/client.ts\nvar A2AClient = class {\n agentBaseUrl;\n agentCardPromise;\n requestIdCounter = 1;\n serviceEndpointUrl;\n // To be populated from AgentCard after fetching\n fetchFn;\n /**\n * Constructs an A2AClient instance.\n * It initiates fetching the agent card from the provided agent baseUrl.\n * The Agent Card is expected at `${agentBaseUrl}/.well-known/agent.json`.\n * The `url` field from the Agent Card will be used as the RPC service endpoint.\n * @param agentBaseUrl The base URL of the A2A agent (e.g., https://agent.example.com).\n */\n constructor(agentBaseUrl, fetchFn) {\n this.agentBaseUrl = agentBaseUrl.replace(/\\/$/, \"\");\n this.agentCardPromise = this._fetchAndCacheAgentCard();\n this.fetchFn = fetchFn || globalThis.fetch;\n }\n /**\n * Fetches the Agent Card from the agent's well-known URI and caches its service endpoint URL.\n * This method is called by the constructor.\n * @returns A Promise that resolves to the AgentCard.\n */\n async _fetchAndCacheAgentCard() {\n const agentCardUrl = `${this.agentBaseUrl}/.well-known/agent.json`;\n try {\n const response = await this.fetchFn(agentCardUrl, {\n headers: { \"Accept\": \"application/json\" }\n });\n if (!response.ok) {\n throw new Error(`Failed to fetch Agent Card from ${agentCardUrl}: ${response.status} ${response.statusText}`);\n }\n const agentCard = await response.json();\n if (!agentCard.url) {\n throw new Error(\"Fetched Agent Card does not contain a valid 'url' for the service endpoint.\");\n }\n this.serviceEndpointUrl = agentCard.url;\n return agentCard;\n } catch (error) {\n console.error(\"Error fetching or parsing Agent Card:\");\n throw error;\n }\n }\n /**\n * Retrieves the Agent Card.\n * If an `agentBaseUrl` is provided, it fetches the card from that specific URL.\n * Otherwise, it returns the card fetched and cached during client construction.\n * @param agentBaseUrl Optional. The base URL of the agent to fetch the card from.\n * If provided, this will fetch a new card, not use the cached one from the constructor's URL.\n * @returns A Promise that resolves to the AgentCard.\n */\n async getAgentCard(agentBaseUrl) {\n if (agentBaseUrl) {\n const specificAgentBaseUrl = agentBaseUrl.replace(/\\/$/, \"\");\n const agentCardUrl = `${specificAgentBaseUrl}/.well-known/agent.json`;\n const response = await this.fetchFn(agentCardUrl, {\n headers: { \"Accept\": \"application/json\" }\n });\n if (!response.ok) {\n throw new Error(`Failed to fetch Agent Card from ${agentCardUrl}: ${response.status} ${response.statusText}`);\n }\n return await response.json();\n }\n return this.agentCardPromise;\n }\n /**\n * Gets the RPC service endpoint URL. Ensures the agent card has been fetched first.\n * @returns A Promise that resolves to the service endpoint URL string.\n */\n async _getServiceEndpoint() {\n if (this.serviceEndpointUrl) {\n return this.serviceEndpointUrl;\n }\n await this.agentCardPromise;\n if (!this.serviceEndpointUrl) {\n throw new Error(\"Agent Card URL for RPC endpoint is not available. Fetching might have failed.\");\n }\n return this.serviceEndpointUrl;\n }\n /**\n * Helper method to make a generic JSON-RPC POST request.\n * @param method The RPC method name.\n * @param params The parameters for the RPC method.\n * @returns A Promise that resolves to the RPC response.\n */\n async _postRpcRequest(method, params) {\n const endpoint = await this._getServiceEndpoint();\n const requestId = this.requestIdCounter++;\n const rpcRequest = {\n jsonrpc: \"2.0\",\n method,\n params,\n // Cast because TParams structure varies per method\n id: requestId\n };\n const httpResponse = await this.fetchFn(endpoint, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"Accept\": \"application/json\"\n // Expect JSON response for non-streaming requests\n },\n body: JSON.stringify(rpcRequest)\n });\n if (!httpResponse.ok) {\n let errorBodyText = \"(empty or non-JSON response)\";\n try {\n errorBodyText = await httpResponse.text();\n const errorJson = JSON.parse(errorBodyText);\n if (!errorJson.jsonrpc && errorJson.error) {\n throw new Error(`RPC error for ${method}: ${errorJson.error.message} (Code: ${errorJson.error.code}, HTTP Status: ${httpResponse.status}) Data: ${JSON.stringify(errorJson.error.data)}`);\n } else if (!errorJson.jsonrpc) {\n throw new Error(`HTTP error for ${method}! Status: ${httpResponse.status} ${httpResponse.statusText}. Response: ${errorBodyText}`);\n }\n } catch (e) {\n if (e.message.startsWith(\"RPC error for\") || e.message.startsWith(\"HTTP error for\")) throw e;\n throw new Error(`HTTP error for ${method}! Status: ${httpResponse.status} ${httpResponse.statusText}. Response: ${errorBodyText}`);\n }\n }\n const rpcResponse = await httpResponse.json();\n if (rpcResponse.id !== requestId) {\n console.error(`CRITICAL: RPC response ID mismatch for method ${method}. Expected ${requestId}, got ${rpcResponse.id}. This may lead to incorrect response handling.`);\n }\n return rpcResponse;\n }\n /**\n * Sends a message to the agent.\n * The behavior (blocking/non-blocking) and push notification configuration\n * are specified within the `params.configuration` object.\n * Optionally, `params.message.contextId` or `params.message.taskId` can be provided.\n * @param params The parameters for sending the message, including the message content and configuration.\n * @returns A Promise resolving to SendMessageResponse, which can be a Message, Task, or an error.\n */\n async sendMessage(params) {\n return this._postRpcRequest(\"message/send\", params);\n }\n /**\n * Sends a message to the agent and streams back responses using Server-Sent Events (SSE).\n * Push notification configuration can be specified in `params.configuration`.\n * Optionally, `params.message.contextId` or `params.message.taskId` can be provided.\n * Requires the agent to support streaming (`capabilities.streaming: true` in AgentCard).\n * @param params The parameters for sending the message.\n * @returns An AsyncGenerator yielding A2AStreamEventData (Message, Task, TaskStatusUpdateEvent, or TaskArtifactUpdateEvent).\n * The generator throws an error if streaming is not supported or if an HTTP/SSE error occurs.\n */\n async *sendMessageStream(params) {\n const agentCard = await this.agentCardPromise;\n if (!agentCard.capabilities?.streaming) {\n throw new Error(\"Agent does not support streaming (AgentCard.capabilities.streaming is not true).\");\n }\n const endpoint = await this._getServiceEndpoint();\n const clientRequestId = this.requestIdCounter++;\n const rpcRequest = {\n // This is the initial JSON-RPC request to establish the stream\n jsonrpc: \"2.0\",\n method: \"message/stream\",\n params,\n id: clientRequestId\n };\n const response = await this.fetchFn(endpoint, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"Accept\": \"text/event-stream\"\n // Crucial for SSE\n },\n body: JSON.stringify(rpcRequest)\n });\n if (!response.ok) {\n let errorBody = \"\";\n try {\n errorBody = await response.text();\n const errorJson = JSON.parse(errorBody);\n if (errorJson.error) {\n throw new Error(`HTTP error establishing stream for message/stream: ${response.status} ${response.statusText}. RPC Error: ${errorJson.error.message} (Code: ${errorJson.error.code})`);\n }\n } catch (e) {\n if (e.message.startsWith(\"HTTP error establishing stream\")) throw e;\n throw new Error(`HTTP error establishing stream for message/stream: ${response.status} ${response.statusText}. Response: ${errorBody || \"(empty)\"}`);\n }\n throw new Error(`HTTP error establishing stream for message/stream: ${response.status} ${response.statusText}`);\n }\n if (!response.headers.get(\"Content-Type\")?.startsWith(\"text/event-stream\")) {\n throw new Error(\"Invalid response Content-Type for SSE stream. Expected 'text/event-stream'.\");\n }\n yield* this._parseA2ASseStream(response, clientRequestId);\n }\n /**\n * Sets or updates the push notification configuration for a given task.\n * Requires the agent to support push notifications (`capabilities.pushNotifications: true` in AgentCard).\n * @param params Parameters containing the taskId and the TaskPushNotificationConfig.\n * @returns A Promise resolving to SetTaskPushNotificationConfigResponse.\n */\n async setTaskPushNotificationConfig(params) {\n const agentCard = await this.agentCardPromise;\n if (!agentCard.capabilities?.pushNotifications) {\n throw new Error(\"Agent does not support push notifications (AgentCard.capabilities.pushNotifications is not true).\");\n }\n return this._postRpcRequest(\n \"tasks/pushNotificationConfig/set\",\n params\n );\n }\n /**\n * Gets the push notification configuration for a given task.\n * @param params Parameters containing the taskId.\n * @returns A Promise resolving to GetTaskPushNotificationConfigResponse.\n */\n async getTaskPushNotificationConfig(params) {\n return this._postRpcRequest(\n \"tasks/pushNotificationConfig/get\",\n params\n );\n }\n /**\n * Retrieves a task by its ID.\n * @param params Parameters containing the taskId and optional historyLength.\n * @returns A Promise resolving to GetTaskResponse, which contains the Task object or an error.\n */\n async getTask(params) {\n return this._postRpcRequest(\"tasks/get\", params);\n }\n /**\n * Cancels a task by its ID.\n * @param params Parameters containing the taskId.\n * @returns A Promise resolving to CancelTaskResponse, which contains the updated Task object or an error.\n */\n async cancelTask(params) {\n return this._postRpcRequest(\"tasks/cancel\", params);\n }\n /**\n * Resubscribes to a task's event stream using Server-Sent Events (SSE).\n * This is used if a previous SSE connection for an active task was broken.\n * Requires the agent to support streaming (`capabilities.streaming: true` in AgentCard).\n * @param params Parameters containing the taskId.\n * @returns An AsyncGenerator yielding A2AStreamEventData (Message, Task, TaskStatusUpdateEvent, or TaskArtifactUpdateEvent).\n */\n async *resubscribeTask(params) {\n const agentCard = await this.agentCardPromise;\n if (!agentCard.capabilities?.streaming) {\n throw new Error(\"Agent does not support streaming (required for tasks/resubscribe).\");\n }\n const endpoint = await this._getServiceEndpoint();\n const clientRequestId = this.requestIdCounter++;\n const rpcRequest = {\n // Initial JSON-RPC request to establish the stream\n jsonrpc: \"2.0\",\n method: \"tasks/resubscribe\",\n params,\n id: clientRequestId\n };\n const response = await this.fetchFn(endpoint, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"Accept\": \"text/event-stream\"\n },\n body: JSON.stringify(rpcRequest)\n });\n if (!response.ok) {\n let errorBody = \"\";\n try {\n errorBody = await response.text();\n const errorJson = JSON.parse(errorBody);\n if (errorJson.error) {\n throw new Error(`HTTP error establishing stream for tasks/resubscribe: ${response.status} ${response.statusText}. RPC Error: ${errorJson.error.message} (Code: ${errorJson.error.code})`);\n }\n } catch (e) {\n if (e.message.startsWith(\"HTTP error establishing stream\")) throw e;\n throw new Error(`HTTP error establishing stream for tasks/resubscribe: ${response.status} ${response.statusText}. Response: ${errorBody || \"(empty)\"}`);\n }\n throw new Error(`HTTP error establishing stream for tasks/resubscribe: ${response.status} ${response.statusText}`);\n }\n if (!response.headers.get(\"Content-Type\")?.startsWith(\"text/event-stream\")) {\n throw new Error(\"Invalid response Content-Type for SSE stream on resubscribe. Expected 'text/event-stream'.\");\n }\n yield* this._parseA2ASseStream(response, clientRequestId);\n }\n /**\n * Parses an HTTP response body as an A2A Server-Sent Event stream.\n * Each 'data' field of an SSE event is expected to be a JSON-RPC 2.0 Response object,\n * specifically a SendStreamingMessageResponse (or similar structure for resubscribe).\n * @param response The HTTP Response object whose body is the SSE stream.\n * @param originalRequestId The ID of the client's JSON-RPC request that initiated this stream.\n * Used to validate the `id` in the streamed JSON-RPC responses.\n * @returns An AsyncGenerator yielding the `result` field of each valid JSON-RPC success response from the stream.\n */\n async *_parseA2ASseStream(response, originalRequestId) {\n if (!response.body) {\n throw new Error(\"SSE response body is undefined. Cannot read stream.\");\n }\n const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();\n let buffer = \"\";\n let eventDataBuffer = \"\";\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n if (eventDataBuffer.trim()) {\n const result = this._processSseEventData(eventDataBuffer, originalRequestId);\n yield result;\n }\n break;\n }\n buffer += value;\n let lineEndIndex;\n while ((lineEndIndex = buffer.indexOf(\"\\n\")) >= 0) {\n const line = buffer.substring(0, lineEndIndex).trim();\n buffer = buffer.substring(lineEndIndex + 1);\n if (line === \"\") {\n if (eventDataBuffer) {\n const result = this._processSseEventData(eventDataBuffer, originalRequestId);\n yield result;\n eventDataBuffer = \"\";\n }\n } else if (line.startsWith(\"data:\")) {\n eventDataBuffer += line.substring(5).trimStart() + \"\\n\";\n } else if (line.startsWith(\":\")) {\n } else if (line.includes(\":\")) {\n }\n }\n }\n } catch (error) {\n console.error(\"Error reading or parsing SSE stream:\", error.message);\n throw error;\n } finally {\n reader.releaseLock();\n }\n }\n /**\n * Processes a single SSE event's data string, expecting it to be a JSON-RPC response.\n * @param jsonData The string content from one or more 'data:' lines of an SSE event.\n * @param originalRequestId The ID of the client's request that initiated the stream.\n * @returns The `result` field of the parsed JSON-RPC success response.\n * @throws Error if data is not valid JSON, not a valid JSON-RPC response, an error response, or ID mismatch.\n */\n _processSseEventData(jsonData, originalRequestId) {\n if (!jsonData.trim()) {\n throw new Error(\"Attempted to process empty SSE event data.\");\n }\n try {\n const sseJsonRpcResponse = JSON.parse(jsonData.replace(/\\n$/, \"\"));\n const a2aStreamResponse = sseJsonRpcResponse;\n if (a2aStreamResponse.id !== originalRequestId) {\n console.warn(`SSE Event's JSON-RPC response ID mismatch. Client request ID: ${originalRequestId}, event response ID: ${a2aStreamResponse.id}.`);\n }\n if (this.isErrorResponse(a2aStreamResponse)) {\n const err = a2aStreamResponse.error;\n throw new Error(`SSE event contained an error: ${err.message} (Code: ${err.code}) Data: ${JSON.stringify(err.data)}`);\n }\n if (!(\"result\" in a2aStreamResponse) || typeof a2aStreamResponse.result === \"undefined\") {\n throw new Error(`SSE event JSON-RPC response is missing 'result' field. Data: ${jsonData}`);\n }\n const successResponse = a2aStreamResponse;\n return successResponse.result;\n } catch (e) {\n if (e.message.startsWith(\"SSE event contained an error\") || e.message.startsWith(\"SSE event JSON-RPC response is missing 'result' field\")) {\n throw e;\n }\n console.error(\"Failed to parse SSE event data string or unexpected JSON-RPC structure:\", jsonData, e);\n throw new Error(`Failed to parse SSE event data: \"${jsonData.substring(0, 100)}...\". Original error: ${e.message}`);\n }\n }\n isErrorResponse(response) {\n return \"error\" in response;\n }\n};\n\nexport {\n A2AClient\n};\n","// Distri Framework Types - Based on A2A Protocol and SSE\nimport { AgentSkill, Message, Task, TaskArtifactUpdateEvent, TaskStatusUpdateEvent } from '@a2a-js/sdk/client';\n\n/**\n * Distri-specific Agent type that wraps A2A AgentCard\n */\nexport interface DistriAgent {\n /** The name of the agent. */\n name: string;\n\n id: string;\n\n /** A brief description of the agent's purpose. */\n description?: string;\n\n /** The version of the agent. */\n version?: string;\n\n /** The system prompt for the agent, if any. */\n system_prompt?: string | null;\n\n /** A list of MCP server definitions associated with the agent. */\n mcp_servers?: McpDefinition[];\n\n /** Settings related to the model used by the agent. */\n model_settings?: ModelSettings;\n\n /** The size of the history to maintain for the agent. */\n history_size?: number;\n\n /** The planning configuration for the agent, if any. */\n plan?: any;\n\n /** A2A-specific fields */\n icon_url?: string;\n\n max_iterations?: number;\n\n skills?: AgentSkill[];\n\n /** List of sub-agents that this agent can transfer control to */\n sub_agents?: string[];\n}\n\nexport interface McpDefinition {\n /** The filter applied to the tools in this MCP definition. */\n filter?: string[];\n\n /** The name of the MCP server. */\n name: string;\n\n /** The type of the MCP server (Tool or Agent). */\n type?: McpServerType; // Use 'type' here instead of 'r#type'\n}\n\n\nexport interface ModelSettings {\n model: string;\n temperature: number;\n max_tokens: number;\n top_p: number;\n frequency_penalty: number;\n presence_penalty: number;\n max_iterations: number;\n provider: ModelProvider;\n /** Additional parameters for the agent, if any. */\n parameters?: any;\n\n /** The format of the response, if specified. */\n response_format?: any;\n}\n\nexport type McpServerType = 'tool' | 'agent';\n\nexport type ModelProvider = 'openai' | 'aigateway';\n\n/**\n * Distri Thread type for conversation management\n */\nexport interface DistriThread {\n id: string;\n title: string;\n agent_id: string;\n agent_name: string;\n updated_at: string;\n message_count: number;\n last_message?: string;\n}\n\nexport interface Agent {\n id: string;\n name: string;\n description: string;\n status: 'online' | 'offline';\n}\n\nexport interface Thread {\n id: string;\n title: string;\n agent_id: string;\n agent_name: string;\n updated_at: string;\n message_count: number;\n last_message?: string;\n}\n\nexport interface ChatProps {\n thread: Thread;\n agent: Agent;\n onThreadUpdate?: () => void;\n}\n\n/**\n * Connection Status\n */\nexport type ConnectionStatus = 'connecting' | 'connected' | 'disconnected' | 'error';\n\n/**\n * Distri Client Configuration\n */\nexport interface DistriClientConfig {\n baseUrl: string;\n apiVersion?: string;\n timeout?: number;\n retryAttempts?: number;\n retryDelay?: number;\n debug?: boolean;\n headers?: Record<string, string>;\n interceptor?: (input: RequestInfo | URL, init?: RequestInit) => Promise<RequestInfo | URL>;\n}\n\n/**\n * Error Types\n */\nexport class DistriError extends Error {\n constructor(\n message: string,\n public code: string,\n public details?: any\n ) {\n super(message);\n this.name = 'DistriError';\n }\n}\n\nexport class A2AProtocolError extends DistriError {\n constructor(message: string, details?: any) {\n super(message, 'A2A_PROTOCOL_ERROR', details);\n this.name = 'A2AProtocolError';\n }\n}\n\nexport class ApiError extends DistriError {\n constructor(message: string, public statusCode: number, details?: any) {\n super(message, 'API_ERROR', details);\n this.name = 'ApiError';\n }\n}\n\nexport class ConnectionError extends DistriError {\n constructor(message: string, details?: any) {\n super(message, 'CONNECTION_ERROR', details);\n this.name = 'ConnectionError';\n }\n}\n\n// Re-export A2A types for convenience\nexport type { AgentCard, Message, Task, TaskStatus, MessageSendParams, TaskStatusUpdateEvent, TaskArtifactUpdateEvent } from '@a2a-js/sdk/client';\n\nexport type A2AStreamEventData = Message | TaskStatusUpdateEvent | TaskArtifactUpdateEvent | Task;","import {\n A2AClient,\n Message,\n MessageSendParams,\n Task,\n SendMessageResponse,\n GetTaskResponse,\n\n} from '@a2a-js/sdk/client';\nimport {\n DistriClientConfig,\n DistriError,\n ApiError,\n A2AProtocolError,\n DistriAgent,\n DistriThread,\n A2AStreamEventData\n} from './types';\n/**\n * Enhanced Distri Client that wraps A2AClient and adds Distri-specific features\n */\nexport class DistriClient {\n private config: Required<DistriClientConfig>;\n private agentClients = new Map<string, A2AClient>();\n\n constructor(config: DistriClientConfig) {\n this.config = {\n baseUrl: config.baseUrl.replace(/\\/$/, ''),\n apiVersion: config.apiVersion || 'v1',\n timeout: config.timeout || 30000,\n retryAttempts: config.retryAttempts || 3,\n retryDelay: config.retryDelay || 1000,\n debug: config.debug || false,\n headers: config.headers || {},\n interceptor: config.interceptor || ((input: RequestInfo | URL, _init?: RequestInit) => Promise.resolve(input))\n };\n\n this.debug('DistriClient initialized with config:', this.config);\n }\n\n\n /**\n * Get all available agents from the Distri server\n */\n async getAgents(): Promise<DistriAgent[]> {\n try {\n const response = await this.fetch(`/agents`, {\n headers: {\n ...this.config.headers,\n }\n });\n if (!response.ok) {\n throw new ApiError(`Failed to fetch agents: ${response.statusText}`, response.status);\n }\n\n const agents: DistriAgent[] = await response.json();\n // Temporary fix for agents without an id\n agents.forEach(agent => {\n if (!agent.id) {\n agent.id = agent.name;\n }\n });\n\n return agents;\n } catch (error) {\n if (error instanceof ApiError) throw error;\n throw new DistriError('Failed to fetch agents', 'FETCH_ERROR', error);\n }\n }\n\n /**\n * Get specific agent by ID\n */\n async getAgent(agentId: string): Promise<DistriAgent> {\n try {\n const response = await this.fetch(`/agents/${agentId}`, {\n headers: {\n ...this.config.headers,\n }\n });\n if (!response.ok) {\n if (response.status === 404) {\n throw new ApiError(`Agent not found: ${agentId}`, 404);\n }\n throw new ApiError(`Failed to fetch agent: ${response.statusText}`, response.status);\n }\n\n const agent: DistriAgent = await response.json();\n // If the agent doesn't have an id, set it to the agentId\n if (!agent.id) {\n agent.id = agentId;\n }\n return agent;\n } catch (error) {\n if (error instanceof ApiError) throw error;\n throw new DistriError(`Failed to fetch agent ${agentId}`, 'FETCH_ERROR', error);\n }\n }\n\n /**\n * Get or create A2AClient for an agent\n */\n private getA2AClient(agentId: string): A2AClient {\n if (!this.agentClients.has(agentId)) {\n // Use agent's URL from the configured baseUrl\n const fetchFn = this.fetch;\n const agentUrl = `${this.config.baseUrl}/agents/${agentId}`;\n const client = new A2AClient(agentUrl, fetchFn);\n this.agentClients.set(agentId, client);\n this.debug(`Created A2AClient for agent ${agentId} at ${agentUrl}`);\n }\n return this.agentClients.get(agentId)!;\n }\n\n /**\n * Send a message to an agent\n */\n async sendMessage(agentId: string, params: MessageSendParams): Promise<Message | Task> {\n try {\n const client = this.getA2AClient(agentId);\n\n const response: SendMessageResponse = await client.sendMessage(params);\n\n if ('error' in response && response.error) {\n throw new A2AProtocolError(response.error.message, response.error);\n }\n\n if ('result' in response) {\n const result = response.result;\n this.debug(`Message sent to ${agentId}, got ${result.kind}:`, result);\n return result;\n }\n\n throw new DistriError('Invalid response format', 'INVALID_RESPONSE');\n } catch (error) {\n if (error instanceof A2AProtocolError || error instanceof DistriError) throw error;\n throw new DistriError(`Failed to send message to agent ${agentId}`, 'SEND_MESSAGE_ERROR', error);\n }\n }\n\n /**\n * Send a streaming message to an agent\n */\n async * sendMessageStream(agentId: string, params: MessageSendParams): AsyncGenerator<A2AStreamEventData> {\n try {\n const client = this.getA2AClient(agentId);\n yield* await client.sendMessageStream(params);\n } catch (error) {\n throw new DistriError(`Failed to stream message to agent ${agentId}`, 'STREAM_MESSAGE_ERROR', error);\n }\n }\n\n /**\n * Get task details\n */\n async getTask(agentId: string, taskId: string): Promise<Task> {\n try {\n const client = this.getA2AClient(agentId);\n const response: GetTaskResponse = await client.getTask({ id: taskId });\n\n if ('error' in response && response.error) {\n throw new A2AProtocolError(response.error.message, response.error);\n }\n\n if ('result' in response) {\n const result = response.result;\n this.debug(`Got task ${taskId} from ${agentId}:`, result);\n return result;\n }\n\n throw new DistriError('Invalid response format', 'INVALID_RESPONSE');\n } catch (error) {\n if (error instanceof A2AProtocolError || error instanceof DistriError) throw error;\n throw new DistriError(`Failed to get task ${taskId} from agent ${agentId}`, 'GET_TASK_ERROR', error);\n }\n }\n\n /**\n * Cancel a task\n */\n async cancelTask(agentId: string, taskId: string): Promise<void> {\n try {\n const client = this.getA2AClient(agentId);\n await client.cancelTask({ id: taskId });\n this.debug(`Cancelled task ${taskId} on agent ${agentId}`);\n } catch (error) {\n throw new DistriError(`Failed to cancel task ${taskId} on agent ${agentId}`, 'CANCEL_TASK_ERROR', error);\n }\n }\n\n /**\n * Get threads from Distri server\n */\n async getThreads(): Promise<DistriThread[]> {\n try {\n const response = await this.fetch(`/threads`);\n if (!response.ok) {\n throw new ApiError(`Failed to fetch threads: ${response.statusText}`, response.status);\n }\n\n return await response.json();\n } catch (error) {\n if (error instanceof ApiError) throw error;\n throw new DistriError('Failed to fetch threads', 'FETCH_ERROR', error);\n }\n }\n\n async getThread(threadId: string): Promise<DistriThread> {\n try {\n const response = await this.fetch(`/threads/${threadId}`);\n if (!response.ok) {\n throw new ApiError(`Failed to fetch thread: ${response.statusText}`, response.status);\n }\n return await response.json();\n } catch (error) {\n if (error instanceof ApiError) throw error;\n throw new DistriError(`Failed to fetch thread ${threadId}`, 'FETCH_ERROR', error);\n }\n }\n\n /**\n * Get thread messages\n */\n async getThreadMessages(threadId: string): Promise<Message[]> {\n try {\n const response = await this.fetch(`/threads/${threadId}/messages`);\n if (!response.ok) {\n if (response.status === 404) {\n return []; // Thread not found, return empty messages\n }\n throw new ApiError(`Failed to fetch thread messages: ${response.statusText}`, response.status);\n }\n\n return await response.json();\n } catch (error) {\n if (error instanceof ApiError) throw error;\n throw new DistriError(`Failed to fetch messages for thread ${threadId}`, 'FETCH_ERROR', error);\n }\n }\n\n /**\n * Get the base URL for making direct requests\n */\n get baseUrl(): string {\n return this.config.baseUrl;\n }\n\n /**\n * Enhanced fetch with retry logic\n */\n private async fetch(request: RequestInfo | URL, init?: RequestInit): Promise<Response> {\n const input = await this.config.interceptor(request, init);\n // Construct the full URL using baseUrl\n const url = `${this.config.baseUrl}${input}`;\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= this.config.retryAttempts; attempt++) {\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);\n\n const response = await fetch(url, {\n ...init,\n signal: controller.signal,\n headers: {\n ...this.config.headers,\n ...init?.headers\n }\n });\n\n clearTimeout(timeoutId);\n return response;\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n\n if (attempt < this.config.retryAttempts) {\n this.debug(`Request failed (attempt ${attempt + 1}), retrying in ${this.config.retryDelay}ms...`);\n await this.delay(this.config.retryDelay);\n }\n }\n }\n\n throw lastError!;\n }\n\n /**\n * Delay utility\n */\n private delay(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n }\n\n /**\n * Debug logging\n */\n private debug(...args: any[]): void {\n if (this.config.debug) {\n console.log('[DistriClient]', ...args);\n }\n }\n\n /**\n * Helper method to create A2A messages\n */\n static initMessage(\n\n input: string,\n role: 'agent' | 'user' = 'user',\n contextId?: string,\n messageId?: string,\n taskId?: string\n ): Message {\n return {\n messageId: messageId || uuidv4(),\n role,\n parts: [{ kind: 'text', text: input.trim() }],\n contextId,\n taskId: taskId || uuidv4(),\n kind: 'message'\n };\n }\n\n /**\n * Helper method to create message send parameters\n */\n static initMessageParams(\n message: Message,\n configuration?: MessageSendParams['configuration']\n ): MessageSendParams {\n return {\n message,\n configuration: {\n acceptedOutputModes: ['text/plain'],\n blocking: false, // Default to non-blocking for streaming\n ...configuration\n }\n };\n }\n}\nexport function uuidv4(): string {\n if (typeof crypto?.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n // Fallback for older browsers\n const array = new Uint8Array(16);\n crypto.getRandomValues(array);\n // Per RFC4122 v4\n array[6] = (array[6] & 0x0f) | 0x40;\n array[8] = (array[8] & 0x3f) | 0x80;\n return [...array].map((b, i) =>\n ([4, 6, 8, 10].includes(i) ? '-' : '') + b.toString(16).padStart(2, '0')\n ).join('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EACvD;AAAA;AAAA;AAAA;AAAA,EAKQ,SAAS,MAAmB;AAClC,QAAI,KAAK,OAAO,OAAO;AACrB,cAAQ,IAAI,kBAAkB,GAAG,IAAI;AAAA,IACvC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,YAEL,OACA,OAAyB,QACzB,WACA,WACA,QACS;AACT,WAAO;AAAA,MACL,WAAW,aAAa,OAAO;AAAA,MAC/B;AAAA,MACA,OAAO,CAAC,EAAE,MAAM,QAAQ,MAAM,MAAM,KAAK,EAAE,CAAC;AAAA,MAC5C;AAAA,MACA,QAAQ,UAAU,OAAO;AAAA,MACzB,MAAM;AAAA,IACR;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,kBACL,SACA,eACmB;AACnB,WAAO;AAAA,MACL;AAAA,MACA,eAAe;AAAA,QACb,qBAAqB,CAAC,YAAY;AAAA,QAClC,UAAU;AAAA;AAAA,QACV,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF;AACO,SAAS,SAAiB;AAC/B,MAAI,OAAO,QAAQ,eAAe,YAAY;AAC5C,WAAO,OAAO,WAAW;AAAA,EAC3B;AAEA,QAAM,QAAQ,IAAI,WAAW,EAAE;AAC/B,SAAO,gBAAgB,KAAK;AAE5B,QAAM,CAAC,IAAK,MAAM,CAAC,IAAI,KAAQ;AAC/B,QAAM,CAAC,IAAK,MAAM,CAAC,IAAI,KAAQ;AAC/B,SAAO,CAAC,GAAG,KAAK,EAAE;AAAA,IAAI,CAAC,GAAG,OACvB,CAAC,GAAG,GAAG,GAAG,EAAE,EAAE,SAAS,CAAC,IAAI,MAAM,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AAAA,EACzE,EAAE,KAAK,EAAE;AACX;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distri/core",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Core utilities and types for Distri Framework",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",