MCPcopy Index your code
hub / github.com/simstudioai/sim / createA2AClient

Function createA2AClient

apps/sim/lib/a2a/client.ts:194–222  ·  view source on GitHub ↗
(
  agentUrl: string,
  apiKey?: string,
  options: { signal?: AbortSignal } = {}
)

Source from the content-addressed store, hash-verified

192 * request is cancelled.
193 */
194export async function createA2AClient(
195 agentUrl: string,
196 apiKey?: string,
197 options: { signal?: AbortSignal } = {}
198): Promise<Client> {
199 const validation = await validateUrlWithDNS(agentUrl, 'agentUrl')
200 if (!validation.isValid || !validation.resolvedIP) {
201 throw new Error(validation.error || 'Agent URL validation failed')
202 }
203 const { resolvedIP } = validation
204
205 const card = await resolveAgentCard(agentUrl, resolvedIP, options.signal)
206
207 const pinnedFetch = createPinnedFetch(resolvedIP, {
208 timeout: RPC_TIMEOUT_MS,
209 signal: options.signal,
210 })
211 const factory = new ClientFactory(
212 ClientFactoryOptions.createFrom(ClientFactoryOptions.default, {
213 transports: [
214 new JsonRpcTransportFactory({ fetchImpl: pinnedFetch }),
215 new RestTransportFactory({ fetchImpl: pinnedFetch }),
216 ],
217 ...(apiKey ? { clientConfig: { interceptors: [new ApiKeyInterceptor(apiKey)] } } : {}),
218 })
219 )
220
221 return factory.createFromAgentCard(card)
222}
223
224/** A file to attach to an outgoing message, resolved to raw bytes from Sim storage. */
225export interface A2AFileInput {

Callers 4

route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90

Calls 3

validateUrlWithDNSFunction · 0.90
resolveAgentCardFunction · 0.85
createPinnedFetchFunction · 0.70

Tested by

no test coverage detected