ops

package
v0.0.72 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InjectDefaults

func InjectDefaults(inputType reflect.Type, inputMap map[string]interface{}) error

InjectDefaults adds default values to the input map for fields that are missing. Defaults are injected as strings and will be resolved by the template system. This function recursively handles nested structs at arbitrary depth.

func InstallInvocation added in v0.0.66

func InstallInvocation(ctx context.Context, inv *ActivityInvocationRequest, req ToolSetupRequest, prepareTools func(context.Context, ToolSetupRequest) ToolSetupResult) error

func MergeStartedJobs added in v0.0.72

MergeStartedJobs retains all children produced by the steps of an op.

func NewTaskExecutionContext added in v0.0.14

func NewTaskExecutionContext(taskCtx jobworkflow.TaskContext) (context.Context, context.CancelFunc)

NewTaskExecutionContext follows JobDB's invocation cancellation directly.

func PrepareInvocation added in v0.0.66

func PrepareInvocation(ctx context.Context, inv *ActivityInvocationRequest, prepareTools func(context.Context, ToolSetupRequest) ToolSetupResult) error

func Register

func Register(r *ActivityRegistry, activity ops.RegisterableOp) error

Register accepts any generic RegisterableOp from the activity module

Types

type ActivityInvocationOutput

type ActivityInvocationOutput struct {
	PreparationMS     int64                           `json:"preparation_ms,omitempty"`
	Configuration     *configuration.Diagnostics      `json:"configuration,omitempty"`
	Extension         *extops.ResolvedOp              `json:"extension,omitempty"`
	SecretSetupMS     int64                           `json:"secret_setup_ms,omitempty"`
	Setup             *toolenv.Diagnostics            `json:"setup,omitempty"`
	WorkspaceScopeID  string                          `json:"workspace_scope_id,omitempty"`
	Execution         *execution.Requirements         `json:"execution,omitempty"`
	GitResult         contextual.GitCommitContext     `json:"git,omitempty"`
	NextTaskAlternate *jobworkflow.TaskAlternateAfter `json:"next_task_alternate,omitempty"`
	NextTask          string                          `json:"nextTaskType,omitempty"`
	OpOutput          map[string]interface{}          `json:"output"`
	ArtifactRefs      map[string]recipeartifacts.Ref  `json:"artifact_refs,omitempty"`
	Jobs              jobcontext.StartedJobsContext   `json:"jobs,omitempty"`
}

ActivityInvocationOutput wraps the raw op output alongside workspace results.

type ActivityInvocationOutputRaw

type ActivityInvocationOutputRaw struct {
	WorkspaceScopeID  string                          `json:"workspace_scope_id,omitempty"`
	Execution         *execution.Requirements         `json:"execution,omitempty"`
	GitResult         contextual.GitCommitContext     `json:"git,omitempty"`
	NextTaskAlternate *jobworkflow.TaskAlternateAfter `json:"next_task_alternate,omitempty"`
	NextTask          string                          `json:"nextTaskType,omitempty"`
	Output            any                             `json:"output"`
	ArtifactRefs      map[string]recipeartifacts.Ref  `json:"artifact_refs,omitempty"`
	Jobs              jobcontext.StartedJobsContext   `json:"jobs,omitempty"`
}

variation of ActivityInvocationOutput that allows arbitrary output types to avoid double serialization

type ActivityInvocationRequest

type ActivityInvocationRequest struct {
	Preparation      PreparationRequest             `json:"preparation,omitzero"`
	SecretSetupMS    int64                          `json:"-"`
	Setup            *ToolSetupResult               `json:"-"`
	WorkspaceManaged bool                           `json:"workspace_managed,omitempty"`
	RestoreArtifact  *jobdb.ArtifactKey             `json:"restore_artifact,omitempty"`
	Input            map[string]interface{}         `json:"input"`
	Const            bool                           `json:"const,omitempty"`
	GitTaskContext   gitstate.GlobalGitTaskContext  `json:"context"`
	ArtifactKeys     []jobdb.ArtifactKey            `json:"artifact_keys,omitempty"`
	Artifacts        map[string]recipeartifacts.Ref `json:"artifacts,omitempty"`
	Deps             ops.OpDependencies             `json:"-"`
}

ActivityInvocationRequest wraps the invocation metadata and original input payload.

func (ActivityInvocationRequest) ExternalOutput added in v0.0.72

ExternalOutput carries unchanged context from an external task's input snapshot.

type ActivityRegisterable

type ActivityRegisterable interface {
	RegisterActivityWithOptions(a interface{}, options activity.RegisterOptions)
}

type ActivityRegistration

type ActivityRegistration struct {
	Activity     ops.RegisterableOp // parent op
	Step         ops.TaskStep
	StepIndex    int
	TaskType     string // opType:stepName
	NextTaskType string
	InputSchema  *jsonschema.Schema
	OutputSchema *jsonschema.Schema
	Metadata     ops.OpMetadata
}

ActivityRegistration holds the activity step and its generated schemas.

type ActivityRegistry

type ActivityRegistry struct {
	SecretSessions *secrets.Sessions
	// contains filtered or unexported fields
}

ActivityRegistry manages all registered activities

func NewActivityRegistry

func NewActivityRegistry() (*ActivityRegistry, error)

NewActivityRegistry creates a new activity registry

func (*ActivityRegistry) Dependencies

func (r *ActivityRegistry) Dependencies() ops.ServiceDependencies2

Dependencies exposes the current dependency container (may be nil).

func (*ActivityRegistry) EnableActivitiesInWorker

func (r *ActivityRegistry) EnableActivitiesInWorker(deps ops.ServiceDependencies2, worker ActivityRegisterable)

func (*ActivityRegistry) Get

func (r *ActivityRegistry) Get(taskType string) (ActivityRegistration, bool)

Get retrieves an activity registration by task type

func (*ActivityRegistry) GetAll

GetAll returns all activity registrations

func (*ActivityRegistry) GetTaskWorkers

func (*ActivityRegistry) List

func (r *ActivityRegistry) List() []string

List returns all registered activity types

func (*ActivityRegistry) Register

func (r *ActivityRegistry) Register(activity ops.RegisterableOp) error

func (*ActivityRegistry) RegisterFunc

func (r *ActivityRegistry) RegisterFunc(name string, fn func(context.Context, map[string]interface{}) (map[string]interface{}, error)) error

func (*ActivityRegistry) SetDependencies

func (r *ActivityRegistry) SetDependencies(deps ops.ServiceDependencies2)

SetDependencies makes a dependency container available for invocations produced by this registry.

func (*ActivityRegistry) UpdateRegistration

func (r *ActivityRegistry) UpdateRegistration(activityType string, registration ActivityRegistration)

UpdateRegistration updates an existing activity registration This is used by the schema manager to update schemas after generation

type ConsumeArtifactInput

type ConsumeArtifactInput struct {
	Artifact jobdb.ArtifactKey `json:"artifact" validate:"required"`
}

type ConsumeArtifactOutput

type ConsumeArtifactOutput struct {
	Name string `json:"name"`
}

type DefaultSchemaGenerator

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

DefaultSchemaGenerator uses invopop/jsonschema for schema generation

func NewDefaultSchemaGenerator

func NewDefaultSchemaGenerator() *DefaultSchemaGenerator

NewDefaultSchemaGenerator creates a new schema generator

func (*DefaultSchemaGenerator) GenerateSchema

func (g *DefaultSchemaGenerator) GenerateSchema(typ reflect.Type) (*jsonschema.Schema, error)

GenerateSchema creates a JSON schema from a Go type

func (*DefaultSchemaGenerator) ValidateStructTags

func (g *DefaultSchemaGenerator) ValidateStructTags(typ reflect.Type) error

ValidateStructTags ensures all fields have explicit json tags

type EmitArtifactOutput

type EmitArtifactOutput struct {
	Name string `json:"name"`
}

type ExtensionResolutionRequest added in v0.0.64

type ExtensionResolutionRequest struct {
	TemplateContext json.RawMessage       `json:"template_context,omitempty"`
	RawInputs       map[string]any        `json:"raw_inputs,omitempty"`
	Selector        string                `json:"selector"`
	Options         extops.ResolveOptions `json:"options"`
}

type GenericActivityFunc

type GenericActivityFunc func(context.Context, any) (any, error)

type GenericInput

type GenericInput struct {
	Message  string                 `json:"message,omitempty"`
	Command  string                 `json:"command,omitempty"`
	Text     string                 `json:"text,omitempty"`
	Name     string                 `json:"name,omitempty"`
	Run      string                 `json:"run,omitempty"`
	Duration string                 `json:"duration,omitempty"`
	Data     interface{}            `json:"data,omitempty"`
	Items    []interface{}          `json:"items,omitempty"`
	Error    bool                   `json:"error,omitempty"`
	Extra    map[string]interface{} `json:"-" mapstructure:",remain"`
}

Test activity input/output types

type GenericOutput

type GenericOutput struct {
	// String outputs
	Result    interface{} `json:"result,omitempty"`
	Output    string      `json:"output,omitempty"`
	Status    string      `json:"status,omitempty"`
	Stdout    string      `json:"stdout,omitempty"`
	Report    string      `json:"report,omitempty"`
	Response  string      `json:"response,omitempty"`
	Body      string      `json:"body,omitempty"`
	Slept     string      `json:"slept,omitempty"`
	Action    string      `json:"action,omitempty"`
	Handler   string      `json:"handler,omitempty"`
	Processor string      `json:"processor,omitempty"`
	Recipe    string      `json:"recipe,omitempty"`

	// Boolean outputs
	Logged bool `json:"logged,omitempty"`
	Valid  bool `json:"valid,omitempty"`

	// Numeric outputs
	Count      int     `json:"count,omitempty"`
	Confidence float64 `json:"confidence,omitempty"`

	// Complex outputs
	Model interface{}   `json:"model,omitempty"`
	Data  interface{}   `json:"data,omitempty"`
	Items []interface{} `json:"items,omitempty"`
}

type NextTaskOverrideInput

type NextTaskOverrideInput struct {
	Message string `json:"message"`
}

type NextTaskOverrideOutput

type NextTaskOverrideOutput struct {
	Message string `json:"message"`
	Step    string `json:"step"`
}

type PreparationRequest added in v0.0.66

type PreparationRequest struct {
	Extension *ExtensionResolutionRequest `json:"extension,omitempty"`
	Scopes    []toolenv.Scope             `json:"scopes,omitempty"`
}

PreparationRequest contains identities, never resolved configuration or credentials. Preparation runs only inside a live task, under the same timeout as execution.

func (PreparationRequest) IsZero added in v0.0.70

func (p PreparationRequest) IsZero() bool

IsZero makes nil and empty scope lists serialize identically when no extension needs preparation. omitempty alone does not omit a value-typed struct.

type SchemaGenerator

type SchemaGenerator interface {
	GenerateSchema(typ reflect.Type) (*jsonschema.Schema, error)
	ValidateStructTags(typ reflect.Type) error
}

SchemaGenerator validates struct tags and generates JSON schemas This is internal to recipe-worker

type ToolSetupRequest added in v0.0.64

type ToolSetupRequest struct {
	Scopes       []toolenv.Scope    `json:"scopes,omitempty"`
	Extension    *extops.ResolvedOp `json:"extension,omitempty"`
	ResolutionMS int64              `json:"resolution_ms,omitempty"`
}

func ResolveInvocation added in v0.0.66

func ResolveInvocation(ctx context.Context, inv *ActivityInvocationRequest) (ToolSetupRequest, error)

ResolveInvocation loads a manifest and its defaults only for a live task.

type ToolSetupResult added in v0.0.64

type ToolSetupResult struct {
	Duration    time.Duration        `json:"duration_ns"`
	Environment *toolenv.Environment `json:"environment,omitempty"`
	Extension   *extops.ResolvedOp   `json:"extension,omitempty"`
	Diagnostics toolenv.Diagnostics  `json:"diagnostics"`
}

func PrepareTools added in v0.0.64

func PrepareTools(ctx context.Context, req ToolSetupRequest) ToolSetupResult

PrepareTools is shared by task workers and native recipe-test passthrough. Callers supply the consuming task context, including its execution timeout.

Jump to

Keyboard shortcuts

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