Expand description
§OpenClaw Node.js Bridge
napi-rs bindings to expose Rust core functionality to Node.js.
§Features
- Configuration: Load and validate
OpenClawconfig files - Event Store: Append-only event storage with CRDT projections
- Providers: Anthropic Claude and
OpenAIGPT API clients - Auth: Encrypted credential storage with safe API key handling
- Tools: Tool registry for agent tool execution
- Validation: Input validation and session key building
§Example
const {
loadDefaultConfig,
AnthropicProvider,
NodeApiKey,
CredentialStore,
ToolRegistry,
NodeEventStore,
} = require('openclaw-node');
// Load configuration
const config = JSON.parse(loadDefaultConfig());
// Create provider
const provider = new AnthropicProvider(process.env.ANTHROPIC_API_KEY);
// Create completion
const response = await provider.complete({
model: 'claude-3-5-sonnet-20241022',
messages: [{ role: 'user', content: 'Hello!' }],
maxTokens: 1024,
});
console.log(response.content);Re-exports§
pub use providers::AnthropicProvider;pub use providers::JsCompletionRequest;pub use providers::JsCompletionResponse;pub use providers::JsMessage;pub use providers::JsStreamChunk;pub use providers::JsTokenUsage;pub use providers::JsTool;pub use providers::JsToolCall;pub use providers::OpenAIProvider;pub use auth::CredentialStore;pub use auth::NodeApiKey;pub use agents::JsToolDefinition;pub use agents::JsToolResult;pub use agents::ToolRegistry;
Modules§
- agents
- Agent runtime and tool bindings.
- auth
- Authentication and credential management bindings.
- error
- Structured error types for JavaScript consumption.
- providers
- AI Provider bindings for Anthropic,
OpenAI, etc.
Structs§
- Node
Event Store OpenClawevent store wrapper for Node.js.
Functions§
- build_
session_ key - Build a session key from components.
- load_
config - Load and parse an
OpenClawconfiguration file. - load_
default_ config - Load the default configuration (~/.openclaw/openclaw.json).
- validate_
config - Validate configuration and return any errors.
- validate_
message - Validate a message content string.
- validate_
path - Validate a file path for safety.