domain

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: AGPL-3.0 Imports: 0 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ActionRenderContent requests the host to display content to the user.
	// Payload: string (the content)
	ActionRenderContent = "RENDER_CONTENT"

	// ActionRequestInput requests the host to collect input from the user.
	// Payload: InputRequest
	ActionRequestInput = "REQUEST_INPUT"
)

Standard Action Types

View Source
const (
	// NodeTypeText displays content and continues immediately (soft step).
	NodeTypeText = "text"
	// NodeTypeQuestion displays content and halts waiting for input (hard step).
	// NOTE: Future architecture may merge this with InputType logic.
	NodeTypeQuestion = "question"
	// NodeTypeLogic executes internal script/logic (silent step).
	NodeTypeLogic = "logic"
)

NodeType constants define the control flow behavior.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionRequest

type ActionRequest struct {
	Type    string // e.g., "CLI_PRINT", "HTTP_GET"
	Payload any    // The data needed to perform the action
}

ActionRequest represents a side-effect that the engine requests the host to perform.

type ActionResponse

type ActionResponse struct {
	Success bool
	Data    any
	Error   error
}

ActionResponse represents the result of an ActionRequest.

type InputRequest added in v0.3.2

type InputRequest struct {
	Type    InputType `json:"type"`
	Options []string  `json:"options,omitempty"`
	Default string    `json:"default,omitempty"`
}

InputRequest describes the constraints and type of input needed.

type InputType added in v0.3.2

type InputType string

InputType defines the kind of input requested.

const (
	InputText    InputType = "text"
	InputConfirm InputType = "confirm"
	InputChoice  InputType = "choice"
)

type Node

type Node struct {
	ID   string `json:"id"`
	Type string `json:"type"` // e.g., "text", "question", "logic"

	// Content holds the raw data for this node.
	// For a text node, it might be the markdown content.
	// For a logic node, it might be the script or parameters.
	Content []byte `json:"content"`

	// Metadata allows for extensible key-value pairs.
	Metadata map[string]string `json:"metadata,omitempty"`

	// Transitions defines the possible paths from this node.
	Transitions []Transition `json:"transitions"`

	// Input Configuration (Optional)
	InputType    string   `json:"input_type,omitempty"`
	InputOptions []string `json:"input_options,omitempty"`
	InputDefault string   `json:"input_default,omitempty"`
}

Node represents a logical unit in the graph. It can contain text content (for Wiki-style) or logic instructions (for Logic-style).

type State

type State struct {
	// CurrentNodeID is the identifier of the active node.
	CurrentNodeID string

	// Memory holds variable state for the session.
	Memory map[string]any

	// History could track the path taken (optional for now, but good for debugging)
	History []string

	// Terminated indicates if the execution has reached a sink state (no transitions).
	Terminated bool
}

State represents the current snapshot of the execution.

func NewState

func NewState(startNodeID string) *State

NewState creates a clean state starting at a specific node.

type Transition

type Transition struct {
	FromNodeID string `json:"from_node_id,omitempty"`
	ToNodeID   string `json:"to_node_id"`

	// Condition is a simple expression string that must evaluate to true
	// for this transition to be valid. e.g., "user_age >= 18"
	// If empty, it's considered an "always" transition (default).
	Condition string `json:"condition,omitempty"`
}

Transition defines a rule to move from one node to another.

Jump to

Keyboard shortcuts

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