@alvin0/ai-agent-sdk-a2a 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-2bhYYreC.mjs","names":[],"sources":["../src/client/link-helpers.ts","../src/client/http-redirect.ts","../src/client.ts"],"sourcesContent":["import {\n ClientFactory,\n JsonRpcTransportFactory,\n RestTransportFactory,\n} from '@a2a-js/sdk/client'\nimport type { SupportSafeError } from '@alvin0/ai-agent-sdk-core'\nimport type { A2AAgentLinkOptions, A2AUnlinkReport } from './types.ts'\nimport { cleanupFailure } from '../common/cleanup-report.ts'\n\nexport function unlinkReport(\n status: A2AUnlinkReport['status'],\n alreadyUnlinked: boolean,\n error: SupportSafeError | undefined = status === 'failed'\n ? cleanupFailure('A2A_UNLINK_FAILED', 'a2a-unlink', 'A2A link removal failed')\n : undefined,\n): A2AUnlinkReport {\n return Object.freeze({ status, alreadyUnlinked, ...(error === undefined ? {} : { error }) })\n}\n\nexport function defaultFactory(options: A2AAgentLinkOptions): ClientFactory {\n const transportOptions = {\n ...(options.fetch === undefined ? {} : { fetchImpl: options.fetch }),\n legacyCompat: { enabled: options.legacyCompat ?? false },\n }\n return new ClientFactory({\n transports: [\n new JsonRpcTransportFactory(transportOptions),\n new RestTransportFactory(transportOptions),\n ],\n })\n}\n","import { waitForSettlement } from '@alvin0/ai-agent-sdk-core'\n\nconst REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308])\nconst MAX_REDIRECT_HOPS = 5\n\nexport interface A2ARedirectOptions {\n readonly allowRedirects: boolean\n readonly signal: AbortSignal\n readonly teardownTimeoutMs: number\n readonly validateEndpoint: (url: string | URL) => URL\n}\n\n/** Apply redirect policy manually so every target is validated before contact. */\nexport async function fetchA2AEndpoint(\n baseFetch: typeof fetch,\n input: Parameters<typeof fetch>[0],\n init: RequestInit | undefined,\n options: A2ARedirectOptions,\n): Promise<Response> {\n let currentInput = input\n let currentUrl = options.validateEndpoint(inputUrl(input))\n let requestInit: RequestInit = { ...init, signal: options.signal, redirect: 'manual' }\n for (let hop = 0; ; hop++) {\n const response = await raceAbort(\n Promise.resolve(baseFetch(currentInput, requestInit)), options.signal,\n )\n const observableFollow = response.redirected === true || response.type === 'opaqueredirect'\n || (response.url.length > 0 && response.url !== currentUrl.href)\n if (observableFollow) {\n await cancelResponse(response, options.teardownTimeoutMs)\n throw new Error('A2A HTTP transport rejected an already-followed redirect')\n }\n if (!REDIRECT_STATUSES.has(response.status)) return response\n if (!options.allowRedirects) {\n await cancelResponse(response, options.teardownTimeoutMs)\n throw new Error('A2A HTTP transport rejected a redirect')\n }\n if (hop >= MAX_REDIRECT_HOPS) {\n await cancelResponse(response, options.teardownTimeoutMs)\n throw new Error(`A2A HTTP transport exceeded the ${MAX_REDIRECT_HOPS}-redirect limit`)\n }\n const location = response.headers.get('location')\n if (location === null) {\n await cancelResponse(response, options.teardownTimeoutMs)\n throw new Error('A2A HTTP transport received a redirect without a location')\n }\n const nextUrl = options.validateEndpoint(new URL(location, currentUrl))\n await cancelResponse(response, options.teardownTimeoutMs)\n requestInit = redirectedInit(requestInit, input, response.status, nextUrl.origin !== currentUrl.origin)\n currentInput = nextUrl\n currentUrl = nextUrl\n }\n}\n\nfunction redirectedInit(\n previous: RequestInit,\n original: Parameters<typeof fetch>[0],\n status: number,\n crossesOrigin: boolean,\n): RequestInit {\n const inputMethod = typeof Request !== 'undefined' && original instanceof Request\n ? original.method\n : undefined\n const method = (previous.method ?? inputMethod ?? 'GET').toUpperCase()\n const switchesToGet = status === 303 || ((status === 301 || status === 302) && method === 'POST')\n const inputHasBody = typeof Request !== 'undefined' && original instanceof Request && original.body !== null\n if (!switchesToGet && (inputHasBody\n || (typeof ReadableStream !== 'undefined' && previous.body instanceof ReadableStream))) {\n throw new Error('A2A HTTP transport cannot replay a streaming request across a redirect')\n }\n const sourceHeaders = previous.headers\n ?? (typeof Request !== 'undefined' && original instanceof Request ? original.headers : undefined)\n const headers = crossesOrigin ? new Headers() : new Headers(sourceHeaders)\n if (switchesToGet) {\n headers.delete('content-length')\n headers.delete('content-type')\n }\n return { ...previous, redirect: 'manual', headers,\n ...(switchesToGet ? { method: 'GET', body: null } : {}) }\n}\n\nfunction inputUrl(input: Parameters<typeof fetch>[0]): string {\n return typeof input === 'string' || input instanceof URL ? input.toString() : input.url\n}\n\nasync function cancelResponse(response: Response, timeoutMs: number): Promise<void> {\n if (response.body === null) return\n await waitForSettlement(response.body.cancel().catch(() => undefined), timeoutMs)\n}\n\nfunction raceAbort<T>(pending: Promise<T>, signal: AbortSignal): Promise<T> {\n if (signal.aborted) return Promise.reject(signal.reason ?? new Error('A2A operation aborted'))\n return new Promise<T>((resolve, reject) => {\n const abort = () => { cleanup(); reject(signal.reason ?? new Error('A2A operation aborted')) }\n const cleanup = () => signal.removeEventListener('abort', abort)\n signal.addEventListener('abort', abort, { once: true })\n void pending.then(value => { cleanup(); resolve(value) }, error => { cleanup(); reject(error) })\n })\n}\n","/** Official A2A Protocol client transport and AgentTeam linking helpers. */\n\nimport {\n Role,\n TaskState,\n type AgentCard,\n type Message,\n type Part,\n type SendMessageRequest,\n type Task,\n} from '@a2a-js/sdk'\nimport {\n DefaultAgentCardResolver,\n type Client,\n type RequestOptions,\n} from '@a2a-js/sdk/client'\nimport type {\n LinkedAgentResult,\n LinkedAgentSendInput,\n LinkedAgentTransport,\n} from '@alvin0/ai-agent-sdk-core/agent'\nimport type { ContentBlock } from '@alvin0/ai-agent-sdk-core'\nimport { detachedFrozen } from '@alvin0/ai-agent-sdk-core'\nimport { waitForSettlement } from '@alvin0/ai-agent-sdk-core'\nimport { a2aErrorCode, beginA2AIntegrationOperation } from './common/integration-operation.ts'\nimport { defaultFactory, unlinkReport } from './client/link-helpers.ts'\nimport { fetchA2AEndpoint } from './client/http-redirect.ts'\nimport type {\n A2AAgentLinkOptions, A2ALinkableTeam, A2AUnlinkReport, LinkA2AAgentOptions,\n} from './client/types.ts'\n\nexport type {\n A2AAgentLinkOptions, A2ALinkableTeam, A2AUnlinkReport, LinkA2AAgentOptions,\n} from './client/types.ts'\n\n/** A resolved official SDK client presented as an AgentTeam transport. */\nexport class A2AAgentLink implements LinkedAgentTransport {\n readonly protocol = 'a2a/1.0'\n readonly agentId: string\n readonly client: Client\n readonly agentCard: AgentCard | undefined\n private readonly options: A2AAgentLinkOptions\n private readonly contexts = new Map<string, { readonly id: string; lastAccess: number }>()\n private readonly pendingContextKeys = new Set<string>()\n private readonly timeoutMs: number\n private readonly teardownTimeoutMs: number\n private readonly maxRequestBytes: number\n private readonly maxResponseBytes: number\n private readonly maxTransportBytes: number\n private readonly maxStreamEvents: number\n private readonly maxStreamBytes: number\n private readonly maxContexts: number\n private readonly contextTtlMs: number\n\n constructor(\n client: Client,\n options: A2AAgentLinkOptions,\n agentCard?: AgentCard,\n ) {\n this.client = client\n this.options = snapshotLinkOptions(options)\n this.agentCard = agentCard === undefined ? undefined : detachedFrozen(agentCard)\n this.agentId = nonEmpty(\n options.agentId ?? agentCard?.name ?? options.baseUrl,\n 'A2A linked agent id',\n )\n this.timeoutMs = positiveInteger(options.timeoutMs ?? 120_000, 'timeoutMs')\n this.teardownTimeoutMs = positiveInteger(options.teardownTimeoutMs ?? 30_000, 'teardownTimeoutMs')\n this.maxRequestBytes = positiveInteger(options.maxRequestBytes ?? 1024 * 1024, 'maxRequestBytes')\n this.maxResponseBytes = positiveInteger(options.maxResponseBytes ?? 1024 * 1024, 'maxResponseBytes')\n this.maxTransportBytes = positiveInteger(options.maxTransportBytes ?? 16 * 1024 * 1024, 'maxTransportBytes')\n this.maxStreamEvents = positiveInteger(options.maxStreamEvents ?? 10_000, 'maxStreamEvents')\n this.maxStreamBytes = positiveInteger(options.maxStreamBytes ?? 8 * 1024 * 1024, 'maxStreamBytes')\n this.maxContexts = positiveInteger(options.maxContexts ?? 1_000, 'maxContexts')\n this.contextTtlMs = positiveInteger(options.contextTtlMs ?? 30 * 60_000, 'contextTtlMs')\n if (options.historyLength !== undefined) positiveInteger(options.historyLength, 'historyLength')\n }\n\n async send(input: LinkedAgentSendInput): Promise<LinkedAgentResult> {\n const operation = beginA2AIntegrationOperation(input.logger, 'a2a-client-link', 'send')\n const attempt = operation.attempt(1)\n let contextKey: string | undefined\n let signal = input.signal\n try {\n input.signal?.throwIfAborted()\n contextKey = JSON.stringify([input.teamId, input.sender])\n const context = this.reserveContext(contextKey)\n const request = this.request(input, context?.id)\n if (byteLength(request) > this.maxRequestBytes) {\n throw new Error(`A2A request exceeds the ${this.maxRequestBytes}-byte limit`)\n }\n signal = combineSignals(input.signal, AbortSignal.timeout(this.timeoutMs))\n const requestOptions: RequestOptions = {\n signal,\n ...(this.options.serviceParameters === undefined\n ? {}\n : { serviceParameters: this.options.serviceParameters }),\n }\n const streaming = this.options.streaming\n ?? this.agentCard?.capabilities?.streaming\n ?? false\n let result: LinkedAgentResult\n if (streaming) {\n const stream = beginA2AIntegrationOperation(input.logger, 'a2a-client-link', 'stream')\n const streamAttempt = stream.attempt(1)\n try {\n result = await this.sendStreaming(request, requestOptions)\n streamAttempt.success(); stream.success()\n } catch (error: unknown) {\n if (signal.aborted) { streamAttempt.abort(); stream.abort() }\n else {\n const code = a2aErrorCode(error)\n streamAttempt.fail(code); stream.fail(code)\n }\n throw error\n }\n } else {\n const wireResult = await raceWithSignal(this.client.sendMessage(request, requestOptions), signal)\n if (byteLength(wireResult) > this.maxTransportBytes) {\n throw new Error(`A2A transport response exceeds the ${this.maxTransportBytes}-byte limit`)\n }\n result = normalizeResult(wireResult)\n }\n if (byteLength(result) > this.maxResponseBytes) {\n throw new Error(`A2A response exceeds the ${this.maxResponseBytes}-byte limit`)\n }\n if (result.contextId.length > 0) {\n this.contexts.set(contextKey, { id: result.contextId, lastAccess: Date.now() })\n }\n attempt.success(); operation.success()\n return result\n } catch (error: unknown) {\n if (signal?.aborted === true) { attempt.abort(); operation.abort() }\n else {\n const code = a2aErrorCode(error)\n attempt.fail(code); operation.fail(code)\n }\n throw error\n } finally {\n if (contextKey !== undefined) this.pendingContextKeys.delete(contextKey)\n }\n }\n\n private request(input: LinkedAgentSendInput, contextId: string | undefined): SendMessageRequest {\n return {\n // Required by the generated A2A request shape; the SDK does not attach a\n // deployment tenancy model to protocol messages.\n tenant: '',\n message: {\n messageId: input.messageId,\n contextId: contextId ?? '',\n taskId: '',\n role: Role.ROLE_USER,\n parts: input.content.map(contentPart),\n metadata: {\n teamId: input.teamId,\n sender: input.sender,\n senderAgentId: input.senderAgentId,\n },\n extensions: [],\n referenceTaskIds: [],\n },\n configuration: {\n acceptedOutputModes: [...this.options.acceptedOutputModes ?? ['text/plain', 'application/json']],\n taskPushNotificationConfig: undefined,\n ...(this.options.historyLength === undefined ? {} : { historyLength: this.options.historyLength }),\n returnImmediately: false,\n },\n metadata: { teamId: input.teamId, sender: input.sender },\n }\n }\n\n private async sendStreaming(\n request: SendMessageRequest,\n options: RequestOptions,\n ): Promise<LinkedAgentResult> {\n let lastTask: Task | undefined\n let lastMessage: Message | undefined\n let taskId = ''\n let contextId = request.message?.contextId ?? ''\n let state: TaskState | undefined\n const streamedArtifactText: string[] = []\n const streamedStatusText: string[] = []\n let eventCount = 0\n let streamBytes = 0\n const iterator = this.client.sendMessageStream(request, options)[Symbol.asyncIterator]()\n let exhausted = false\n try {\n while (true) {\n const next = await raceWithSignal(iterator.next(), options.signal)\n if (next.done === true) {\n exhausted = true\n break\n }\n const rawEvent = next.value\n eventCount++\n streamBytes += byteLength(rawEvent)\n if (eventCount > this.maxStreamEvents) {\n throw new Error(`A2A stream exceeds the ${this.maxStreamEvents}-event limit`)\n }\n if (streamBytes > this.maxStreamBytes) {\n throw new Error(`A2A stream exceeds the ${this.maxStreamBytes}-byte limit`)\n }\n // A diagnostic observer must never be able to mutate the protocol value\n // before transport state is reduced from it.\n const event = detachedFrozen(rawEvent)\n try { this.options.onStreamEvent?.(event) } catch { /* observers do not own transport correctness */ }\n const payload = event.payload\n if (payload?.$case === 'task') {\n lastTask = payload.value\n taskId = payload.value.id\n contextId = payload.value.contextId\n state = payload.value.status?.state\n } else if (payload?.$case === 'message') {\n lastMessage = payload.value\n contextId = payload.value.contextId\n taskId = payload.value.taskId\n } else if (payload?.$case === 'statusUpdate') {\n taskId = payload.value.taskId\n contextId = payload.value.contextId\n state = payload.value.status?.state\n const text = textOfMessage(payload.value.status?.message)\n if (text.length > 0) streamedStatusText.push(text)\n } else if (payload?.$case === 'artifactUpdate') {\n taskId = payload.value.taskId\n contextId = payload.value.contextId\n const text = textOfParts(payload.value.artifact?.parts ?? [])\n if (text.length > 0) streamedArtifactText.push(text)\n }\n }\n } finally {\n if (!exhausted) {\n const close = iterator.return?.bind(iterator)\n if (close !== undefined) {\n const settled = await waitForSettlement(\n Promise.resolve().then(async () => { await close() }),\n this.teardownTimeoutMs,\n )\n if (!settled) {\n throw new Error(`A2A stream teardown exceeded ${this.teardownTimeoutMs}ms`)\n }\n }\n }\n }\n if (lastMessage !== undefined && (state === undefined || taskId.length === 0)) {\n return normalizeMessage(lastMessage)\n }\n if (lastMessage !== undefined) {\n return Object.freeze({\n kind: 'task',\n succeeded: state === TaskState.TASK_STATE_COMPLETED,\n text: textOfMessage(lastMessage) || streamedArtifactText.join('') || streamedStatusText.at(-1) || '',\n contextId,\n taskId,\n ...(state === undefined ? {} : { state: taskStateName(state) }),\n })\n }\n if (lastTask !== undefined) {\n const normalized = normalizeTask(lastTask)\n const streamed = streamedArtifactText.join('') || streamedStatusText.at(-1) || ''\n const effectiveState = state ?? lastTask.status?.state\n return Object.freeze({\n ...normalized,\n succeeded: effectiveState === TaskState.TASK_STATE_COMPLETED,\n text: normalized.text || streamed,\n ...(effectiveState === undefined ? {} : { state: taskStateName(effectiveState) }),\n })\n }\n if (taskId.length === 0) throw new Error('A2A stream ended without a message or task')\n return Object.freeze({\n kind: 'task',\n succeeded: state === TaskState.TASK_STATE_COMPLETED,\n text: streamedArtifactText.join('') || streamedStatusText.at(-1) || '',\n contextId,\n taskId,\n ...(state === undefined ? {} : { state: taskStateName(state) }),\n })\n }\n\n private reserveContext(key: string): { readonly id: string; lastAccess: number } | undefined {\n const now = Date.now()\n for (const [candidate, value] of this.contexts) {\n if (now - value.lastAccess >= this.contextTtlMs) this.contexts.delete(candidate)\n }\n const existing = this.contexts.get(key)\n if (existing !== undefined) {\n existing.lastAccess = now\n return existing\n }\n if (!this.pendingContextKeys.has(key)\n && this.contexts.size + this.pendingContextKeys.size >= this.maxContexts) {\n throw new Error(`A2A link reached its ${this.maxContexts}-context limit`)\n }\n this.pendingContextKeys.add(key)\n return undefined\n }\n}\n\n/** Discover an Agent Card and construct a protocol link with official transports. */\nexport async function createA2AAgentLink(options: A2AAgentLinkOptions): Promise<A2AAgentLink> {\n const operation = beginA2AIntegrationOperation(options.logger, 'a2a-client-link', 'agent-card-resolve')\n const attempt = operation.attempt(1)\n try {\n options = snapshotLinkOptions(options)\n const sources = [options.client, options.agentCard, options.baseUrl].filter(value => value !== undefined)\n if (sources.length !== 1) {\n throw new TypeError('createA2AAgentLink requires exactly one of client, agentCard, or baseUrl')\n }\n if (options.client !== undefined) {\n const link = new A2AAgentLink(options.client, options)\n attempt.success(); operation.success()\n return link\n }\n if (options.agentCard !== undefined) {\n const cardOptions: A2AAgentLinkOptions = { ...options }\n validateAgentCard(options.agentCard, cardOptions)\n const guardedFetch = endpointFetch(options.fetch ?? globalThis.fetch, cardOptions)\n const factory = options.clientFactory ?? defaultFactory({ ...cardOptions, fetch: guardedFetch })\n const signal = AbortSignal.timeout(positiveInteger(options.timeoutMs ?? 120_000, 'timeoutMs'))\n const link = new A2AAgentLink(\n await raceWithSignal(factory.createFromAgentCard(options.agentCard), signal),\n cardOptions,\n options.agentCard,\n )\n attempt.success(); operation.success()\n return link\n }\n const baseUrl = validateEndpoint(options.baseUrl as string, options)\n const discoveryOptions: A2AAgentLinkOptions = { ...options }\n const guardedFetch = endpointFetch(options.fetch ?? globalThis.fetch, discoveryOptions)\n const resolver = new DefaultAgentCardResolver({\n fetchImpl: guardedFetch,\n legacyCompat: { enabled: options.legacyCompat ?? false },\n })\n const signal = AbortSignal.timeout(positiveInteger(options.timeoutMs ?? 120_000, 'timeoutMs'))\n const agentCard = await raceWithSignal(resolver.resolve(baseUrl.href, options.cardPath), signal)\n validateAgentCard(agentCard, discoveryOptions)\n const factory = options.clientFactory ?? defaultFactory({ ...discoveryOptions, fetch: guardedFetch })\n const client = await raceWithSignal(factory.createFromAgentCard(agentCard), signal)\n const link = new A2AAgentLink(client, discoveryOptions, agentCard)\n attempt.success(); operation.success()\n return link\n } catch (error: unknown) {\n const code = a2aErrorCode(error)\n attempt.fail(code); operation.fail(code)\n throw error\n }\n}\n\n/** Discover and add a remote A2A peer to the same roster local agents use. */\nexport async function linkA2AAgent(\n team: A2ALinkableTeam,\n options: LinkA2AAgentOptions,\n): Promise<{ readonly link: A2AAgentLink; readonly unlink: () => void;\n readonly unlinkWithReport: () => A2AUnlinkReport }> {\n const linkOperation = beginA2AIntegrationOperation(options.logger, 'a2a-client-link', 'link')\n const linkAttempt = linkOperation.attempt(1)\n let link: A2AAgentLink\n let removeLink: () => void\n try {\n link = await createA2AAgentLink(options)\n removeLink = team.linkAgent({\n name: options.name,\n transport: link,\n ...(options.description === undefined ? {} : { description: options.description }),\n })\n linkAttempt.success(); linkOperation.success()\n } catch (error: unknown) {\n const code = a2aErrorCode(error)\n linkAttempt.fail(code); linkOperation.fail(code)\n throw error\n }\n let report: A2AUnlinkReport | undefined\n const unlink = (): void => {\n if (report !== undefined) return\n const operation = beginA2AIntegrationOperation(options.logger, 'a2a-client-link', 'unlink')\n const attempt = operation.attempt(1)\n try {\n removeLink()\n report = unlinkReport('unlinked', false)\n attempt.success(); operation.success()\n } catch (error) {\n report = unlinkReport('failed', false)\n const code = a2aErrorCode(error)\n attempt.fail(code); operation.fail(code)\n throw error\n }\n }\n const unlinkWithReport = (): A2AUnlinkReport => {\n if (report !== undefined) return unlinkReport(report.status, true, report.error)\n const operation = beginA2AIntegrationOperation(options.logger, 'a2a-client-link', 'unlink')\n const attempt = operation.attempt(1)\n try {\n removeLink()\n report = unlinkReport('unlinked', false)\n attempt.success(); operation.success()\n } catch (error: unknown) {\n report = unlinkReport('failed', false)\n const code = a2aErrorCode(error)\n attempt.fail(code); operation.fail(code)\n }\n return report\n }\n return Object.freeze({ link, unlink, unlinkWithReport })\n}\n\nfunction contentPart(block: ContentBlock): Part {\n if (block.type === 'text') return part({ $case: 'text', value: block.text }, 'text/plain')\n if (block.type === 'image') {\n if (block.source.kind === 'url') return part({ $case: 'url', value: block.source.url }, 'image/*')\n if (block.source.kind === 'base64') {\n return part(\n { $case: 'url', value: `data:${block.source.mediaType};base64,${block.source.data}` },\n block.source.mediaType,\n )\n }\n return part({ $case: 'data', value: { type: 'image-file', fileId: block.source.fileId } }, 'application/json')\n }\n return part({ $case: 'data', value: structuredClone(block) }, 'application/json')\n}\n\nfunction part(content: NonNullable<Part['content']>, mediaType: string): Part {\n return { content, metadata: undefined, filename: '', mediaType }\n}\n\nfunction normalizeResult(result: Message | Task): LinkedAgentResult {\n return 'messageId' in result ? normalizeMessage(result) : normalizeTask(result)\n}\n\nfunction normalizeMessage(message: Message): LinkedAgentResult {\n return Object.freeze({\n kind: 'message', succeeded: message.role === Role.ROLE_AGENT,\n text: textOfMessage(message), contextId: message.contextId,\n ...(message.taskId.length === 0 ? {} : { taskId: message.taskId }),\n })\n}\n\nfunction normalizeTask(task: Task): LinkedAgentResult {\n const state = task.status?.state\n const artifactText = task.artifacts.map(artifact => textOfParts(artifact.parts)).filter(Boolean).join('\\n')\n const statusText = textOfMessage(task.status?.message)\n const historyText = [...task.history].reverse()\n .find(message => message.role === Role.ROLE_AGENT)\n return Object.freeze({\n kind: 'task',\n succeeded: state === TaskState.TASK_STATE_COMPLETED,\n text: artifactText || statusText || textOfMessage(historyText),\n contextId: task.contextId,\n taskId: task.id,\n ...(state === undefined ? {} : { state: taskStateName(state) }),\n })\n}\n\nfunction textOfMessage(message: Message | undefined): string {\n return message === undefined ? '' : textOfParts(message.parts)\n}\n\nfunction textOfParts(parts: readonly Part[]): string {\n return parts.flatMap(item => item.content?.$case === 'text' ? [item.content.value] : []).join('')\n}\n\nfunction taskStateName(state: TaskState): string {\n return TaskState[state] ?? String(state)\n}\n\nfunction nonEmpty(value: unknown, label: string): string {\n if (typeof value !== 'string' || value.trim().length === 0) throw new TypeError(`${label} must be a non-empty string`)\n if (value.length > 256) throw new TypeError(`${label} must be at most 256 characters`)\n return value\n}\n\nfunction positiveInteger(value: number, label: string): number {\n if (!Number.isSafeInteger(value) || value < 1) throw new TypeError(`${label} must be a positive integer`)\n return value\n}\n\nfunction utf8Bytes(value: string): number {\n return new TextEncoder().encode(value).byteLength\n}\n\nfunction byteLength(value: unknown): number {\n const serialized = JSON.stringify(value)\n if (serialized === undefined) throw new TypeError('A2A value is not JSON serializable')\n return utf8Bytes(serialized)\n}\n\nfunction combineSignals(...signals: readonly (AbortSignal | undefined)[]): AbortSignal {\n const active = signals.filter((signal): signal is AbortSignal => signal !== undefined)\n if (active.length === 1) return active[0]!\n return AbortSignal.any(active)\n}\n\nasync function raceWithSignal<T>(pending: Promise<T>, signal: AbortSignal | undefined): Promise<T> {\n if (signal === undefined) return pending\n if (signal.aborted) throw signal.reason ?? new Error('A2A operation aborted')\n return await new Promise<T>((resolve, reject) => {\n const abort = () => {\n signal.removeEventListener('abort', abort)\n reject(signal.reason ?? new Error('A2A operation aborted'))\n }\n signal.addEventListener('abort', abort, { once: true })\n void pending.then(\n value => { signal.removeEventListener('abort', abort); resolve(value) },\n error => { signal.removeEventListener('abort', abort); reject(error) },\n )\n })\n}\n\nfunction validateAgentCard(card: AgentCard, options: A2AAgentLinkOptions): void {\n const maxBytes = positiveInteger(options.maxResponseBytes ?? 1024 * 1024, 'maxResponseBytes')\n if (byteLength(card) > maxBytes) {\n throw new RangeError(`A2A Agent Card exceeds the ${maxBytes}-byte limit`)\n }\n if (card.supportedInterfaces.length === 0) {\n throw new TypeError('A2A Agent Card must advertise at least one interface')\n }\n for (const item of card.supportedInterfaces) validateEndpoint(item.url, options)\n}\n\nfunction snapshotLinkOptions(options: A2AAgentLinkOptions): A2AAgentLinkOptions {\n return Object.freeze({\n ...options,\n ...(options.allowedOrigins === undefined ? {} : {\n allowedOrigins: Object.freeze([...options.allowedOrigins]),\n }),\n ...(options.acceptedOutputModes === undefined ? {} : {\n acceptedOutputModes: Object.freeze([...options.acceptedOutputModes]),\n }),\n ...(options.serviceParameters === undefined ? {} : {\n serviceParameters: detachedFrozen(options.serviceParameters),\n }),\n ...(options.agentCard === undefined ? {} : { agentCard: detachedFrozen(options.agentCard) }),\n })\n}\n\nfunction validateEndpoint(value: string, options: A2AAgentLinkOptions): URL {\n const url = new URL(value)\n if (url.username.length > 0 || url.password.length > 0) {\n throw new TypeError('A2A endpoint URL must not contain credentials')\n }\n if (url.protocol !== 'https:' && url.protocol !== 'http:') {\n throw new TypeError('A2A endpoint URL must use http or https')\n }\n if (options.requireHttps === true && url.protocol !== 'https:') {\n throw new TypeError('A2A endpoint URL must use https under the configured policy')\n }\n const allowedOrigins = options.allowedOrigins?.map(origin => new URL(origin).origin)\n if (allowedOrigins !== undefined && !allowedOrigins.includes(url.origin)) {\n throw new TypeError(`A2A endpoint origin '${url.origin}' is not allowed`)\n }\n if (options.allowPrivateNetwork === false && isPrivateHostname(url.hostname)) {\n throw new TypeError(`A2A endpoint host '${url.hostname}' is private or local`)\n }\n options.validateEndpoint?.(new URL(url))\n return url\n}\n\nfunction endpointFetch(baseFetch: typeof fetch, options: A2AAgentLinkOptions): typeof fetch {\n if (typeof baseFetch !== 'function') throw new TypeError('A2A endpoint resolution requires fetch')\n const maxBytes = positiveInteger(options.maxTransportBytes ?? 16 * 1024 * 1024, 'maxTransportBytes')\n const timeoutMs = positiveInteger(options.timeoutMs ?? 120_000, 'timeoutMs')\n const teardownTimeoutMs = positiveInteger(options.teardownTimeoutMs ?? 30_000, 'teardownTimeoutMs')\n return (async (input: Parameters<typeof fetch>[0], init?: RequestInit): Promise<Response> => {\n const value = typeof input === 'string' || input instanceof URL ? input.toString() : input.url\n validateEndpoint(value, options)\n const signal = combineSignals(init?.signal ?? undefined, AbortSignal.timeout(timeoutMs))\n const response = await fetchA2AEndpoint(baseFetch, input, init, {\n signal,\n allowRedirects: options.allowRedirects !== false,\n teardownTimeoutMs,\n validateEndpoint: value => validateEndpoint(value.toString(), options),\n })\n if (response.url.length > 0) validateEndpoint(response.url, options)\n const declared = Number(response.headers.get('content-length'))\n if (Number.isFinite(declared) && declared > maxBytes) {\n if (response.body !== null) {\n await waitForSettlement(response.body.cancel().catch(() => undefined), teardownTimeoutMs)\n }\n throw new Error(`A2A HTTP response exceeds the ${maxBytes}-byte limit`)\n }\n if (response.body === null) return response\n let received = 0\n const limited = response.body.pipeThrough(new TransformStream<Uint8Array, Uint8Array>({\n transform(chunk, controller) {\n received += chunk.byteLength\n if (received > maxBytes) {\n controller.error(new Error(`A2A HTTP response exceeds the ${maxBytes}-byte limit`))\n return\n }\n controller.enqueue(chunk)\n },\n }))\n return new Response(limited, {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n })\n }) as typeof fetch\n}\n\nfunction isPrivateHostname(value: string): boolean {\n const hostname = value.toLowerCase().replace(/^\\[|\\]$/g, '')\n if (hostname === 'localhost' || hostname.endsWith('.localhost')\n || hostname.endsWith('.local') || hostname.endsWith('.internal')\n || hostname.endsWith('.home.arpa') || !hostname.includes('.')) return true\n if (hostname.includes(':')) return true\n const octets = hostname.split('.').map(Number)\n if (octets.length !== 4 || octets.some(octet => !Number.isInteger(octet) || octet < 0 || octet > 255)) {\n return false\n }\n const [first = 0, second = 0] = octets\n return first === 0 || first === 10 || first === 127 || first >= 224\n || (first === 100 && second >= 64 && second <= 127)\n || (first === 169 && second === 254)\n || (first === 172 && second >= 16 && second <= 31)\n || (first === 192 && second === 168)\n || (first === 198 && (second === 18 || second === 19))\n}\n\nexport {\n ClientFactory,\n DefaultAgentCardResolver,\n JsonRpcTransportFactory,\n RestTransportFactory,\n type Client,\n type RequestOptions,\n} from '@a2a-js/sdk/client'\nexport type {\n AgentCard,\n Message,\n Part,\n SendMessageRequest,\n StreamResponse,\n Task,\n} from '@a2a-js/sdk'\n"],"mappings":";;;;;;AASA,SAAgB,aACd,QACA,iBACA,QAAsC,WAAW,WAC7C,eAAe,qBAAqB,cAAc,yBAAyB,IAC3E,QACa;CACjB,OAAO,OAAO,OAAO;EAAE;EAAQ;EAAiB,GAAI,UAAU,SAAY,CAAC,IAAI,EAAE,MAAM;CAAG,CAAC;AAC7F;AAEA,SAAgB,eAAe,SAA6C;CAC1E,MAAM,mBAAmB;EACvB,GAAI,QAAQ,UAAU,SAAY,CAAC,IAAI,EAAE,WAAW,QAAQ,MAAM;EAClE,cAAc,EAAE,SAAS,QAAQ,gBAAgB,MAAM;CACzD;CACA,OAAO,IAAI,cAAc,EACvB,YAAY,CACV,IAAI,wBAAwB,gBAAgB,GAC5C,IAAI,qBAAqB,gBAAgB,CAC3C,EACF,CAAC;AACH;;;;AC5BA,MAAM,oCAAoB,IAAI,IAAI;CAAC;CAAK;CAAK;CAAK;CAAK;AAAG,CAAC;AAC3D,MAAM,oBAAoB;;AAU1B,eAAsB,iBACpB,WACA,OACA,MACA,SACmB;CACnB,IAAI,eAAe;CACnB,IAAI,aAAa,QAAQ,iBAAiB,SAAS,KAAK,CAAC;CACzD,IAAI,cAA2B;EAAE,GAAG;EAAM,QAAQ,QAAQ;EAAQ,UAAU;CAAS;CACrF,KAAK,IAAI,MAAM,IAAK,OAAO;EACzB,MAAM,WAAW,MAAM,UACrB,QAAQ,QAAQ,UAAU,cAAc,WAAW,CAAC,GAAG,QAAQ,MACjE;EAGA,IAFyB,SAAS,eAAe,QAAQ,SAAS,SAAS,oBACrE,SAAS,IAAI,SAAS,KAAK,SAAS,QAAQ,WAAW,MACvC;GACpB,MAAM,eAAe,UAAU,QAAQ,iBAAiB;GACxD,MAAM,IAAI,MAAM,0DAA0D;EAC5E;EACA,IAAI,CAA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part, SendMessageRequest, StreamResponse, StreamResponse as StreamResponse$1, Task } from "@a2a-js/sdk";
2
+ import { Client, Client as Client$1, ClientFactory, ClientFactory as ClientFactory$1, DefaultAgentCardResolver as DefaultAgentCardResolver$1, JsonRpcTransportFactory as JsonRpcTransportFactory$1, RequestOptions, RequestOptions as RequestOptions$1, RestTransportFactory as RestTransportFactory$1 } from "@a2a-js/sdk/client";
3
+ import { SdkLogger, SupportSafeError } from "@alvin0/ai-agent-sdk-core";
4
+ import { LinkAgentOptions, LinkedAgentResult, LinkedAgentSendInput, LinkedAgentTransport } from "@alvin0/ai-agent-sdk-core/agent";
5
+ //#region src/client/types.d.ts
6
+ interface A2AAgentLinkOptions {
7
+ readonly logger?: SdkLogger;
8
+ readonly agentId?: string;
9
+ readonly baseUrl?: string;
10
+ readonly cardPath?: string;
11
+ readonly agentCard?: AgentCard;
12
+ readonly client?: Client;
13
+ readonly clientFactory?: ClientFactory;
14
+ readonly fetch?: typeof fetch;
15
+ readonly legacyCompat?: boolean;
16
+ readonly allowedOrigins?: readonly string[];
17
+ readonly requireHttps?: boolean;
18
+ readonly allowPrivateNetwork?: boolean;
19
+ readonly allowRedirects?: boolean;
20
+ readonly validateEndpoint?: (url: URL) => void;
21
+ readonly timeoutMs?: number;
22
+ readonly teardownTimeoutMs?: number;
23
+ readonly maxRequestBytes?: number;
24
+ readonly maxResponseBytes?: number;
25
+ readonly maxStreamEvents?: number;
26
+ readonly maxStreamBytes?: number;
27
+ readonly maxTransportBytes?: number;
28
+ readonly maxContexts?: number;
29
+ readonly contextTtlMs?: number;
30
+ readonly streaming?: boolean;
31
+ readonly acceptedOutputModes?: readonly string[];
32
+ readonly historyLength?: number;
33
+ readonly serviceParameters?: RequestOptions['serviceParameters'];
34
+ readonly onStreamEvent?: (event: StreamResponse) => void;
35
+ }
36
+ interface LinkA2AAgentOptions extends A2AAgentLinkOptions {
37
+ readonly name: string;
38
+ readonly description?: string;
39
+ }
40
+ interface A2ALinkableTeam {
41
+ linkAgent(options: LinkAgentOptions): () => void;
42
+ }
43
+ interface A2AUnlinkReport {
44
+ readonly status: 'unlinked' | 'failed';
45
+ readonly alreadyUnlinked: boolean;
46
+ readonly error?: SupportSafeError;
47
+ }
48
+ //#endregion
49
+ //#region src/client.d.ts
50
+ /** A resolved official SDK client presented as an AgentTeam transport. */
51
+ declare class A2AAgentLink implements LinkedAgentTransport {
52
+ readonly protocol = "a2a/1.0";
53
+ readonly agentId: string;
54
+ readonly client: Client;
55
+ readonly agentCard: AgentCard | undefined;
56
+ private readonly options;
57
+ private readonly contexts;
58
+ private readonly pendingContextKeys;
59
+ private readonly timeoutMs;
60
+ private readonly teardownTimeoutMs;
61
+ private readonly maxRequestBytes;
62
+ private readonly maxResponseBytes;
63
+ private readonly maxTransportBytes;
64
+ private readonly maxStreamEvents;
65
+ private readonly maxStreamBytes;
66
+ private readonly maxContexts;
67
+ private readonly contextTtlMs;
68
+ constructor(client: Client, options: A2AAgentLinkOptions, agentCard?: AgentCard);
69
+ send(input: LinkedAgentSendInput): Promise<LinkedAgentResult>;
70
+ private request;
71
+ private sendStreaming;
72
+ private reserveContext;
73
+ }
74
+ /** Discover an Agent Card and construct a protocol link with official transports. */
75
+ declare function createA2AAgentLink(options: A2AAgentLinkOptions): Promise<A2AAgentLink>;
76
+ /** Discover and add a remote A2A peer to the same roster local agents use. */
77
+ declare function linkA2AAgent(team: A2ALinkableTeam, options: LinkA2AAgentOptions): Promise<{
78
+ readonly link: A2AAgentLink;
79
+ readonly unlink: () => void;
80
+ readonly unlinkWithReport: () => A2AUnlinkReport;
81
+ }>;
82
+ //#endregion
83
+ export { A2ALinkableTeam as _, DefaultAgentCardResolver$1 as a, Part as c, SendMessageRequest as d, StreamResponse$1 as f, A2AAgentLinkOptions as g, linkA2AAgent as h, ClientFactory$1 as i, RequestOptions$1 as l, createA2AAgentLink as m, AgentCard$1 as n, JsonRpcTransportFactory$1 as o, Task as p, Client$1 as r, Message as s, A2AAgentLink as t, RestTransportFactory$1 as u, A2AUnlinkReport as v, LinkA2AAgentOptions as y };
84
+ //# sourceMappingURL=client-DmkHTq-_.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-DmkHTq-_.d.mts","names":[],"sources":["../src/client/types.ts","../src/client.ts"],"mappings":";;;;;UAKiB;WACN,SAAS;WACT;WACA;WACA;WACA,YAAY;WACZ,SAAS;WACT,gBAAgB;WAChB,eAAe;WACf;WACA;WACA;WACA;WACA;WACA,oBAAoB,KAAK;WACzB;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,oBAAoB;WACpB,iBAAiB,OAAO;;UAGlB,4BAA4B;WAClC;WACA;;UAGM;EACf,UAAU,SAAS;;UAGJ;WACN;WACA;WACA,QAAQ;;;;;cCZN,wBAAwB;WAC1B;WACA;WACA,QAAQ;WACR,WAAW;mBACH;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;EAEjB,YACE,QAAQ,QACR,SAAS,qBACT,YAAY;EAqBR,KAAK,OAAO,uBAAuB,QAAQ;UAiEzC;UA6BM;UA2GN;;;iBAoBY,mBAAmB,SAAS,sBAAsB,QAAQ;;iBAmD1D,aACpB,MAAM,iBACN,SAAS,sBACR;WAAmB,MAAM;WAAuB;WACxC,wBAAwB"}
@@ -0,0 +1,2 @@
1
+ import { _ as A2ALinkableTeam, a as DefaultAgentCardResolver, c as Part, d as SendMessageRequest, f as StreamResponse, g as A2AAgentLinkOptions, h as linkA2AAgent, i as ClientFactory, l as RequestOptions, m as createA2AAgentLink, n as AgentCard, o as JsonRpcTransportFactory, p as Task, r as Client, s as Message, t as A2AAgentLink, u as RestTransportFactory, v as A2AUnlinkReport, y as LinkA2AAgentOptions } from "./client-DmkHTq-_.mjs";
2
+ export { A2AAgentLink, type A2AAgentLinkOptions, type A2ALinkableTeam, type A2AUnlinkReport, type AgentCard, type Client, ClientFactory, DefaultAgentCardResolver, JsonRpcTransportFactory, type LinkA2AAgentOptions, type Message, type Part, type RequestOptions, RestTransportFactory, type SendMessageRequest, type StreamResponse, type Task, createA2AAgentLink, linkA2AAgent };
@@ -0,0 +1,3 @@
1
+ import { a as RestTransportFactory, i as JsonRpcTransportFactory, n as ClientFactory, o as createA2AAgentLink, r as DefaultAgentCardResolver, s as linkA2AAgent, t as A2AAgentLink } from "./client-2bhYYreC.mjs";
2
+
3
+ export { A2AAgentLink, ClientFactory, DefaultAgentCardResolver, JsonRpcTransportFactory, RestTransportFactory, createA2AAgentLink, linkA2AAgent };
@@ -0,0 +1,3 @@
1
+ import { _ as A2ALinkableTeam, a as DefaultAgentCardResolver, c as Part, d as SendMessageRequest, f as StreamResponse, g as A2AAgentLinkOptions, h as linkA2AAgent, i as ClientFactory, l as RequestOptions, m as createA2AAgentLink, n as AgentCard, o as JsonRpcTransportFactory, p as Task, r as Client, s as Message, t as A2AAgentLink, u as RestTransportFactory, v as A2AUnlinkReport, y as LinkA2AAgentOptions } from "./client-DmkHTq-_.mjs";
2
+ import { C as TaskStore, E as createAgentCardFromDefinition, S as TaskState, T as AgentCardFromDefinitionOptions, a as AgentExecutor, b as ServerCallContext, c as DefaultRequestHandler, d as DefinedAgentA2AServer, f as DefinedAgentA2AServerOptions, h as JsonRpcTransportHandler, i as AgentEvent, l as DefinedAgentA2AExecutor, m as InMemoryTaskStore, n as A2A_PROTOCOL_VERSION, o as DefaultExecutionEventBus, p as ExecutionEventBus, s as DefaultExecutionEventBusManager, t as A2ADisposeReport, u as DefinedAgentA2AExecutorOptions, v as RequestContext, w as createDefinedAgentA2AServer, y as Role } from "./server-ejQSEjqI.mjs";
3
+ export { A2AAgentLink, type A2AAgentLinkOptions, A2ADisposeReport, type A2ALinkableTeam, type A2AUnlinkReport, A2A_PROTOCOL_VERSION, type AgentCardFromDefinitionOptions, AgentEvent, type AgentExecutor, type Client, ClientFactory, DefaultAgentCardResolver, DefaultExecutionEventBus, DefaultExecutionEventBusManager, DefaultRequestHandler, DefinedAgentA2AExecutor, DefinedAgentA2AExecutorOptions, DefinedAgentA2AServer, DefinedAgentA2AServerOptions, type ExecutionEventBus, InMemoryTaskStore, JsonRpcTransportFactory, JsonRpcTransportHandler, type LinkA2AAgentOptions, type RequestContext, type RequestOptions, RestTransportFactory, Role, type SendMessageRequest, ServerCallContext, type StreamResponse, TaskState, type TaskStore, createA2AAgentLink, createAgentCardFromDefinition, createDefinedAgentA2AServer, linkA2AAgent };
package/dist/index.mjs ADDED
@@ -0,0 +1,4 @@
1
+ import { a as RestTransportFactory, i as JsonRpcTransportFactory, n as ClientFactory, o as createA2AAgentLink, r as DefaultAgentCardResolver, s as linkA2AAgent, t as A2AAgentLink } from "./client-2bhYYreC.mjs";
2
+ import { a as DefaultRequestHandler, c as JsonRpcTransportHandler, d as TaskState, f as createDefinedAgentA2AServer, i as DefaultExecutionEventBusManager, l as Role, n as AgentEvent, o as DefinedAgentA2AExecutor, p as createAgentCardFromDefinition, r as DefaultExecutionEventBus, s as InMemoryTaskStore, t as A2A_PROTOCOL_VERSION, u as ServerCallContext } from "./server-BX1bnVUG.mjs";
3
+
4
+ export { A2AAgentLink, A2A_PROTOCOL_VERSION, AgentEvent, ClientFactory, DefaultAgentCardResolver, DefaultExecutionEventBus, DefaultExecutionEventBusManager, DefaultRequestHandler, DefinedAgentA2AExecutor, InMemoryTaskStore, JsonRpcTransportFactory, JsonRpcTransportHandler, RestTransportFactory, Role, ServerCallContext, TaskState, createA2AAgentLink, createAgentCardFromDefinition, createDefinedAgentA2AServer, linkA2AAgent };