delivery

package
v0.45.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: BSD-2-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidMarkdownWithFrontmatter

func IsValidMarkdownWithFrontmatter(content string) bool

IsValidMarkdownWithFrontmatter checks that the string has valid YAML frontmatter delimiters. The content must start with "---" followed by a newline and have a closing "---" on its own line.

func ParseMarkdownFrontmatter

func ParseMarkdownFrontmatter(content string) (map[string]string, string)

ParseMarkdownFrontmatter splits a markdown document with YAML frontmatter into a string map and the body. Returns empty map and full content if no frontmatter. Values are converted to strings: arrays become fmt representation, nested objects become fmt representation.

func PrintResult

func PrintResult(ctx context.Context, result any) error

PrintResult marshals any value to JSON and prints to stdout.

func ReplaceOrAppendSection

func ReplaceOrAppendSection(content, heading, newSection string) string

ReplaceOrAppendSection replaces an existing ## section or appends it at the end.

func SetFrontmatterField

func SetFrontmatterField(content, key, value string) string

SetFrontmatterField updates or adds a field in YAML frontmatter. Returns content unchanged if no frontmatter delimiters are found.

func StripMarkdownCodeFences

func StripMarkdownCodeFences(s string) string

StripMarkdownCodeFences removes surrounding ``` code fences from a string if present.

Types

type AgentResultInfo

type AgentResultInfo struct {
	Status  AgentStatus
	Output  string // human-readable summary or result body
	Message string // error or status message
}

AgentResultInfo holds the minimum fields a ContentGenerator needs from any agent result.

type AgentStatus

type AgentStatus string

AgentStatus represents the outcome status of an agent task.

const (
	// AgentStatusDone indicates the task completed successfully.
	AgentStatusDone AgentStatus = "done"
	// AgentStatusFailed indicates the task failed.
	AgentStatusFailed AgentStatus = "failed"
	// AgentStatusNeedsInput indicates the task requires additional user input.
	AgentStatusNeedsInput AgentStatus = "needs_input"
)

type ContentGenerator

type ContentGenerator interface {
	Generate(ctx context.Context, originalContent string, result AgentResultInfo) (string, error)
}

ContentGenerator produces a complete updated task markdown document from the original content and agent result. The returned string must be valid markdown with YAML frontmatter.

func NewFallbackContentGenerator

func NewFallbackContentGenerator() ContentGenerator

NewFallbackContentGenerator creates a ContentGenerator that uses deterministic string concatenation.

type ResultDeliverer

type ResultDeliverer interface {
	DeliverResult(ctx context.Context, result AgentResultInfo) error
}

ResultDeliverer publishes an agent result back to the task controller.

func NewFileResultDeliverer

func NewFileResultDeliverer(generator ContentGenerator, filePath string) ResultDeliverer

NewFileResultDeliverer creates a ResultDeliverer that writes results to a task file. The generator produces the complete updated markdown; the deliverer writes it to disk.

func NewKafkaResultDeliverer

func NewKafkaResultDeliverer(
	syncProducer libkafka.SyncProducer,
	branch base.Branch,
	taskID agentlib.TaskIdentifier,
	originalContent string,
	generator ContentGenerator,
	currentDateTime libtime.CurrentDateTimeGetter,
) ResultDeliverer

NewKafkaResultDeliverer creates a ResultDeliverer that publishes task updates to Kafka. taskID must be non-empty; if empty, use NewNoopResultDeliverer instead. originalContent is the original task markdown; the generator produces the complete updated content.

func NewNoopResultDeliverer

func NewNoopResultDeliverer() ResultDeliverer

NewNoopResultDeliverer creates a ResultDeliverer that does nothing.

Jump to

Keyboard shortcuts

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