Documentation
¶
Index ¶
- Constants
- Variables
- func GetAlternateOp() ops.RegisterableOp
- func GetAutoFillOp() ops.RegisterableOp
- func GetOp() ops.RegisterableOp
- func NormalizeOutputMap(opInput map[string]interface{}, opOutput map[string]interface{}) (map[string]interface{}, error)
- type APIFieldType
- type APIFormField
- type APIOption
- type Actor
- type Artifact
- type Config
- type FallbackAnswers
- type FieldType
- type FieldValidation
- type FormContext
- type FormField
- type FormResponse
- type FormSubmission
- type GlobPattern
- type Input
- type InputCancelSignal
- type InputForm
- type InputRequestSignal
- type InputResponseSignal
- type InputTimeoutSignal
- type InputWorkflowParams
- type InputWorkflowResult
- type LinearScale
- type Option
- type Output
- type PendingInput
- type Receipt
- type Runtime
- func (r *Runtime) Cancel(ctx context.Context, projectID string, jobID string, reason string) error
- func (r *Runtime) GetDetails(ctx context.Context, projectID string, jobID string) (*UserInputDetails, error)
- func (r *Runtime) GetForm(ctx context.Context, projectID, jobID string) (InputForm, error)
- func (r *Runtime) ListPendingInputs(ctx context.Context, projectID string) ([]PendingInput, error)
- func (r *Runtime) SSEManager() ops.SSEManager
- func (r *Runtime) SubmitFormResponse(ctx context.Context, tenantID, jobID string, submission FormSubmission, ...) (Output, error)
- func (r *Runtime) SubmitResponse(ctx context.Context, projectID string, jobID string, output FormResponse) error
- func (r *Runtime) SubmitStructuredResponse(ctx context.Context, projectID, jobID string, submission StructuredSubmission, ...) (Output, error)
- type SSEEvent
- type SimpleSSEManager
- type StructuredSubmission
- type UnansweredPolicy
- type UserInputDetails
- type UserResponseSignal
- type ValidationError
Constants ¶
const ( APIFieldTypeCheckboxes = openapi.FieldTypeCheckboxes APIFieldTypeLinearScale = openapi.FieldTypeLinearScale APIFieldTypeBoolean = openapi.FieldTypeBoolean )
Variables ¶
var ErrInputNotPending = errors.New("input is not pending for job")
Functions ¶
func GetAlternateOp ¶ added in v0.0.56
func GetAlternateOp() ops.RegisterableOp
GetAlternateOp registers the internal worker implementing pending input collection.
func GetAutoFillOp ¶
func GetAutoFillOp() ops.RegisterableOp
GetAutoFillOp registers the op that echoes a pre-filled input response.
func GetOp ¶
func GetOp() ops.RegisterableOp
Types ¶
type APIFieldType ¶
APIFieldType is the generated transport enum for form fields.
type APIFormField ¶
APIFormField is the generated transport shape used by user-input clients.
type Actor ¶ added in v0.0.56
Actor is supplied by the embedding application, not taken from response data. The application is responsible for authenticating this identity.
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 {
Kind string `json:"kind,omitempty" jsonschema:"enum=review,description=Optional review marker"`
Documents map[string]any `json:"documents,omitempty"`
// Structured mode. Schemas and request are frozen in the generate_form outcome.
Request any `json:"request,omitempty"`
RequestSchema map[string]any `json:"request_schema,omitempty"`
ResponseSchema map[string]any `json:"response_schema,omitempty"`
Presentation map[string]any `json:"presentation,omitempty"`
// Single question format
Question string `json:"question,omitempty" 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) MarshalJSON ¶ added in v0.0.56
func (Config) ValidateOpInput ¶ added in v0.0.6
type FallbackAnswers ¶ added in v0.0.56
type FallbackAnswers struct {
Response any `json:"response,omitempty"`
Fields map[string]any `json:"fields,omitempty"`
ArtifactRefs map[string]artifacts.Ref `json:"artifact_refs,omitempty"`
}
FallbackAnswers is frozen in the prepared form, together with FallbackAt.
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 FormSubmission ¶ added in v0.0.56
type FormSubmission struct {
RequestID string `json:"request_id"`
SubmissionID string `json:"submission_id"`
Response any `json:"response,omitempty"`
Fields map[string]any `json:"fields,omitempty"`
ArtifactRefs map[string]artifacts.Ref `json:"artifact_refs,omitempty"`
}
FormSubmission answers a review using ordinary form fields and attachments. File-upload fields may contain stored refs or jobdb.Artifact values. Additional documents may be supplied as named, already-stored ArtifactRefs.
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 {
IfUnanswered *UnansweredPolicy `json:"if_unanswered,omitempty"`
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
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 {
FallbackAt string `json:"fallback_at,omitempty"`
Fallback *FallbackAnswers `json:"fallback,omitempty"`
Kind string `json:"kind,omitempty"`
Documents map[string]recipeartifacts.Ref `json:"documents,omitempty"`
RequestID string `json:"request_id,omitempty"`
Request any `json:"request,omitempty"`
RequestSchema map[string]any `json:"request_schema,omitempty"`
ResponseSchema map[string]any `json:"response_schema"`
Presentation map[string]any `json:"presentation,omitempty"`
// 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
func (InputForm) MarshalJSON ¶ added in v0.0.56
Preserve an explicitly empty schema (accept any JSON) across task persistence.
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 {
ArtifactRefs map[string]recipeartifacts.Ref `json:"artifact_refs"`
Receipt *Receipt `json:"receipt,omitempty"`
Response interface{} `json:"response" jsonschema:"description=User response for an ordinary or structured input"`
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
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) GetDetails ¶
func (*Runtime) GetForm ¶ added in v0.0.56
GetForm returns the frozen form independently of any presentation transport.
func (*Runtime) ListPendingInputs ¶
func (*Runtime) SSEManager ¶
func (r *Runtime) SSEManager() ops.SSEManager
func (*Runtime) SubmitFormResponse ¶ added in v0.0.56
func (r *Runtime) SubmitFormResponse(ctx context.Context, tenantID, jobID string, submission FormSubmission, actor Actor) (Output, error)
SubmitFormResponse validates and completes the exact pending review. The embedding application supplies the authenticated actor separately.
func (*Runtime) SubmitResponse ¶
func (*Runtime) SubmitStructuredResponse ¶ added in v0.0.56
func (r *Runtime) SubmitStructuredResponse(ctx context.Context, projectID, jobID string, submission StructuredSubmission, actor Actor) (Output, error)
SubmitStructuredResponse validates against the recorded request before finishing the exact waiting task. Successful return is the same output recorded for the op. Recovery of ambiguous completion failures remains JobDB's responsibility.
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 StructuredSubmission ¶ added in v0.0.56
type StructuredSubmission struct {
RequestID string `json:"request_id"`
SubmissionID string `json:"submission_id"`
Response any `json:"response"`
ArtifactRefs map[string]recipeartifacts.Ref `json:"artifact_refs,omitempty"`
}
StructuredSubmission accepts ordinary JSON values and stored artifact refs. Go callers can also place jobdb.Artifact values in Response: these are attached to the outcome and replaced by stored refs before schema validation. Their contents never become inline JSON. ArtifactRefs provides explicit named bindings.
type UnansweredPolicy ¶ added in v0.0.56
type UnansweredPolicy struct {
After string `json:"after"`
Response any `json:"response,omitempty"`
Fields map[string]any `json:"fields,omitempty"`
ArtifactRefs map[string]artifacts.Ref `json:"artifact_refs,omitempty"`
}
UnansweredPolicy supplies ordinary answers if a worker acquires the alternate after the delay. It does not impose a deadline on human responses.
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
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
Source Files
¶
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. |