input

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIFieldTypeCheckboxes  = openapi.FieldTypeCheckboxes
	APIFieldTypeLinearScale = openapi.FieldTypeLinearScale
	APIFieldTypeBoolean     = openapi.FieldTypeBoolean
)

Variables

View Source
var ErrInputNotPending = errors.New("input is not pending for job")

Functions

func GetAutoFillOp

func GetAutoFillOp() ops.RegisterableOp

GetAutoFillOp registers the op that echoes a pre-filled input response.

func GetOp

func GetOp() ops.RegisterableOp

func NormalizeOutputMap added in v0.0.11

func NormalizeOutputMap(opInput map[string]interface{}, opOutput map[string]interface{}) (map[string]interface{}, error)

Types

type APIFieldType

type APIFieldType = openapi.FieldType

APIFieldType is the generated transport enum for form fields.

type APIFormField

type APIFormField = openapi.FormField

APIFormField is the generated transport shape used by user-input clients.

type APIOption

type APIOption = openapi.Option

APIOption is the generated transport shape for select options.

type Artifact

type Artifact struct {
	Path string `json:"path" validate:"required" jsonschema:"required,description=Path to artifact file"`
}

Artifact represents a static artifact reference

type Config

type Config struct {
	// Single question format
	Question string       `json:"question,omitempty" validate:"required_without=Fields" jsonschema:"description=Question to ask the user"`
	Type     FieldType    `` /* 285-byte string literal not displayed */
	Options  []Option     `json:"options,omitempty" validate:"omitempty,min=1,dive" jsonschema:"description=Options for choice fields"`
	Scale    *LinearScale `` /* 126-byte string literal not displayed */
	Default  interface{}  `json:"default,omitempty" jsonschema:"description=Default value used when the response is omitted"`

	// Multi-field format
	Title   string      `json:"title,omitempty" jsonschema:"description=Form title"`
	Fields  []FormField `json:"fields,omitempty" validate:"omitempty,min=1,dive" jsonschema:"description=Form fields"`
	Context FormContext `json:"context,omitempty" jsonschema:"description=Form context and artifacts"`

	// Optional auto-fill response
	Output *Output `json:"autofill,omitempty" jsonschema:"description=Optional auto-fill output response"`
}

Config represents the configuration for the input activity

func (Config) ValidateOpInput added in v0.0.6

func (c Config) ValidateOpInput() error

type FieldType

type FieldType string

FieldType represents the type of form field

const (
	FieldTypeShortAnswer        FieldType = "short_answer"
	FieldTypeParagraphText      FieldType = "paragraph_text"
	FieldTypeMultipleChoice     FieldType = "multiple_choice"
	FieldTypeCheckboxes         FieldType = "checkboxes"
	FieldTypeDropdown           FieldType = "dropdown"
	FieldTypeLinearScale        FieldType = "linear_scale"
	FieldTypeBoolean            FieldType = "boolean"
	FieldTypeMultipleChoiceGrid FieldType = "multiple_choice_grid"
	FieldTypeCheckboxGrid       FieldType = "checkbox_grid"
	FieldTypeDate               FieldType = "date"
	FieldTypeTime               FieldType = "time"
	FieldTypeFileUpload         FieldType = "file_upload"
)

type FieldValidation

type FieldValidation struct {
	MinLength int    `json:"min_length,omitempty" jsonschema:"minimum=0,description=Minimum length for text fields"`
	MaxLength int    `json:"max_length,omitempty" jsonschema:"minimum=1,description=Maximum length for text fields"`
	Pattern   string `json:"pattern,omitempty" jsonschema:"description=Regex pattern for validation"`
	Min       int    `json:"min,omitempty" jsonschema:"description=Minimum value for numeric fields"`
	Max       int    `json:"max,omitempty" jsonschema:"description=Maximum value for numeric fields"`
}

FieldValidation represents validation rules for a form field

type FormContext

type FormContext struct {
	Artifacts           []Artifact    `json:"artifacts,omitempty" jsonschema:"description=Static artifact references"`
	ArtifactsFromOutput string        `json:"artifacts_from_output,omitempty" jsonschema:"description=Reference to artifacts from previous activity output"`
	ArtifactsGlob       []GlobPattern `json:"artifacts_glob,omitempty" jsonschema:"description=Glob patterns for artifact discovery"`
}

FormContext represents context information for the form

type FormField

type FormField struct {
	ID          string          `json:"id" validate:"required" jsonschema:"required,description=Unique field identifier"`
	Type        FieldType       `` /* 371-byte string literal not displayed */
	Question    string          `json:"question" validate:"required" jsonschema:"required,description=Field question or label"`
	Required    bool            `json:"required,omitempty" jsonschema:"description=Whether field is required"`
	Default     interface{}     `json:"default,omitempty" jsonschema:"description=Default value used when the field is omitted"`
	Placeholder string          `json:"placeholder,omitempty" jsonschema:"description=Placeholder text"`
	Options     []Option        `json:"options,omitempty" validate:"omitempty,min=1,dive" jsonschema:"description=Options for choice fields"`
	Scale       *LinearScale    `` /* 126-byte string literal not displayed */
	Validation  FieldValidation `json:"validation,omitempty" jsonschema:"description=Field validation rules"`
}

FormField represents a single field in a multi-field form

type FormResponse

type FormResponse = openapi.FormResponse

FormResponse represents the user's response to a form (OpenAPI-generated type).

type GlobPattern

type GlobPattern struct {
	Pattern string `json:"pattern" validate:"required" jsonschema:"required,description=Glob pattern for matching files"`
}

GlobPattern represents a glob pattern for artifact discovery

type Input

type Input struct {
	Form Config `json:"form,omitempty" validate:"required" jsonschema:"description=Form formuration"`
}

Input represents the inputs passed to the input activity

func (Input) ValidateOpInput added in v0.0.6

func (in Input) ValidateOpInput() error

type InputCancelSignal

type InputCancelSignal struct {
	ActivityID string `json:"activity_id"`
	ResponseID string `json:"response_id"`
	Reason     string `json:"reason"`
}

InputCancelSignal represents a signal to cancel a pending input request

type InputForm

type InputForm struct {
	// Single question fields
	Question string       `json:"question,omitempty" jsonschema:"description=Single question text"`
	Type     FieldType    `` /* 177-byte string literal not displayed */
	Options  []Option     `json:"options,omitempty" jsonschema:"description=Options for single choice field"`
	Scale    *LinearScale `json:"scale,omitempty" jsonschema:"description=Configuration for linear scale fields"`
	Default  interface{}  `json:"default,omitempty" jsonschema:"description=Default value used when the response is omitted"`

	// Multi-field form
	Title  string      `json:"title,omitempty" jsonschema:"description=Form title"`
	Fields []FormField `json:"fields,omitempty" jsonschema:"description=Form fields for multi-field form"`

	// Common fields
	Context FormContext   `json:"context,omitempty" jsonschema:"description=Form context and artifacts"`
	Output  *Output       `json:"output,omitempty" jsonschema:"description=Optional auto-fill output response"`
	Timeout time.Duration `json:"timeout,omitempty" jsonschema:"default=300,description=Timeout in seconds"`
}

InputForm represents the complete form structure

type InputRequestSignal

type InputRequestSignal struct {
	ActivityID string        `json:"activity_id"`
	WorkflowID string        `json:"workflow_id"`
	Form       InputForm     `json:"form"`
	Timeout    time.Duration `json:"timeout"`
}

InputRequestSignal represents a signal sent by the activity to request user input

type InputResponseSignal

type InputResponseSignal struct {
	ActivityID   string       `json:"activity_id"`
	ResponseID   string       `json:"response_id"`
	FormResponse FormResponse `json:"form_response"`
	UserID       string       `json:"user_id"`
	RespondedAt  time.Time    `json:"responded_at"`
}

InputResponseSignal represents a signal sent when user submits form

type InputTimeoutSignal

type InputTimeoutSignal struct {
	ActivityID string    `json:"activity_id"`
	ResponseID string    `json:"response_id"`
	TimedOutAt time.Time `json:"timed_out_at"`
}

InputTimeoutSignal represents a signal sent when input request times out

type InputWorkflowParams

type InputWorkflowParams struct {
	ID         string        `json:"id"`
	Form       InputForm     `json:"form"`
	Timeout    time.Duration `json:"timeout"`
	BoxID      string        `json:"box_id"`
	ActivityID string        `json:"activity_id"`
}

InputWorkflowParams represents parameters for the input collection workflow

type InputWorkflowResult

type InputWorkflowResult struct {
	FormResponse map[string]interface{} `json:"form_response"`
	UserID       string                 `json:"user_id"`
	Metadata     map[string]interface{} `json:"metadata"`
}

InputWorkflowResult represents the result of the input collection workflow

type LinearScale

type LinearScale struct {
	Min      int    `json:"min" validate:"required,gte=0,lte=10" jsonschema:"required,minimum=0,maximum=10,description=Minimum scale value"`
	Max      int    `json:"max" validate:"required,gte=1,lte=10" jsonschema:"required,minimum=1,maximum=10,description=Maximum scale value"`
	MinLabel string `json:"min_label,omitempty" jsonschema:"description=Label for minimum value"`
	MaxLabel string `json:"max_label,omitempty" jsonschema:"description=Label for maximum value"`
}

LinearScale represents configuration for linear scale fields

type Option

type Option struct {
	Value string `json:"value" validate:"required" jsonschema:"required,description=Option value"`
	Label string `json:"label,omitempty" jsonschema:"description=Optional display label"`
}

Option represents a choice option for fields like multiple choice, dropdown, etc.

type Output

type Output struct {
	Response interface{}            `json:"response,omitempty" jsonschema:"description=User response for single question"`
	Fields   map[string]interface{} `json:"fields,omitempty" jsonschema:"description=User responses for multi-field form"`
	UserID   string                 `json:"user_id,omitempty" jsonschema:"description=ID of user who responded"`
	Metadata map[string]interface{} `json:"metadata,omitempty" jsonschema:"description=Additional metadata"`
}

Output represents the output from the input activity

func NormalizeOutput added in v0.0.11

func NormalizeOutput(form Config, out Output) (Output, error)

NormalizeOutput stabilizes successful input outputs against the rendered form schema. Required fields without submitted values or explicit defaults fail instead of receiving invented values.

type PendingInput

type PendingInput = openapi.PendingInput

PendingInput represents a pending input request (OpenAPI-generated type).

type Runtime

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

func NewRuntime

func NewRuntime(ctl workflowctl.WorkflowControl, sse ops.SSEManager) (*Runtime, error)

func NewRuntimeFromDeps

func NewRuntimeFromDeps(deps ops.ServiceDependencies2) (*Runtime, error)

func (*Runtime) Cancel

func (r *Runtime) Cancel(ctx context.Context, projectID string, jobID string, reason string) error

func (*Runtime) GetDetails

func (r *Runtime) GetDetails(ctx context.Context, projectID string, jobID string) (*UserInputDetails, error)

func (*Runtime) ListPendingInputs

func (r *Runtime) ListPendingInputs(ctx context.Context, projectID string) ([]PendingInput, error)

func (*Runtime) SSEManager

func (r *Runtime) SSEManager() ops.SSEManager

func (*Runtime) SubmitResponse

func (r *Runtime) SubmitResponse(ctx context.Context, projectID string, jobID string, output FormResponse) error

type SSEEvent

type SSEEvent = recipeops.SSEEvent

SSEEvent is a local alias for the core ops SSEEvent used by tests.

type SimpleSSEManager

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

SimpleSSEManager is a basic implementation of SSEManager

func NewSimpleSSEManager

func NewSimpleSSEManager() *SimpleSSEManager

NewSimpleSSEManager creates a new SSE manager

func (*SimpleSSEManager) Broadcast

func (m *SimpleSSEManager) Broadcast(event ops.SSEEvent)

Broadcast sends an event to all connected clients

func (*SimpleSSEManager) ClearBuffer

func (m *SimpleSSEManager) ClearBuffer()

ClearBuffer clears the event buffer

func (*SimpleSSEManager) GetClients

func (m *SimpleSSEManager) GetClients() int

GetClients returns the number of connected clients

func (*SimpleSSEManager) Subscribe

func (m *SimpleSSEManager) Subscribe(clientID string) <-chan ops.SSEEvent

Subscribe adds a client and returns their event channel

func (*SimpleSSEManager) Unsubscribe

func (m *SimpleSSEManager) Unsubscribe(clientID string)

Unsubscribe removes a client

type UserInputDetails

type UserInputDetails = openapi.UserInputDetails

UserInputDetails describes a pending input request in a transport-agnostic shape.

type UserResponseSignal

type UserResponseSignal struct {
	Fields      map[string]interface{} `json:"fields"`
	UserID      string                 `json:"user_id"`
	RespondedAt time.Time              `json:"responded_at"`
	Metadata    map[string]interface{} `json:"metadata"`
}

UserResponseSignal represents the signal sent when a user responds

type ValidationError added in v0.0.6

type ValidationError struct {
	Field    string
	Message  string
	Required bool
}

ValidationError reports input-op invariants that cannot be expressed safely with field tags.

func (ValidationError) Error added in v0.0.6

func (e ValidationError) Error() string

func (ValidationError) RequiredValidationError added in v0.0.6

func (e ValidationError) RequiredValidationError() bool

Directories

Path Synopsis
Package openapi provides primitives to interact with the openapi HTTP API.
Package openapi provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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