Delete the agentic loop
Tools, retries, compaction, session persistence, model fallback chains, streaming — one createAgentSession() call instead of a bespoke backend every vertical AI team rebuilds.
Documentation
Use Gajae-Code as the agent runtime for your own product — mobile apps, desktop apps, custom web frontends, and vertical AI applications. Delete your agentic loop; keep your product.
The bundled Telegram, Discord, and Slack integrations are themselves ordinary SDK clients. They use the exact same public contract described here — no private hooks, no upstream changes. Anything they do (render questions on your phone, route replies back to the exact session, stream turn summaries), your integration can do.
Tools, retries, compaction, session persistence, model fallback chains, streaming — one createAgentSession() call instead of a bespoke backend every vertical AI team rebuilds.
Every session hosts a loopback WebSocket endpoint. Embed Gajae-Code and phone notifications, remote ask approvals, CLI automation, and MCP orchestration all work with zero extra code.
The event stream supports multiple simultaneous subscribers: your app UI, a remote notifier, and an audit logger can all watch one session.
Tools, skills, rules, and the system prompt are injectable. The same runtime powers legal assistants, research agents, and data-analysis products.
| Embedding SDK (in-process) | WebSocket SDK (out-of-process) | |
|---|---|---|
| What it is | Import @gajae-code/coding-agent as a library | Connect to a running session's loopback endpoint |
| Language | TypeScript / Bun | Any language (JSON frames) |
| Telemetry | Full: token deltas, tool events, session events | Curated: ask/action frames, summarized turn stream, queries |
| Trust | You are the host | Token-authenticated client; secrets never cross the wire |
A common production shape uses both: your product UI subscribes in-process for full-fidelity streaming while remote channels attach over WebSocket for notifications and approvals.
bun add @gajae-code/coding-agent
import { createAgentSession } from "@gajae-code/coding-agent";
const { session } = await createAgentSession();
session.subscribe((event) => {
if (event.type === "message_update" &&
event.assistantMessageEvent.type === "text_delta") {
process.stdout.write(event.assistantMessageEvent.delta);
}
});
await session.prompt("Summarize this repository in 3 bullets.");
await session.dispose();
Provide to override, omit to discover: with no options it auto-discovers auth, models, settings, tools, context files, and a file-backed session store. Everything is overridable.
All of these are createAgentSession() options:
toolNames allowlist, bashAllowedPrefixes, plus runtime setActiveToolsByName().customTools (your domain tools) or mcpConfigPath (tools from an MCP server you own).skills, rules, contextFiles, promptTemplates, and systemPrompt (replace or transform the default blocks).SessionManager.inMemory() and Settings.isolated() for request-scoped agents.outputSchema, requireYieldTool, taskDepth for orchestrators.telemetry.Any running top-level session writes a discovery file at <repo>/.gjc/state/sdk/<sessionId>.json containing its url and token. Connect with any WebSocket client, or bun add @gajae-code/bridge-client and use SdkClient.
A minimal client handles three server frames — action_needed, action_resolved, reply_rejected — and sends one: reply. Optional threaded frames add turn_stream, context_update, activity, and image_attachment. Typed control operations (turn.prompt, turn.steer, model.set, session.fork, …) and read queries (transcript.*, diff.*, usage.get, …) cover nearly everything the TUI can do.
Sessions can be created programmatically with no pre-existing session: the SDK broker starts on demand (gjc daemon session, broker global session.create/fork/resume/close/delete), and multi-session controllers can use the Coordinator MCP.
Embed with toolNames + customTools + skills + a domain system prompt. Your UI streams token deltas in-process; users get phone approvals via the bundled adapters for free.
Run sessions under the broker; your backend attaches over WebSocket, renders turn_stream, answers asks with reply, reads history via transcript.*.
Exactly the contract the Telegram daemon implements: discover endpoints, render action_needed, send reply.
Coordinator MCP or broker globals to create and supervise many worktree-scoped sessions.
The WebSocket surface is loopback-only, never carries secrets (config.patch rejects secret fields; endpoint credentials are prohibited through chat adapters), streams summarized turn text (no thinking tokens; redaction-gated), and fails closed on stale action identity. Full-fidelity token streaming is an in-process embedding capability by design — the boundary is trust, not capability.