delivery

package
v0.45.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendSection added in v0.45.1

func AppendSection(content, newSection string) string

AppendSection appends newSection to content, ensuring a single blank line separator and exactly one trailing newline in the result.

func HasSection added in v0.45.1

func HasSection(content, heading string) bool

HasSection reports whether content contains at least one line that matches heading at line-start. A match requires the line to equal heading exactly, or to start with heading followed by a space or tab. Substrings like "## Results" do NOT match "## Result".

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 every section matching heading with newSection, or appends newSection if no matching section exists. The result always contains exactly one section with this heading.

func ReplaceSection added in v0.45.1

func ReplaceSection(content, heading, newSection string) string

ReplaceSection removes every section whose heading line matches heading (line-start match) and appends newSection once at the end. If no section matches, behaves identically to AppendSection.

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