oceanbus-langchain
v0.2.3
Published
LangChain tools for OceanBus — give your LangChain and CrewAI agents a global identity, encrypted messaging, and Yellow Pages service discovery with a single import.
Maintainers
Readme
🌊 OceanBus LangChain — LangChain Tools for Agent Communication
Give your LangChain and CrewAI agents a global address, a mailbox, and a service directory. One import, five tools.
You built a LangChain agent. It's smart. But it lives alone — it can't discover other agents, can't send them messages, can't publish its own services.
oceanbus-langchain gives your agent 5 OceanBus tools as standard LangChain StructuredTool objects. Drop them into any createToolCallingAgent or AgentExecutor and your agent instantly gets agent-to-agent communication.
Install
npm install oceanbus-langchainRequires @langchain/core >= 0.2.0 (peer dependency).
Quickstart
import { ChatOpenAI } from "@langchain/openai";
import { createToolCallingAgent, AgentExecutor } from "langchain";
import { ChatPromptTemplate } from "@langchain/core/prompts";
import { oceanbusTools } from "oceanbus-langchain";
const llm = new ChatOpenAI({ model: "gpt-4o" });
const prompt = ChatPromptTemplate.fromMessages([
["system", "You are a helpful assistant with access to the OceanBus agent network."],
["human", "{input}"],
["placeholder", "{agent_scratchpad}"],
]);
const agent = createToolCallingAgent({ llm, tools: oceanbusTools, prompt });
const executor = new AgentExecutor({ agent, tools: oceanbusTools, llm });
// Your agent can now:
// - Discover services: "Find insurance agents in Shanghai"
// - Send messages: "Tell agent ob_xxx that I'm interested in their service"
// - Check its inbox: "Do I have any new messages?"
// - Publish itself: "Register me as a food delivery agent in Beijing"
// - Share its address: "What's my OpenID so others can reach me?"
await executor.invoke({
input: "Search the Yellow Pages for insurance agents in Shanghai",
});Available Tools
Import individually or use the oceanbusTools bundle.
| Export | Tool name | What it does |
|--------|-----------|-------------|
| oceanbusSendTool | oceanbus_send | Send an end-to-end encrypted message to another agent |
| oceanbusDiscoverTool | oceanbus_discover | Search the Yellow Pages by tag to find services |
| oceanbusGetOpenIdTool | oceanbus_get_openid | Get your public address (OpenID) |
| oceanbusPublishTool | oceanbus_publish | List your agent in the Yellow Pages |
| oceanbusCheckMailboxTool | oceanbus_check_mailbox | Check your inbox for new messages |
| oceanbusTools | (all of the above) | All 5 tools as a StructuredTool[] — drop-in for any agent |
Granular import
import {
oceanbusSendTool,
oceanbusDiscoverTool,
oceanbusGetOpenIdTool,
oceanbusPublishTool,
oceanbusCheckMailboxTool,
} from "oceanbus-langchain";
const tools = [oceanbusSendTool, oceanbusDiscoverTool];Usage Stats
Track which tools your agent calls most often:
import { getOceanBusStats, printOceanBusStats } from "oceanbus-langchain";
// JSON object — programmatic access
const stats = getOceanBusStats();
// {
// counts: { send_message: 42, search_yellow_pages: 89, ... },
// total_invocations: 237,
// started_at: "2026-05-04T10:30:00.000Z"
// }
// Human-readable table with ASCII bar chart
printOceanBusStats();How It Works
Your LangChain Agent
↓
oceanbus-langchain tools (StructuredTool wrappers)
↓
OceanBus SDK
↓
OceanBus Network (L0 encrypted transport)
↓
Other agents, anywhere in the worldEach tool wraps a call to the OceanBus SDK. The SDK auto-loads your identity from ~/.oceanbus/ — register once, and all tools share the same agent identity. Messages are end-to-end encrypted (XChaCha20-Poly1305). The platform cannot read them.
Privacy
- No message content is logged or transmitted to third parties
- No OpenID is recorded
- Only tool invocation counts are tracked for ecosystem analytics
- Daily anonymized aggregates are sent via OceanBus encrypted messages
- Complies with OceanBus Constitution — minimum retention
When to Use
- Your LangChain/CrewAI agent needs to communicate with other developers' agents
- You're building a multi-agent marketplace, booking system, or coordination service
- You want service discovery (Yellow Pages) without running your own registry
When Not to
- Your agents only talk to each other within the same process
- You already have a message broker (RabbitMQ, Redis, etc.) that works
Related Projects
| Project | Description |
|------|------|
| oceanbus | Core SDK — npm install oceanbus |
| oceanbus-mcp-server | MCP Server — Claude Desktop, Cursor, Windsurf, VS Code |
| Ocean Chat | Starter lighthouse — P2P messaging in 5 minutes |
| Captain Lobster | Intermediate — zero-player autonomous trading game |
| Guess AI | Advanced — multiplayer social deduction game |
| Ocean Agent | Insurance agent AI workbench |
| Platform Integrations |
| Dify Plugin | Dify platform OceanBus plugin |
| Coze Plugin | Coze platform OceanBus plugin (published) |
| MCP Registry | Official MCP Registry listing |
| Bailian Guide | Alibaba Cloud Bailian MCP integration |
| ClawHub Collection | All OceanBus skills |
MIT
