SDK for building Nebo apps. Mirrors native browser APIs (fetch, WebSocket, localStorage) while adding agent invocation, LLM completions, and real-time state management.
pnpm add @neboai/app-sdkOr use the global build via CDN:
<script src="https://unpkg.com/@neboai/app-sdk/dist/nebo.global.js"></script>import { nebo } from '@neboai/app-sdk';
// Fetch from your sidecar (relative) or external APIs (absolute, CORS-free)
const data = await nebo.fetch('/deals').then(r => r.json());
const weather = await nebo.fetch('https://api.weather.gov/points/40,-74').then(r => r.json());
// Persistent key-value storage
await nebo.storage.setItem('lastSync', Date.now());
const val = await nebo.storage.getItem('lastSync');
// Invoke the agent
const { text } = await nebo.agents.invoke('Summarize my deals');
// Stream agent responses
for await (const chunk of nebo.agents.stream('Analyze this quarter')) {
console.log(chunk.text);
}
// Direct LLM call (no persona)
const answer = await nebo.janus.complete({
messages: [{ role: 'user', content: 'What is 2+2?' }],
});
// Embed chat panel
nebo.chat.mount(document.getElementById('chat'), {
placeholder: 'Ask about your deals...',
theme: 'dark',
});
// Listen for agent-pushed state
nebo.surfaces.connect();
nebo.surfaces.on('state_snapshot', (e) => {
appState = e.snapshot;
render();
});Auto-routed fetch. Relative URLs go to your sidecar. Absolute URLs go through Nebo's CORS-free proxy.
Auto-reconnecting WebSocket with exponential backoff (1s–30s).
Server-persisted async key-value store: getItem, setItem, removeItem, clear, keys.
invoke(message, options?)— One-shot agent call, returns{ text, tools? }stream(message, options?)— Streaming agent call, yields{ text, done }
complete(options)— Direct LLM completionstream(options)— Streaming LLM completion
mount(element, options?)— Embed chat UIunmount()— Remove chat UIsend(message)— Programmatically send a messageonMessage(handler)— Listen for chat eventssetContext(context)— Update app context for the agentnewThread()— Start a new conversation
Real-time agent-to-app event system with typed events:
connect()/disconnect()on(type, handler)— Subscribe to events (returns unsubscribe fn)send(name, payload?)— Send action to agentrequestState()— Request full state snapshot
Events: run_started, run_finished, run_error, text_start, text_content, text_end, tool_call_start, tool_call_end, state_snapshot, state_delta, surface_create, surface_update, surface_delete, data_update, custom.
get()— Returns agent metadata (id, name, skills, model, etc.)invalidate()— Clear cached identity
A2UI v0.9 message bridge for agent-driven UI components.
init(processor)— Initialize with@a2ui/web_coreMessageProcessorsendAction(surfaceId, action)— Send UI action to agentsendError(surfaceId, code, message)— Report error to agent
Set appId and baseUrl manually (auto-detected by default).
| Format | File | Use |
|---|---|---|
| ESM | dist/index.js |
import { nebo } from '@neboai/app-sdk' |
| CJS | dist/index.cjs |
const { nebo } = require('@neboai/app-sdk') |
| IIFE | dist/nebo.global.js |
<script> tag — exposes window.NeboAppSDK |
MIT