Command Palette

Search for a command to run...

google-adk-client

Active

A strongly-typed TypeScript SDK that bridges the Google Agent Development Kit (ADK) with the Vercel AI SDK ecosystem.

Overview

As generative AI matures, developers are shifting from building simple chatbots to orchestrating complex, autonomous agents using tools like the Google Agent Development Kit (ADK). However, integrating these enterprise-grade APIs into modern frontend frameworks often requires significant boilerplate to handle Server-Sent Events (SSE) and UI state.

I built @kentandrian/google-adk to eliminate this friction. It is a high-level, isomorphic TypeScript library that abstracts away the complexities of the Google ADK API. More importantly, it provides native, plug-and-play connectors for the Vercel AI SDK, allowing developers to build robust AI user interfaces in minutes.

Features

This library was designed with a strict focus on Developer Experience (DX), ensuring maximum flexibility across environments.

  • Seamless AI SDK Integration: Provides a simple and robust way to connect the Google ADK agent service directly to the Vercel AI SDK and its ecosystem of UI components.
  • Strongly-Typed: Written entirely in TypeScript to provide deep autocomplete and strong type safety for all ADK API interactions (Sessions, Artifacts, etc.).
  • Flexible & Isomorphic: Can be used in any modern TypeScript project, including Node.js backends, Next.js Edge runtimes, and browser-based applications.
  • Simple and Robust: Abstracted complexity replaces hundreds of lines of raw HTTP requests, header management, and stream parsing with a clean, class-based architecture.

Architecture

The package is architected to be modular. By utilizing Subpath Exports (. vs ./ai-sdk), developers only import the exact code they need. The Vercel ai package is treated as an optional peer dependency to keep the core ADK client lean for non-Vercel environments.

The Stack Breakdown

  • Core Language: Strict TypeScript (Targeting Node & Edge environments).
  • Package Manager: pnpm v10 for strict workspace and dependency resolution.
  • Linting & Formatting: Biome (v2.4), replacing traditional Prettier/ESLint pipelines for sub-millisecond Rust-based execution.
  • Testing: Vitest for blazing-fast, ESM-native unit testing.

Server-Side Connector

The library provides a custom stream formatter that instantly converts Google ADK SSE responses into Vercel AI-compatible streams within a Next.js App Router API route:

// src/app/api/chat/route.ts
import { AdkClient } from "@kentandrian/google-adk";
import { createAdkAiSdkStream } from "@kentandrian/google-adk/ai-sdk";
import { auth } from "lib/auth";
 
export async function POST(req: Request) {
  const { messages } = await req.json();
  const session = await auth();
 
  if (!session?.user?.id) return new Response("Unauthorized", { status: 401 });
 
  const client = new AdkClient({
    baseUrl: process.env.ADK_BASE_URL,
    appName: process.env.ADK_APP_NAME,
    userId: session.user.id,
  });
 
  const adkResponse = await client.runSse("session-123", messages);
  return createAdkAiSdkStream(adkResponse);
}

Client-Side Transport

For architectures where direct client-to-agent communication is preferred, the library exposes a custom AdkChatTransport class, extending the native HttpChatTransport:

import { useChat } from "@ai-sdk/react";
import { AdkClient } from "@kentandrian/google-adk";
import { AdkChatTransport } from "@kentandrian/google-adk/ai-sdk";
 
const client = new AdkClient({
  baseUrl: "https://my-adk-agent.example.com",
  appName: "my-app-name",
  userId: "user-123",
});
 
const transport = new AdkChatTransport(client);
 
export function MyChatComponent() {
  const { messages, input, handleInputChange, handleSubmit } = useChat({
    transport,
  });
  // ... render chat UI
}

Milestones & Migrations

Building open-source tooling requires strict attention to semantic versioning, bundle size, and developer adoption.

2026: Tooling Upgrades & Type Consistency

  • Shipped v0.1.4 and v0.1.5, introducing robust handleDataLine helper functions to safely parse and stream complex ADK SSE payloads.
  • Upgraded the core infrastructure to TypeScript 6.0, enforcing strict read-only class properties and modern import protocols.
  • Implemented automated cross-library type compatibility testing using Vitest to guarantee seamless integration between Google's upstream changes and the Vercel ecosystem.

2025: Foundation & Type Vendoring

  • Architected the core client, utilizing Subpath Exports to cleanly separate core ADK functionality from the ai-sdk connectors.
  • Executed a massive type-vendoring strategy: systematically extracted and modularized core types from the upstream @google/adk and @google/genai repositories. This critical architectural decision ensures the package remains highly typed without forcing users to install heavy, potentially conflicting dependencies.
  • Migrated the repository to pnpm for deterministic dependency resolution and set up an automated GitHub Actions CI/CD release pipeline.