Rakontevr SDK
Vendor SDK modules, CleverCase gateway wiring, and Gladys/Iorek integration
Rakontevr SDK
CleverCase V2 vendors @rakontevr/sdk under vendor/rakontevr/sdk/. The SDK is the HTTP and streaming client surface for BuilderHub, unified-agent, realtime streams, necromancy bundles, and tenant environments. CleverCase wraps the SDK with server-side gateway helpers so service keys and metering headers never reach the browser.
Module map
| Subpath | Module | Purpose |
|---|---|---|
@rakontevr/sdk | index.ts | Barrel export |
@rakontevr/sdk/http | http-client.ts | createRakontevrClient — typed fetch with auth |
@rakontevr/sdk/unified-agent | unified-agent.ts | BuilderHub Lyra/unified-agent JSON calls |
@rakontevr/sdk/agents | agents.ts | Published agent chat (agentChat, agentChatStream) |
@rakontevr/sdk/streams | streams.ts | WebSocket sidecar for activity/RSP progress |
@rakontevr/sdk/sse | sse.ts | parseSseStream, parseSseResponse |
@rakontevr/sdk/necromancy | necromancy.ts | Bundle list/push for necromancy reanimate |
@rakontevr/sdk/agent-marketplace | agent-marketplace.ts | Agent blueprint catalog |
@rakontevr/sdk/environments | environments.ts | Managed preview/staging environments |
unified-agent
callUnifiedAgent posts to ${baseUrl}/api/builderhub/unified-agent with identity headers (X-User-Id, X-Tenant-Id, X-Trace-Id, X-Task-Type, X-Agent-Tier). Options include memoryTier, pack, surfaceContext, multimodal attachments, and streaming via stream: true.
CleverCase does not call the SDK directly from browser code. Server routes use gladys-iorek-server.ts, which mirrors callUnifiedAgent streaming semantics while avoiding Turbopack symlink issues with the scoped package root.
agents
agentChat and agentChatStream target the published agent chat API for non-Gladys personas. Gladys legal queries route through unified-agent with personaId: "gladys" and domain: "legal" instead.
streams
connectStreams opens a WebSocket sidecar for channels such as activity, rsp-progress, and metering. Use subscribeChannels after onopen. In Node, pass WebSocketImpl from the ws package.
http-client
createRakontevrClient centralizes base URL, bearer/PAT auth, and tenant scoping:
import { createRakontevrClient } from "@rakontevr/sdk";
const client = createRakontevrClient({
baseUrl: process.env.RAKONTEVR_API_BASE_URL!,
auth: { kind: "bearer", token: process.env.RAKONTEVR_SERVICE_KEY! },
tenantId: "00000000-0000-4000-a000-000000000003",
});sse
parseSseStream consumes text/event-stream bodies and yields { event, data } tuples. Gladys BFF pipes upstream SSE through this parser before re-emitting events to the browser.
necromancy
necromancyListBundles and necromancyPushBundle sync reanimated schema bundles between CleverCase and the platform necromancy registry. The Prisma schema header // Generated by necromancy reanimate reflects this pipeline.
agent-marketplace
createAgentMarketplaceClient lists and executes published agent blueprints. CleverCase workflow agent_task nodes can dispatch marketplace agents when configured in template graphs.
environments
createEnvironment, provisionEnvironmentDns, and shareEnvironment manage preview environments for BuilderHub experiences. CleverCase tenant UUID 00000000-0000-4000-a000-000000000003 scopes all environment calls.
CleverCase: rak-gateway.ts
src/lib/clevercase/rak-gateway.ts stamps upstream identity for metering and audit:
| Export | Role |
|---|---|
buildRakGatewayHeaders | Merges telemetry headers + Authorization: Bearer <serviceKey> |
fetchViaRakGateway | Server-side fetch to BuilderHub/gateway paths |
createGatewayTraceId | UUID trace correlation (X-Trace-Id) |
createGatewaySpanId | Span correlation (X-Span-Id) |
Headers include X-User-Id, X-Tenant-Id, X-Metering-User-Id, X-Task-Type, and X-Agent-Tier. When the telemetry client is available, header stamping delegates to getClevercaseTelemetryClient().buildHeaders().
CleverCase: gladys-iorek-server.ts
streamGladysAsk is the server-side Gladys → Iorek client:
- Resolves runtime config from
getGladysRuntimeConfig()(env overrides). - POSTs to
/api/builderhub/unified-agentwithstream: true. - Parses upstream SSE via
parseSseStream. - Returns
{ answer, traceId }afterdoneevent.
Default surface context:
{
surface: "clevercase-experience",
personaId: "gladys",
domain: "legal",
virtualModel: "iorek", // or iorek-v4 via CC_GLADYS_VIRTUAL_MODEL
agentTier: "goliath", // floor via CC_GLADYS_AGENT_TIER
}Env overrides:
| Env | Default | Purpose |
|---|---|---|
CC_GLADYS_AGENT_TIER | goliath | Minimum agent tier |
CC_GLADYS_VIRTUAL_MODEL | iorek | Virtual model id |
CC_GLADYS_AGENT_MODE | 0 | Set 1 for agent-mode tool loops |
Request flow (Gladys)
Related
- Shield V2
- MCP Tools
- Gladys / Iorek Integration
vendor/rakontevr/sdk/README.mdsrc/lib/rakontevr-sdk.ts— re-export shim for app imports