@ekairos/events
Events domain library.
Context-first runtime for AI product interactions: contexts, turns, executions, steps, parts, and durable replay.
Schema
event_contexts
The aggregate root for a durable AI interaction, addressed by id or key.
event_items
Stored user and assistant items that make up the turn history.
event_executions
Reaction runs attached to a context, including status and runtime metadata.
event_steps
Execution-level steps for reasoning, action calls, and observable progress.
event_parts
Canonical output and replay surface for text, actions, data, and streamed chunks.
Actions
createContext
Builds a registered context with narrative, skills, actions, model, and reactor.
defineAction
Declares typed domain actions that a context reaction can call.
createAiSdkReactor
Adapts AI SDK model action-call output into canonical event items and parts.
runContextReactionDirect
Executes a context reaction without registry-specific UI glue.
useContext
React hook from @ekairos/events/react for reading and appending context items.
Register a context. Render it with package state.
Product code defines the context once and registry UI imports the package hook directly. The component stays presentation-focused.
import { createContext } from "@ekairos/events";
import { useContext } from "@ekairos/events/react";
export const tenderContext = createContext("tender.response")
.context(async (stored) => ({
tenderId: stored.content?.tenderId,
orgId: stored.content?.orgId,
}))
.narrative(async ({ content }) =>
`Prepare the supplier response for tender ${content.tenderId}.`,
)
.actions(async () => ({
// domain actions live here
}))
.model("gpt-4o-mini")
.build();
export function TenderAgent({ db, contextKey }) {
const context = useContext(db, { key: contextKey });
return <EventContextPanel context={context} />;
}