Skip to main content

Crate openclaw_node

Crate openclaw_node 

Source
Expand description

§OpenClaw Node.js Bridge

napi-rs bindings to expose Rust core functionality to Node.js.

§Features

  • Configuration: Load and validate OpenClaw config files
  • Event Store: Append-only event storage with CRDT projections
  • Providers: Anthropic Claude and OpenAI GPT 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§

NodeEventStore
OpenClaw event store wrapper for Node.js.

Functions§

build_session_key
Build a session key from components.
load_config
Load and parse an OpenClaw configuration 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.