Connect your agents to Oceum
A zero-dependency Node.js SDK for reporting agent activity, logging tasks, and managing status. Install it, pass your API key and agent ID, and you're live.
npm install oceum
Quick Start
Get your API key from Settings and your agent ID from the Agents page once you sign in to the portal.
const { Oceum } = require('oceum'); const client = new Oceum({ apiKey: process.env.OCEUM_API_KEY, agentId: process.env.OCEUM_AGENT_ID, }); // Start auto-heartbeat (every 60s) client.startHeartbeat(); // Wrap tasks: auto logs start, complete, and errors const result = await client.wrap('Process leads', async () => { const leads = await fetchLeads(); await processAll(leads); return leads.length; }); // Clean up client.stopHeartbeat(); await client.setStatus('idle');
Configuration
The Oceum constructor accepts a configuration object with these properties:
oc_. Found in Settings > API Key.agt_. Assigned when you register an agent.https://oceum.ai. Override for self-hosted or development.API Reference
Sends a keep-alive signal. Updates the agent's status to active and refreshes the last heartbeat timestamp in the dashboard.
Logs the start of a task. Creates an activity log entry visible in the Logs page.
taskName, name of the task (string). meta, optional metadata object.
Logs task completion. Increments the agent's task count on the dashboard.
taskName, name of the task (string). meta, optional metadata object.
Logs an error. Increments the agent's error count. If fatal: true, sets agent status to error.
Options: message (defaults to errorName), stack (stack trace string), fatal (boolean, default false). Extra keys become metadata.
Logs a non-critical warning. Does not increment any counters.
Explicitly sets the agent's status. Valid values: active, idle, paused, offline, error.
Throws if an invalid status is provided.
Starts sending heartbeats at a regular interval. Default: every 60 seconds. Sends one immediately, then repeats. Errors are silently ignored: heartbeats are fire-and-forget.
The timer uses unref() so it won't prevent Node.js from exiting.
Stops the auto-heartbeat timer.
Wraps an async function with automatic lifecycle logging. Sends task_start before execution, task_complete on success, and error on failure. Re-throws any error after reporting it.
const result = await client.wrap('Sync contacts', async () => { const contacts = await crm.fetchAll(); await db.upsertMany(contacts); return contacts.length; });
Knowledge Infrastructure
Orion's intelligence is grounded in a RAG (Retrieval-Augmented Generation) pipeline that ensures every response is factual, sourced, and org-scoped. No hallucinations. Every answer cites its sources.
How It Works
When a user or agent asks Orion a question, the system embeds the query, searches for relevant knowledge chunks via hybrid search (vector similarity + keyword matching), and injects the most relevant context into the LLM prompt. Orion reasons over retrieved facts: it never invents.
Knowledge Tiers
| Tier | Description | Scope |
|---|---|---|
platform | Oceum agents, APIs, integrations, workflows | All orgs (system) |
operations | COO playbooks: finance, sales, support, marketing, HR, DevOps | All orgs (system) |
industry | Legacy systems (SAP, Salesforce, QuickBooks, NetSuite, ADP, Oracle, Dynamics, Workday) + market intelligence | All orgs (system) |
org_custom | Your organization's proprietary knowledge | Your org only |
agent_specific | Scoped to a single agent's domain | Per-agent |
Enterprise Knowledge Management
Upload your own documents via POST /api/knowledge. Documents go through an approval workflow (draft → approved → active) and are versioned with full rollback support. Only active documents appear in retrieval results.
Source Attribution
Every Orion response includes source citations: document name, section, and freshness date. You always know where the answer came from and how current it is.
Advanced Retrieval
Hybrid search combines vector similarity (pgvector HNSW) with keyword matching (PostgreSQL tsvector) via Reciprocal Rank Fusion. Optional Cohere Rerank further refines results. Adaptive top-K retrieval adjusts to query complexity within a strict 1,500-token context budget.
Event Types
Every SDK method sends a webhook event to POST /api/webhook. Here's what each event does server-side:
| Event | SDK Method | Server Effect | Log Level |
|---|---|---|---|
heartbeat |
heartbeat() |
Status → active, updates LastHeartbeat | info |
task_start |
taskStart() |
Creates activity log entry | info |
task_complete |
taskComplete() |
Increments TaskCount + log entry | info |
error |
error() |
Increments ErrorCount, fatal → status 'error' | error |
warning |
warning() |
Creates warning log entry | warning |
status |
setStatus() |
Updates agent status directly | info |
Framework Examples
The SDK works with any Node.js agent framework. Here are integration patterns for popular ones:
LangChain
const { Oceum } = require('oceum'); const { ChatOpenAI } = require('@langchain/openai'); const oceum = new Oceum({ apiKey: process.env.OCEUM_API_KEY, agentId: process.env.OCEUM_AGENT_ID, }); oceum.startHeartbeat(); const model = new ChatOpenAI({ model: 'gpt-4o' }); const answer = await oceum.wrap('Chat completion', async () => { const res = await model.invoke('Summarize Q1 revenue'); return res.content; });
CrewAI (Python → Node.js bridge)
// Node.js wrapper around a CrewAI Python process const { Oceum } = require('oceum'); const { execSync } = require('child_process'); const oceum = new Oceum({ apiKey: process.env.OCEUM_API_KEY, agentId: process.env.OCEUM_AGENT_ID, }); const result = await oceum.wrap('Research crew', async () => { const output = execSync('python crew.py --topic "AI trends"'); return output.toString(); }, { crew: 'research', agents: 3 });
Custom Agent Loop
const { Oceum } = require('oceum'); const oceum = new Oceum({ apiKey: process.env.OCEUM_API_KEY, agentId: process.env.OCEUM_AGENT_ID, }); oceum.startHeartbeat(30000); // every 30s while (true) { const job = await queue.dequeue(); if (!job) { await oceum.setStatus('idle'); await sleep(5000); continue; } await oceum.wrap(job.name, async () => { await processJob(job); }, { jobId: job.id }); } // On shutdown oceum.stopHeartbeat(); await oceum.setStatus('offline');
Pulse System
The Autonomous Pulse System gives your agent estate persistent awareness. Agents record observations between scheduled runs. Every 5 minutes, the Pulse cron synthesizes platform state and decides whether to act or stay quiet.
Agent Observations
Each agent cron records 0–3 observations per run using heuristic thresholds, no LLM calls required. Observations flow into the agent_observations table, scoped to your organization.
// Record an observation from your agent const { recordObservation } = require('./pulse-engine'); await recordObservation(supabase, { orgId: 'your-org-id', agentId: 'agt_your_agent', observationType: 'anomaly', content: 'Error rate exceeded 5% threshold', confidence: 0.85, sourceContext: { errorRate: 0.07, threshold: 0.05 } });
Pulse Evaluation
The Pulse cron builds a situation snapshot every 5 minutes. If the snapshot hash matches the previous tick, the LLM call is skipped entirely: eliminating ~90% of unnecessary API calls. When changes are detected, a single Haiku call decides: act or stay quiet.
Confidence-Gated Notifications
Notifications flow through a two-tier gate. Immediate alerts fire only when confidence exceeds 0.95 and severity is critical (max 3/day). Everything else is batched into a daily digest. Per-topic cooldowns prevent repeated alerts on the same issue.
Agent Journal
Every decision is recorded in an append-only journal with full reasoning. No UPDATE or DELETE permitted. Event types: noticed, decided, acted, deferred, consolidated, pruned, promoted.
Error Handling
All methods throw an OceumError when the API returns a non-2xx status code. The error includes the HTTP status code and the response body for programmatic handling.
const { Oceum, OceumError } = require('oceum'); try { await client.heartbeat(); } catch (err) { if (err instanceof OceumError) { if (err.statusCode === 401) { console.error('Invalid API key'); } else if (err.statusCode === 404) { console.error('Agent not found: check your agent ID'); } } }
Common Error Codes
| Status | Meaning | Fix |
|---|---|---|
401 | Invalid or missing API key | Check your apiKey value in Settings |
400 | Missing or invalid event data | Ensure agentId and event type are provided |
404 | Agent not found | Verify the agentId exists in your Agents page |
500 | Server error | Retry the request. If persistent, contact support |