import { Hono, MiddlewareHandler } from 'hono'; import { A as A2ARequestHandler } from '../../a2a_request_handler-BuP9LgXH.js'; import { U as UserBuilder } from '../../handlers-Bje5MAUM.js'; export { v as AgentCardHandlerOptions, A as AgentCardProvider, J as JsonRpcHandlerOptions, x as RestHandlerOptions, q as agentCardHandler, s as jsonRpcHandler, t as restHandler } from '../../handlers-Bje5MAUM.js'; import { L as Logger } from '../../logger-DM9C11Ou.js'; export { C as ConsoleLogger, J as JsonLogger, b as LogContext, a as LogLevel, N as NoopLogger } from '../../logger-DM9C11Ou.js'; import { e as StreamConsumer } from '../../streaming-DMEWVCNM.js'; export { g as StreamResult, p as processStream } from '../../streaming-DMEWVCNM.js'; import '../../extensions-DvruCIzw.js'; import '../../error-CquguH6H.js'; /** * Hono integration for the A2A Server library. * * Provides A2AHonoApp for edge runtime applications using Hono. * Works with Cloudflare Workers, Deno, Bun, and Node.js. * * This implementation uses Hono's native `streamSSE` for optimal backpressure * handling in streaming responses. The SSE stream properly handles: * - Backpressure from slow clients * - Abort signal handling * - Graceful stream termination */ /** * Configuration options for A2AHonoApp. * Follows the unified A2AServerOptions pattern for consistency across all server implementations. */ interface A2AHonoOptions { /** Logger instance for request/error logging */ logger?: Logger; /** Function to build user from web-standard Request */ userBuilder?: UserBuilder; /** Path for agent card endpoint (default: '/.well-known/agent-card.json') */ agentCardPath?: string; /** Enable REST API endpoints (default: false) */ enableRest?: boolean; /** Base path for REST endpoints (default: '/rest') */ restBasePath?: string; } /** * A2AHonoApp provides A2A protocol support for Hono applications. * * This implementation uses Hono's native `streamSSE` for optimal backpressure * handling. Unlike web-standard ReadableStream, Hono's streaming: * - Applies backpressure when clients can't keep up * - Properly handles abort signals * - Manages stream lifecycle automatically * * @example * ```ts * import { Hono } from 'hono'; * import { A2AHonoApp } from '@drew-foxall/a2a-js-sdk/server/hono'; * import { DefaultRequestHandler, InMemoryTaskStore } from '@drew-foxall/a2a-js-sdk/server'; * * const requestHandler = new DefaultRequestHandler(agentCard, new InMemoryTaskStore(), executor); * const a2aApp = new A2AHonoApp(requestHandler, { enableRest: true }); * * const app = new Hono(); * a2aApp.setupRoutes(app, '/a2a'); * * export default app; * ``` */ declare class A2AHonoApp { private requestHandler; private jsonRpcTransportHandler; private restTransportHandler; private options; constructor(requestHandler: A2ARequestHandler, options?: A2AHonoOptions); /** * Builds user from request using the configured userBuilder. */ private buildUser; /** * Builds ServerCallContext from request. */ private buildContext; /** * Gets extension headers for response. */ private getExtensionsHeaders; /** * Adds A2A routes to an existing Hono app. * * @param app - The Hono app instance * @param baseUrl - The base URL for A2A endpoints (e.g., "/a2a") * @param middlewares - Optional array of Hono middlewares to apply to the A2A routes * @param agentCardPath - Optional custom path for the agent card endpoint (overrides constructor option) * @returns The Hono app with A2A routes */ setupRoutes(app: Hono, baseUrl?: string, middlewares?: MiddlewareHandler[], agentCardPath?: string): Hono; /** * Handles JSON-RPC requests with native Hono streaming. */ private handleJsonRpc; /** * Sets up REST API routes with native Hono streaming. */ private setupRestRoutes; } /** * Hono-specific streaming utilities for A2A. * * Provides a StreamConsumer implementation that uses Hono's native `streamSSE` * for optimal backpressure handling in edge runtime environments. */ /** * SSE stream interface compatible with Hono's streamSSE helper. * This is a minimal interface - Hono's actual SSEStreamingApi has more methods. */ interface HonoSSEStream { writeSSE(event: { id?: string; event?: string; data: string; }): Promise; } /** * Creates a StreamConsumer for Hono's streamSSE. * This is an async consumer with proper backpressure support. * * Hono's `streamSSE` provides: * - Backpressure handling (waits for client to consume data) * - Native abort signal handling * - Proper stream lifecycle management * * @example * ```ts * import { streamSSE } from 'hono/streaming'; * import { createHonoStreamConsumer } from './streaming.js'; * import { processStream } from '../transports/streaming.js'; * * return streamSSE(c, async (sseStream) => { * const consumer = createHonoStreamConsumer(sseStream, c.req.raw.signal); * await processStream(stream, consumer, { logger, logContext: {} }); * }); * ``` */ declare function createHonoStreamConsumer(sseStream: HonoSSEStream, signal?: AbortSignal): StreamConsumer; export { A2AHonoApp, type A2AHonoOptions, type HonoSSEStream, Logger, StreamConsumer, UserBuilder, createHonoStreamConsumer };