@faktion-com/tracy-sdk
v0.0.8
Published
SDK for building and consuming agentic AI streams with tool calling support.
Downloads
499
Readme
@faktion-com/tracy-sdk
SDK for building and consuming agentic AI streams with tool calling support.
Overview
Tracy SDK provides a robust solution for streaming AI agent responses with tool calling capabilities. It consists of two main components:
- Server (
@faktion-com/tracy-sdk/server) - For building AI agents that produce agentic results - Client (
@faktion-com/tracy-sdk/client) - For consuming SSE (Server-Sent Events) streams from agents
The SDK handles the complexity of streaming tool calls, custom message parts, and agent responses in a type-safe, protocol-compatible way.
Installation
npm install @faktion-com/tracy-sdk
# or
pnpm add @faktion-com/tracy-sdk
# or
yarn add @faktion-com/tracy-sdkUsage
Server (Agent Producer)
import { createAgent } from '@faktion-com/tracy-sdk/server';
// Build an AI agent that produces streaming results
const agent = this._mastra.getAgent('citation-agent');
if (!isMessageListInput(messages)) {
throw new Error('Invalid messages');
}
const result = await agent.stream(messages);
const traceId = result.traceId;
if (traceId) {
publishCustomEvent(CustomEvents['X-Trace-Id'], traceId, subscriber);
}
produceSseStream(
result.fullStream.getReader(),
subscriber,
transformers.mastra
).catch((error) => {
logger.error('Error in stream:', error);
subscriber.error(error);
});
// Your agent configuration
});Client (Stream Consumer)
import { consumeStream } from '@faktion-com/tracy-sdk/client';
// Consume SSE streams from your AI agent
const stream = consumeStream(agentUrl);Available Exports
@faktion-com/tracy-sdk/server- Server-side agent utilities@faktion-com/tracy-sdk/client- Client-side stream consumption@faktion-com/tracy-sdk/protocol- Shared protocol definitions@faktion-com/tracy-sdk/schemas- Type schemas and validation@faktion-com/tracy-sdk/prompts- Prompt utilities
Features
- Tool calling support
- SSE streaming
- Custom message parts
- Type-safe protocols
- RAG (Retrieval-Augmented Generation) compatible
Publish
run in root:
pnpm run sdk:changelog // generate changelog for packages to publish
pnpm run sdk:bump // will implement the bumps from temp changelog (runs in cicd)
pnpm run sdk:release // will release bumps to npmLicense
MIT
