chat

package
v0.12.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusInProgress  = "In Progress"
	StatusFinished    = "Finished"
	StatusErrored     = "Errored"
	StatusSurrendered = "Surrendered"
)

Status constants matching the-holonet protocol.

View Source
const (
	MessageTypeToolCall      = "toolCall"
	MessageTypeStatusMessage = "statusMessage"
	MessageTypeResponse      = "response"
	MessageTypeError         = "error"
)

MessageType constants matching the-holonet protocol.

Variables

This section is empty.

Functions

func RenderError

func RenderError(message string) string

RenderError renders an error message (red text).

func RenderMessage

func RenderMessage(msg MessageResponse) string

RenderMessage renders a MessageResponse based on its type.

func RenderResponse

func RenderResponse(message string) string

RenderResponse renders a response message (normal text).

func RenderStatus

func RenderStatus(message string) string

RenderStatus renders a status message (italic text).

func RenderToolCall

func RenderToolCall(message string) string

RenderToolCall renders a tool call message (dim text).

func RunREPL

func RunREPL(ctx context.Context, client *Client) error

RunREPL starts an interactive chat REPL.

func RunSingleShot

func RunSingleShot(ctx context.Context, client *Client, message string) error

RunSingleShot sends a single message and streams the response.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client manages a chat session with the Nullify AI agents.

func NewClient

func NewClient(conn Conn, queryParams map[string]string, opts ...ClientOption) *Client

NewClient creates a new chat client with the given connection.

func (*Client) ChatID

func (c *Client) ChatID() string

ChatID returns the current chat ID.

func (*Client) Close

func (c *Client) Close() error

Close closes the underlying connection.

func (*Client) ReadResponses

func (c *Client) ReadResponses() <-chan MessageResponse

ReadResponses returns a channel that streams responses from the server. The channel is closed when a terminal status is received or an error occurs.

func (*Client) Send

func (c *Client) Send(message string) error

Send sends a message to the chat server.

type ClientOption

type ClientOption func(*Client)

ClientOption configures a chat client.

func WithChatID

func WithChatID(id string) ClientOption

WithChatID sets a specific chat ID (for resuming conversations).

func WithSystemPrompt

func WithSystemPrompt(prompt string) ClientOption

WithSystemPrompt sets an extra system prompt.

type Conn

type Conn interface {
	WriteJSON(v any) error
	ReadJSON(v any) error
	Close() error
}

Conn is the interface for a WebSocket connection, allowing testability.

func Dial

func Dial(ctx context.Context, host string, token string) (Conn, error)

Dial connects to the Nullify chat WebSocket.

type MessageResponse

type MessageResponse struct {
	Status      string `json:"status"`
	MessageType string `json:"messageType"`
	Message     string `json:"message"`
}

MessageResponse is a message received from the Nullify chat WebSocket.

func (*MessageResponse) IsTerminal

func (m *MessageResponse) IsTerminal() bool

IsTerminal returns true if this response indicates the conversation turn is complete.

type Payload

type Payload struct {
	OwnerProvider     map[string]string `json:"ownerProvider"`
	ChatID            string            `json:"chatID"`
	Message           string            `json:"message"`
	ExtraSystemPrompt string            `json:"extraSystemPrompt"`
}

Payload is the message sent to the Nullify chat WebSocket.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL