core

package
v0.0.0-...-f6022ad Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package core holds momo's view of a conversation: the messages channels deliver and the action each direction leads to.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TextOf

func TextOf(content []ContentBlock) string

TextOf is the inverse of Text: the text blocks carry, joined, and nothing of the base64 payload an image, audio or blob block holds. A channel that speaks plain text converts with it at its own edge.

Types

type ContentBlock

type ContentBlock struct {
	Type     string    `json:"type"`
	Text     string    `json:"text,omitempty"`
	Data     string    `json:"data,omitempty"`
	MimeType string    `json:"mimeType,omitempty"`
	URI      string    `json:"uri,omitempty"`
	Name     string    `json:"name,omitempty"`
	Resource *Resource `json:"resource,omitempty"`
}

ContentBlock is one block of a message's content, in ACP v1's shape: a message arriving as ACP reaches the core unchanged and is forwardable to an agent harness as it was sent. Only the fields v1 requires are modelled. Channels that do not speak ACP convert at their own edge.

func Text

func Text(s string) []ContentBlock

Text is a text content block, the shape a channel with plain text messages converts into.

type EchoHandler

type EchoHandler struct {
	Log *slog.Logger
}

EchoHandler answers every incoming message with the content it carried.

ponytail: this is the proof that the reply path works end to end, nothing more; the agent harness replaces it.

func (EchoHandler) Received

func (h EchoHandler) Received(ctx context.Context, m Message, reply Reply)

func (EchoHandler) Sent

func (h EchoHandler) Sent(_ context.Context, m Message)

type Handler

type Handler interface {
	Received(ctx context.Context, m Message, reply Reply)
	Sent(ctx context.Context, m Message)
}

Handler is what a channel delivers messages to. The two directions are separate methods because each is an occasion for a different action, and only the incoming one has something to answer.

type Message

type Message struct {
	Contact string
	Content []ContentBlock
}

Message is a message exchanged with a contact, in the shape the core acts on.

type Reply

type Reply func(ctx context.Context, content []ContentBlock) error

Reply sends a reply on the channel the message arrived on. The destination is fixed when the message arrives, so it is not a parameter. It is safe to call from any goroutine.

type Resource

type Resource struct {
	URI  string `json:"uri"`
	Text string `json:"text,omitempty"`
	Blob string `json:"blob,omitempty"`
}

Resource is the contents an embedded resource block carries.

Jump to

Keyboard shortcuts

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