@best-agent/engine
v0.0.2-beta.8
Published
Runtime core for `best-agent`.
Downloads
62
Readme
@best-agent/engine
Runtime core for best-agent.
Main Exports
Runtime:
AgentRuntimecreateAgentProfileRegistry()AgentProfileInput
Storage and memory:
LocalThreadStoreLocalThreadMemoryresolveWorkspaceStorageRoot()DEFAULT_STORAGE_DIRECTORY_NAME
Tools, skills, and hosted contributions:
ToolRegistrycreateDefaultToolRegistry()createCommandToolDefinition()createMcpToolDefinition()SkillRegistrycreateHostedContributionBundle()defineTool(...)defineSkill(...)
Policy, sandbox, and provider:
RuntimePolicycreateDefaultRuntimePolicy()DEFAULT_ALLOWED_TOOLSLocalSandboxcreateModelProvider()OpenAiSdkProviderAnthropicSdkProviderGoogleSdkProvider
Prompting:
compilePrompt()
Features
- persisted thread lifecycle with SQLite-backed storage
- thread modes:
defaultplan
- approvals, queue/steer controls, sandboxing, and workspace grounding
- segmented memory, compaction, handoff snapshots, and diagnostics
- project-scoped cross-session memory injection via authoritative
memory.md, next-session candidate consolidation, generated-section freshness metadata, and a stale-memory eval gate - built-in workflows and deep research
- built-in lightweight LSP tools for
TypeScript/JavaScriptnavigation plusPythondiagnostics and symbol search, with soft fallback for unsupported files fetch-url(format:"rich"),web-searchwith native OpenAI or runtime-provided adapter execution, deep-research workflow budgeting, soft-unavailable fallback, and prompt-cache diagnostics/benchmarking in the shared tool/runtime path- provider-backed turns plus runtime-owned tool execution
- hosted-contribution, skill, extension, and MCP normalization into one runtime
- hosted
PreToolUse/PostToolUsehooks and Guardian-backed model-assisted approval assessments with an offline eval corpus - composable-runtime primitives:
AgentDefinitioninputs normalized throughcreateAgentProfileRegistry()ToolRegistryconflict strategiescreateDefaultToolRegistry({ excludeBuiltIns, noBuiltIns, extraTools })AgentDefinition.loopKind = "advanced"for custom advanced-phase runsAgentDefinition.maxToolStepsfor per-agent provider loop limitsAgentDefinition.modelStrategyfor per-agent routing overridescustomLoopsandAgentDefinition.customLoopIdfor custom turn-loop replacement- per-agent permission overlays and project
.best-agent/agentsloading
Example
import { AgentRuntime } from "@best-agent/engine";
const runtime = new AgentRuntime({
cwd: process.cwd(),
storageRoot: "/tmp/best-agent-demo",
});
const { thread } = await runtime.startThread({ title: "Demo" });
const result = await runtime.runTurn({
threadId: thread.id,
prompt: 'tool:echo {"text":"hello"}',
});
console.log(result.turn.status);Internal Layout
agent/: built-in profiles and routingcore/: thread, approval, queue, and research storesmemory/: summaries, working memory, telemetry, compaction, segmented cacheplugin/: local and hosted plugin normalizationpolicy/: capability evaluationprompt/: prompt directives and project instructionsprovider/: AI SDK-backed model providersruntime/: turn execution and event emissionsandbox/: filesystem and subprocess enforcementskill/: installed skill registrytool/: built-in tool registry and structured input handling
Does Not Own
- transport protocols
- CLI UX
- external SDK process management
