
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
ag-ui-cloudflare
Advanced tools
Native AG-UI protocol implementation for Cloudflare Workers AI - Enable CopilotKit with edge AI at 93% lower cost
Native AG-UI protocol implementation for Cloudflare Workers AI Power your CopilotKit apps with edge AI - 68% faster, 93% cheaper than OpenAI
npm install ag-ui-cloudflare
# Peer dependencies (if not already installed)
npm install @ag-ui/core @ag-ui/proto
import { CloudflareAGUIAdapter } from 'ag-ui-cloudflare';
const adapter = new CloudflareAGUIAdapter({
accountId: 'your-account-id',
apiToken: 'your-api-token',
model: '@cf/meta/llama-3.1-8b-instruct'
});
// Execute with AG-UI events
const messages = [
{ role: 'user', content: 'Hello, how are you?' }
];
for await (const event of adapter.execute(messages)) {
console.log(event.type, event.data);
}
import { CopilotRuntime } from '@copilotkit/runtime';
import { CloudflareAGUIAdapter } from 'ag-ui-cloudflare';
const adapter = new CloudflareAGUIAdapter({
accountId: process.env.CLOUDFLARE_ACCOUNT_ID!,
apiToken: process.env.CLOUDFLARE_API_TOKEN!,
});
const runtime = new CopilotRuntime({
adapter,
});
export async function POST(req: Request) {
return runtime.handle(req);
}
import { CloudflareProviders } from 'ag-ui-cloudflare';
// Auto-select best model based on capabilities
const adapter = CloudflareProviders.auto({
accountId: 'your-account-id',
apiToken: 'your-api-token',
tools: [...], // Will use Llama 3.3 70B if tools provided
});
// Or choose specific model providers
const fastAdapter = CloudflareProviders.llama3_8b(config);
const powerfulAdapter = CloudflareProviders.llama3_70b(config);
const functionAdapter = CloudflareProviders.llama3_3_70b(config); // Supports tools
import { CloudflareProviders } from 'ag-ui-cloudflare';
const adapter = CloudflareProviders.createWithGateway(
accountId,
apiToken,
gatewayId,
'@cf/meta/llama-3.1-70b-instruct'
);
// Benefits: Response caching, rate limiting, analytics
const tools = [{
type: 'function',
function: {
name: 'get_weather',
description: 'Get current weather',
parameters: {
type: 'object',
properties: {
location: { type: 'string' }
}
}
}
}];
const adapter = new CloudflareAGUIAdapter({
accountId: 'your-account-id',
apiToken: 'your-api-token',
model: '@cf/meta/llama-3.3-70b-instruct', // Only model with function calling
tools
});
for await (const event of adapter.execute(messages)) {
if (event.type === 'TOOL_CALL_START') {
console.log('Calling tool:', event.data.toolName);
}
}
const stages = [
{ name: 'Research', instruction: 'Research the topic' },
{ name: 'Outline', instruction: 'Create an outline' },
{ name: 'Write', instruction: 'Write the full article' }
];
for await (const event of adapter.progressiveGeneration('Write about AI', stages)) {
if (event.type === 'PROGRESS') {
console.log(`Progress: ${event.data.progress}% - ${event.data.message}`);
}
}
| Model | Speed | Cost | Context | Function Calling |
|---|---|---|---|---|
@cf/meta/llama-3.1-8b-instruct | ⚡⚡⚡ | $ | 128K | ❌ |
@cf/meta/llama-3.1-70b-instruct | ⚡⚡ | $$ | 128K | ❌ |
@cf/meta/llama-3.3-70b-instruct | ⚡⚡ | $$ | 128K | ✅ |
@cf/mistral/mistral-7b-instruct-v0.2 | ⚡⚡⚡ | $ | 32K | ❌ |
@cf/google/gemma-7b-it | ⚡⚡⚡ | $ | 8K | ❌ |
@cf/qwen/qwen1.5-14b-chat-awq | ⚡⚡ | $$ | 32K | ❌ |
The adapter emits standard AG-UI protocol events (16 total):
RUN_STARTED - Execution beginsRUN_FINISHED - Execution completesRUN_ERROR - Error during executionTEXT_MESSAGE_START - Text generation startsTEXT_MESSAGE_CONTENT - Streaming text chunksTEXT_MESSAGE_END - Text generation endsTOOL_CALL_START - Tool invocation beginsTOOL_CALL_ARGS - Tool arguments streamingTOOL_CALL_END - Tool invocation completesTOOL_CALL_RESULT - Tool execution resultsSTEP_STARTED - Processing step beginsSTEP_FINISHED - Processing step endsSTATE_SYNC - State synchronizationPROGRESS - Progress updates for multi-stage operationsMETADATA - Usage statistics and model infoCUSTOM - Application-specific eventsclass CloudflareAGUIAdapter {
constructor(options: CloudflareAGUIAdapterOptions)
execute(messages: CloudflareMessage[], context?: Record<string, any>): AsyncGenerator<AGUIEvent>
executeWithTools(messages: CloudflareMessage[], tools: Tool[], context?: Record<string, any>): AsyncGenerator<AGUIEvent>
progressiveGeneration(prompt: string, stages: Stage[]): AsyncGenerator<AGUIEvent>
setModel(model: CloudflareModel): void
getCapabilities(): ModelCapabilities
listAvailableModels(): Promise<string[]>
}
interface CloudflareAGUIAdapterOptions {
accountId: string; // Cloudflare account ID
apiToken: string; // API token with Workers AI permissions
model?: CloudflareModel; // Model to use (defaults to llama-3.1-8b)
baseURL?: string; // Custom API endpoint
gatewayId?: string; // AI Gateway ID for caching/analytics
systemPrompt?: string; // System prompt for all requests
tools?: Tool[]; // Available tools for function calling
streamingEnabled?: boolean; // Enable streaming (default: true)
}
npm test # Run tests
npm test:watch # Run tests in watch mode
npm test:coverage # Generate coverage report
npm run build # Build for production
npm run dev # Build in watch mode
npm run typecheck # Type checking
Contributions are welcome! Please read our contributing guidelines and submit PRs to our GitHub repository.
MIT
Built with ❤️ by the AG-UI community for seamless edge AI integration.
FAQs
Native AG-UI protocol implementation for Cloudflare Workers AI - Enable CopilotKit with edge AI at 93% lower cost
The npm package ag-ui-cloudflare receives a total of 0 weekly downloads. As such, ag-ui-cloudflare popularity was classified as not popular.
We found that ag-ui-cloudflare demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.