Documentation
¶
Overview ¶
Package nebo provides the SDK for building Nebo apps.
A Nebo app is a compiled binary that communicates with Nebo over gRPC via Unix sockets. The SDK handles all gRPC server setup, signal handling, and protocol bridging — you just implement handler interfaces for the capabilities your app provides.
Quick start:
app, _ := nebo.New()
app.RegisterTool(&MyTool{})
log.Fatal(app.Run())
Index ¶
- Variables
- type App
- func (a *App) Env() *AppEnv
- func (a *App) OnConfigure(fn func(map[string]string))
- func (a *App) RegisterChannel(h ChannelHandler)
- func (a *App) RegisterComm(h CommHandler)
- func (a *App) RegisterGateway(h GatewayHandler)
- func (a *App) RegisterSchedule(h ScheduleHandler)
- func (a *App) RegisterTool(h ToolHandler)
- func (a *App) RegisterUI(h UIHandler)
- func (a *App) Run() error
- type AppEnv
- type ChannelHandler
- type CommHandler
- type CommMessage
- type GatewayEvent
- type GatewayHandler
- type GatewayMessage
- type GatewayRequest
- type GatewayToolDef
- type InboundMessage
- type Schedule
- type ScheduleHandler
- type ScheduleHistoryEntry
- type ScheduleTrigger
- type SchemaBuilder
- func (s *SchemaBuilder) Bool(name, description string, required bool) *SchemaBuilder
- func (s *SchemaBuilder) Build() json.RawMessage
- func (s *SchemaBuilder) Enum(name, description string, required bool, values ...string) *SchemaBuilder
- func (s *SchemaBuilder) Number(name, description string, required bool) *SchemaBuilder
- func (s *SchemaBuilder) Object(name, description string, required bool) *SchemaBuilder
- func (s *SchemaBuilder) String(name, description string, required bool) *SchemaBuilder
- type SelectOption
- type ToolHandler
- type ToolHandlerWithApproval
- type UIBlock
- type UIEvent
- type UIEventResult
- type UIHandler
- type UIHandlerWithStreaming
- type View
- type ViewBuilder
- func (v *ViewBuilder) Build() *View
- func (v *ViewBuilder) Button(blockID, text, variant string) *ViewBuilder
- func (v *ViewBuilder) Divider(blockID string) *ViewBuilder
- func (v *ViewBuilder) Heading(blockID, text, variant string) *ViewBuilder
- func (v *ViewBuilder) Image(blockID, src, alt string) *ViewBuilder
- func (v *ViewBuilder) Input(blockID, value, placeholder string) *ViewBuilder
- func (v *ViewBuilder) Select(blockID, value string, options []SelectOption) *ViewBuilder
- func (v *ViewBuilder) Text(blockID, text string) *ViewBuilder
- func (v *ViewBuilder) Toggle(blockID, text string, on bool) *ViewBuilder
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoSockPath is returned when NEBO_APP_SOCK is not set. ErrNoSockPath = errors.New("NEBO_APP_SOCK environment variable is not set") // ErrNoHandlers is returned when Run() is called with no registered handlers. ErrNoHandlers = errors.New("no capability handlers registered — register at least one handler before calling Run()") )
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the main entry point for a Nebo app. It manages the gRPC server, capability registration, and lifecycle.
func New ¶
New creates a new Nebo App. It reads NEBO_APP_* environment variables and prepares the gRPC server. Returns ErrNoSockPath if NEBO_APP_SOCK is not set.
func (*App) OnConfigure ¶
OnConfigure sets a callback that is called when Nebo pushes settings updates. This is shared across all capability handlers.
func (*App) RegisterChannel ¶
func (a *App) RegisterChannel(h ChannelHandler)
RegisterChannel registers a ChannelHandler capability.
func (*App) RegisterComm ¶
func (a *App) RegisterComm(h CommHandler)
RegisterComm registers a CommHandler capability.
func (*App) RegisterGateway ¶
func (a *App) RegisterGateway(h GatewayHandler)
RegisterGateway registers a GatewayHandler capability.
func (*App) RegisterSchedule ¶
func (a *App) RegisterSchedule(h ScheduleHandler)
RegisterSchedule registers a ScheduleHandler capability.
func (*App) RegisterTool ¶
func (a *App) RegisterTool(h ToolHandler)
RegisterTool registers a ToolHandler capability.
func (*App) RegisterUI ¶
RegisterUI registers a UIHandler capability.
type AppEnv ¶
type AppEnv struct {
Dir string // NEBO_APP_DIR — app's installation directory
SockPath string // NEBO_APP_SOCK — Unix socket path to listen on
ID string // NEBO_APP_ID — app ID from manifest
Name string // NEBO_APP_NAME — app name from manifest
Version string // NEBO_APP_VERSION — app version from manifest
DataDir string // NEBO_APP_DATA — path to app's data/ directory
}
AppEnv provides typed access to NEBO_APP_* environment variables. These are set by Nebo's sandbox when launching your app.
type ChannelHandler ¶
type ChannelHandler interface {
ID() string
Connect(ctx context.Context, config map[string]string) error
Disconnect(ctx context.Context) error
Send(ctx context.Context, channelID, text string) error
Receive(ctx context.Context) (<-chan InboundMessage, error)
}
ChannelHandler is the interface for channel capability apps. Implement this to bridge an external messaging platform to Nebo.
type CommHandler ¶
type CommHandler interface {
Name() string
Version() string
Connect(ctx context.Context, config map[string]string) error
Disconnect(ctx context.Context) error
IsConnected() bool
Send(ctx context.Context, msg CommMessage) error
Subscribe(ctx context.Context, topic string) error
Unsubscribe(ctx context.Context, topic string) error
Register(ctx context.Context, agentID string, capabilities []string) error
Deregister(ctx context.Context) error
Receive(ctx context.Context) (<-chan CommMessage, error)
}
CommHandler is the interface for comm capability apps. Implement this to provide inter-agent communication for Nebo.
type CommMessage ¶
type CommMessage struct {
ID string
From string
To string
Topic string
ConversationID string
Type string // "message", "mention", "proposal", "command", "info", "task"
Content string
Metadata map[string]string
Timestamp int64
HumanInjected bool
HumanID string
}
CommMessage represents an inter-agent communication message.
type GatewayEvent ¶
type GatewayEvent struct {
Type string // "text", "tool_call", "thinking", "error", "done"
Content string
Model string
RequestID string
}
GatewayEvent is a streamed event sent back to Nebo.
type GatewayHandler ¶
type GatewayHandler interface {
Stream(ctx context.Context, req *GatewayRequest) (<-chan GatewayEvent, error)
Cancel(ctx context.Context, requestID string) error
}
GatewayHandler is the interface for gateway capability apps. Implement this to provide LLM model routing to Nebo.
type GatewayMessage ¶
type GatewayMessage struct {
Role string
Content string
ToolCallID string
ToolCalls string // JSON-encoded array
}
GatewayMessage is a single message in a conversation.
type GatewayRequest ¶
type GatewayRequest struct {
RequestID string
Messages []GatewayMessage
Tools []GatewayToolDef
MaxTokens int32
Temperature float64
System string
UserID string
UserPlan string
UserToken string // Only populated if app has "user:token" permission
}
GatewayRequest represents an LLM chat completion request from Nebo.
type GatewayToolDef ¶
GatewayToolDef describes a tool available to the model.
type InboundMessage ¶
type InboundMessage struct {
ChannelID string
UserID string
Text string
Metadata string // JSON-encoded
}
InboundMessage represents a message received from an external platform.
type ScheduleHandler ¶
type ScheduleHandler interface {
Create(ctx context.Context, req *pb.CreateScheduleRequest) (*pb.Schedule, error)
Get(ctx context.Context, name string) (*pb.Schedule, error)
List(ctx context.Context, limit, offset int32, enabledOnly bool) ([]*pb.Schedule, int64, error)
Update(ctx context.Context, req *pb.UpdateScheduleRequest) (*pb.Schedule, error)
Delete(ctx context.Context, name string) error
Enable(ctx context.Context, name string) (*pb.Schedule, error)
Disable(ctx context.Context, name string) (*pb.Schedule, error)
Trigger(ctx context.Context, name string) (bool, string, error)
History(ctx context.Context, name string, limit, offset int32) ([]*pb.ScheduleHistoryEntry, int64, error)
Triggers(ctx context.Context) (<-chan *pb.ScheduleTrigger, error)
}
ScheduleHandler is the interface for schedule capability apps. Implement this to replace Nebo's built-in cron scheduler.
type ScheduleHistoryEntry ¶
type ScheduleHistoryEntry = pb.ScheduleHistoryEntry
ScheduleHistoryEntry represents one execution of a schedule.
type ScheduleTrigger ¶
type ScheduleTrigger = pb.ScheduleTrigger
ScheduleTrigger is emitted when a schedule fires.
type SchemaBuilder ¶
type SchemaBuilder struct {
// contains filtered or unexported fields
}
SchemaBuilder constructs JSON Schema for STRAP-pattern tool inputs.
func NewSchema ¶
func NewSchema(actions ...string) *SchemaBuilder
NewSchema creates a SchemaBuilder with the given action names. Actions become an enum on the required "action" field.
func (*SchemaBuilder) Bool ¶
func (s *SchemaBuilder) Bool(name, description string, required bool) *SchemaBuilder
Bool adds a boolean parameter to the schema.
func (*SchemaBuilder) Build ¶
func (s *SchemaBuilder) Build() json.RawMessage
Build returns the complete JSON Schema as json.RawMessage.
func (*SchemaBuilder) Enum ¶
func (s *SchemaBuilder) Enum(name, description string, required bool, values ...string) *SchemaBuilder
Enum adds a string enum parameter to the schema.
func (*SchemaBuilder) Number ¶
func (s *SchemaBuilder) Number(name, description string, required bool) *SchemaBuilder
Number adds a number parameter to the schema.
func (*SchemaBuilder) Object ¶
func (s *SchemaBuilder) Object(name, description string, required bool) *SchemaBuilder
Object adds an object parameter to the schema.
func (*SchemaBuilder) String ¶
func (s *SchemaBuilder) String(name, description string, required bool) *SchemaBuilder
String adds a string parameter to the schema.
type SelectOption ¶
SelectOption is a choice for select-type blocks.
type ToolHandler ¶
type ToolHandler interface {
Name() string
Description() string
Schema() json.RawMessage
Execute(ctx context.Context, input json.RawMessage) (string, error)
}
ToolHandler is the interface for tool capability apps. Implement this to give Nebo's agent a new tool.
type ToolHandlerWithApproval ¶
type ToolHandlerWithApproval interface {
ToolHandler
RequiresApproval() bool
}
ToolHandlerWithApproval is an optional extension for tools that require user confirmation.
type UIBlock ¶
type UIBlock struct {
BlockID string
Type string // text, heading, input, button, select, toggle, divider, image
Text string
Value string
Placeholder string
Hint string
Variant string // button: primary/secondary/ghost/error; heading: h1/h2/h3
Src string // image source URL
Alt string // image alt text
Disabled bool
Options []SelectOption
Style string // compact, full-width
}
UIBlock is a single renderable element in a view.
type UIEvent ¶
type UIEvent struct {
ViewID string
BlockID string
Action string // "click", "change", "submit"
Value string
}
UIEvent represents a user interaction with a UI block.
type UIEventResult ¶
type UIEventResult struct {
View *View // Updated view (optional)
Error string // Error message (optional)
Toast string // Toast notification (optional)
}
UIEventResult is the response to a UI event.
type UIHandler ¶
type UIHandler interface {
GetView(ctx context.Context, viewContext string) (*View, error)
OnEvent(ctx context.Context, event UIEvent) (*UIEventResult, error)
}
UIHandler is the interface for UI capability apps. Implement this to render structured panels in Nebo's web interface.
type UIHandlerWithStreaming ¶
type UIHandlerWithStreaming interface {
UIHandler
StreamUpdates(ctx context.Context) (<-chan *View, error)
}
UIHandlerWithStreaming is an optional extension for apps that push live UI updates.
type ViewBuilder ¶
type ViewBuilder struct {
// contains filtered or unexported fields
}
ViewBuilder constructs a View with a fluent API.
func (*ViewBuilder) Button ¶
func (v *ViewBuilder) Button(blockID, text, variant string) *ViewBuilder
Button adds a button block.
func (*ViewBuilder) Divider ¶
func (v *ViewBuilder) Divider(blockID string) *ViewBuilder
Divider adds a divider block.
func (*ViewBuilder) Heading ¶
func (v *ViewBuilder) Heading(blockID, text, variant string) *ViewBuilder
Heading adds a heading block.
func (*ViewBuilder) Image ¶
func (v *ViewBuilder) Image(blockID, src, alt string) *ViewBuilder
Image adds an image block.
func (*ViewBuilder) Input ¶
func (v *ViewBuilder) Input(blockID, value, placeholder string) *ViewBuilder
Input adds an input block.
func (*ViewBuilder) Select ¶
func (v *ViewBuilder) Select(blockID, value string, options []SelectOption) *ViewBuilder
Select adds a select block.
func (*ViewBuilder) Text ¶
func (v *ViewBuilder) Text(blockID, text string) *ViewBuilder
Text adds a text block.
func (*ViewBuilder) Toggle ¶
func (v *ViewBuilder) Toggle(blockID, text string, on bool) *ViewBuilder
Toggle adds a toggle block.