Minimal runtime core for agent turn orchestration.
vanna-agent-core provides deterministic turn execution primitives:
- Turn contracts (
UserTurn,RuntimeTurnResult,RuntimeError) - Ordered event stream writer
- In-memory session manager with idempotency cache
- Runtime lifecycle guard (
localvscloudownership) - Pluggable
runTurn(...)orchestration with dependency injection hooks - Prompt builder helpers (runtime policy, personality context, extensions)
- No provider SDK binding (OpenAI/Anthropic/etc)
- No UI/client framework (TUI/web/desktop)
- No domain-specific trading logic
- No gateway/websocket transport implementation
npm install vanna-agent-coregit clone <your-repo-url> agent-core
cd agent-core
npm install
npm test
npm run typecheckRun the examples:
node examples/minimal-run.mjs
node examples/custom-hooks.mjsimport { createAgentRuntime } from "vanna-agent-core/runtime";
const runtime = createAgentRuntime({
stateRoot: "/tmp/agent-core-demo",
execute: async ({ emit, input }) => {
emit("assistant", "delta", { delta: "Hello" });
return { ok: true, outputText: `Echo: ${input.message}` };
}
});
const result = await runtime.turn({
sessionKey: "demo-session",
message: "Hello",
runtimeMode: "local"
});
console.log(result.ok, result.outputText, result.events.length);Typical app wiring:
- Create one
AgentRuntimeinstance at service startup. - In each API route or worker job, call
runtime.turn(...). - Forward
onEventcallbacks to logs/websocket/UI if needed.
See docs/BUILDING_ON_TOP.md for an end-to-end integration recipe.
runTurn flow:
- Validate input
- Resolve session + idempotency
- Acquire runtime lifecycle lock for workspace/mode
- Optionally load context via
contextProvider - Build system prompt
- Execute model/tool runtime via injected
execute - Persist in-memory session turn + emit deterministic event stream
createAgentRuntime/runTurn supports these hooks:
contextProvider(request)for prompt extensions / metadatapromptBuilder(context)for custom prompt assemblyexecute(input)for your model/tool runnererrorClassifier(error)for custom runtime error mappingonEvent(event)for streaming observers
npm test
npm run typecheckexamples/minimal-run.mjsexamples/custom-hooks.mjs
Use these guides when integrating this package into your own runtime:
docs/BUILDING_ON_TOP.mddocs/API.md
Current version is 0.x; API can change while extraction stabilizes.
Semver policy and contract details are in docs/API.md.