/** * Cluster-arg resolver for native Kafka handlers. Asymmetric by connection * type: * * - Direct: returns `{ clusterId: undefined, envId: undefined }`. The * `DirectClientManager` ignores cluster args and uses its eagerly-built * single-instance client(s); the handler passes the undefineds through. * - OAuth: requires the args; throws with a discovery hint if missing. * Handlers catch the throw at entry and convert to a `CallToolResult` * with `isError: true` so the agent receives a normal tool-call error * rather than an RPC failure. */ import { ConnectionConfig } from "../../config/models.js"; import { ServerRuntime } from "../../server-runtime.js"; /** * Shared env + Kafka-cluster resolver for Confluent Cloud REST handlers that * address a resource by environment + cluster and carry those ids in the * request URL/body (Connect, Tableflow). Distinct from the native-Kafka * {@link resolveKafkaClusterArgs}, which returns `undefined` on direct because * the `DirectClientManager` ignores cluster args — here the handler genuinely * needs the concrete ids. * * - Direct: explicit tool args win, falling back to the connection's * `kafka.env_id` / `kafka.cluster_id`. Throws `"Environment ID is required"` / * `"Kafka Cluster ID is required"` if either value is absent from both * sources. * - OAuth: both args are required (an OAuth connection carries no `kafka` block * to fall back to). Throws a discovery hint pointing at `list-environments` / * `list-clusters` when either is missing. */ export declare function resolveEnvAndClusterArgs(conn: ConnectionConfig, envIdArg: string | undefined, clusterIdArg: string | undefined): { environment_id: string; kafka_cluster_id: string; }; export declare function resolveKafkaClusterArgs(args: { cluster_id?: string; environment_id?: string; }, runtime: ServerRuntime, connId: string): { clusterId: string | undefined; envId: string | undefined; }; /** * REST-tool variant of {@link resolveKafkaClusterArgs}. The Kafka REST API * places `cluster_id` directly in the URL path * (e.g. `/kafka/v3/clusters/{id}/topics`), so the handler always needs a * concrete cluster id — even on direct connections that omit the arg and * rely on the configured fallback. * * Direct: `args.clusterId ?? conn.kafka?.cluster_id`; throws if neither. * `envId` is unused (direct's `kafka.rest_endpoint` already targets the * per-cluster hostname). * OAuth: both `clusterId` and `environmentId` required. Argument names are * camelCase to match the existing input-schema convention of these tools * and `list-clusters`; the native-Kafka tools' snake_case `cluster_id` is * a separate convention. */ export declare function resolveKafkaRestArgs(args: { clusterId?: string; environmentId?: string; }, runtime: ServerRuntime, connId: string): { clusterId: string; envId: string | undefined; }; /** * Env-only resolver for tools that scope a request to a single CCloud * environment without a cluster identifier (e.g., `list-clusters`). * * Direct: arg wins; falls back to `conn.kafka?.env_id`; throws if neither * source supplies a value. * OAuth: arg required (no service block to fall back to); throws with a * discovery hint pointing at `list-environments`. * * Argument name is camelCase (`environmentId`) to match the existing * input-schema convention of cluster-management tools. */ export declare function resolveEnvArg(args: { environmentId?: string; }, runtime: ServerRuntime, connId: string): string; /** * Disposes a Kafka client (admin or producer) iff the connection is OAuth-typed. * On direct connections this is a no-op — direct's `AsyncLazy` admin/producer * are manager-owned singletons and must not be disconnected by handlers. On * OAuth, calls `client.disconnect()` and swallows + logs any error so disposal * failure never masks the handler's own error. */ export declare function disposeIfOAuth(runtime: ServerRuntime, connId: string, client: { disconnect: () => Promise; }): Promise; /** * Renders any error thrown from a Kafka admin/producer/consumer call into a * single agent-readable string. Preserves per-topic-cause unwrapping for * `KafkaJSAggregateError`, surfaces `KafkaJSError.code` when present, and * falls back gracefully for unknown shapes. */ export declare function formatKafkaError(err: unknown): string; //# sourceMappingURL=cluster-arg-resolvers.d.ts.map