Skip to main content

Core (Advanced)

The @caesura-io/core package is the framework-agnostic shared engine that powers all Caesura SDK integrations. It contains the shared analysis, injection, and credit-metering logic.

warning

This package is not meant to be used directly by most developers.

You should use the framework-specific adapters instead:

What's Inside

If you are building a custom integration for a framework we don't currently support, the core package provides the following building blocks:

ModulePurpose
CaesuraClientHTTP client that calls the backend analysis endpoints.
MemoryCaesuraStoreIn-memory conversation state with LRU + idle-time eviction.
createCaesuraEngineOrchestrator: cadence checks, observe/analyze cycle, buffering, event emission.
createCreditMeterAccumulates and queries credit-usage metrics.
createDebugLoggerStructured onEvent logger for debugging.
HelpershashMessage, selectActive, renderAnalysis, renderBlock, buildAnalyzeMessages.
TypesCaesuraConfig, CaesuraEvent, InjectConfig, SendConfig, etc.

Usage for Custom Integrations

To build your own integration, you instantiate the engine and manually orchestrate the observation and injection cycles:

import { createCaesuraEngine, selectActive, renderBlock } from '@caesura-io/core';

const engine = createCaesuraEngine({
baseUrl: 'https://dev.caesura.io',
apiKey: process.env.CAESURA_API_KEY,
});

// 1. Observe a conversation turn
await engine.observe('conversation-id', [
{ speakerRole: 'user', speakerName: 'Customer', text: 'I need help preparing for the next meeting' },
]);

// 2. Retrieve buffered recommendations
const state = engine.store.get('conversation-id');
const active = selectActive(state, engine.config.inject, Date.now());

// 3. Render the insights for injection into your specific LLM prompt
const blocks = renderBlock(active, engine.config.inject);
// -> `blocks` contains rendered recommendation text ready for injection