#NPM package for ADK
1 messages · Page 1 of 1 (latest)
This solution has been AI generated
There isn't an ADK-specific NPM adapter for Node.js. To use your @google/adk agent without a Python server, expose it via the AG-UI protocol by wrapping it in an AbstractAgent and registering it with the CopilotRuntime.
Install
npm install @ag-ui/client
Implement an AG-UI Agent Adapter
Wrap your @google/adk logic in an AbstractAgent and emit the required AG-UI events in order.
import { AbstractAgent, RunAgentInput, RunAgentResult, EventType } from "@ag-ui/client";
import { Observable } from "rxjs";
// import { MyAdkAgent } from "./your-adk-logic"; // your @google/adk instance
export class AdkAgUIAdapter extends AbstractAgent {
async run(input: RunAgentInput): Promise<RunAgentResult> {
const events = new Observable<any>((subscriber) => {
(async () => {
try {
subscriber.next({ type: EventType.RunStarted });
// 1) Send input to your ADK agent
// 2) Stream back messages using TextMessageStart/TextMessageDelta/TextMessageEnd
// Example:
// subscriber.next({ type: EventType.TextMessageStart, role: "assistant" });
// subscriber.next({ type: EventType.TextMessageDelta, delta: "Hello" });
// subscriber.next({ type: EventType.TextMessageEnd });
subscriber.next({ type: EventType.RunFinished });
subscriber.complete();
} catch (err) {
subscriber.error(err);
}
})();
});
return { events };
}
}
Register with CopilotRuntime
const runtime = new CopilotRuntime({
agents: {
my_adk_agent: new AdkAgUIAdapter(),
},
});
Common causes of “silent” failures
- Protocol mismatch: Missing or out-of-order events (RunStarted → TextMessage* → RunFinished).
- Bad stream: run() must return { events } where events is a valid RxJS Observable.
- Agent name mismatch: Frontend agent id must match the key in runtime.agents.
References
- ADK Integration Overview: https://docs.copilotkit.ai/adk
- Connecting Existing Agents: https://docs.copilotkit.ai/adk/quickstart#use-an-existing-agent
- AG-UI Client Reference: https://github.com/CopilotKit/CopilotKit/tree/main/CopilotKit/packages/runtime-client-gql
Was this helpful?
If this solution worked for you, please click on the appropriate option below to help us improve:
useAgent: Agent 'default' not found after runtime sync (runtimeUrl=/api/copilotkit?storeSlug=nike-demo&guestId=guest_zk7hxw). No agents registered. Verify your runtime /info and/or agents__unsafe_dev_only.
src/app/shop/[slug]/layout.tsx (41:9) @ ShopLayout
39 |
40 | return (
41 | <CopilotKit runtimeUrl={
/api/copilotkit?storeSlug=${store.slug}&guestId=${guestId}}>
| ^
42 | <CartProvider>
43 | <div
44 | className={${theme.font === 'Inter' ? inter.variable : ''} min-h-screen bg-background font-sans antialiased}
Thank you for your feedback! Our team will provide additional assistance. 🔄