Skip to main content

Core (Advanced)

The @caesura-io/core package is the framework-agnostic shared engine that powers all CaesuraO 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({
mode: 'sync', // Finish analysis before reading buffered guidance.
apiKey: process.env.CAESURA_API_KEY,
});

// Create once and reuse the returned backend ID.
const conversationId = await engine.createConversation({ name: 'Support session' });

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

// 2. Retrieve buffered recommendations
const state = engine.store.get(conversationId);
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

observe() advances the turn counter itself, including skipped observations. Keep the engine or its store across calls; custom stores should retain states while inFlight is true.

The engine preserves caller-owned messages, applies budgets to dialogue plus prior analyses, and sets currentUser from the configured agent name. See Conversations & Persistence and Configuration for shared behavior.