120 lines
3.6 KiB
Go
120 lines
3.6 KiB
Go
// Package scriptorium declares the adapter contract for Scriptorium CLI invocations.
|
|
package scriptorium
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
configkit "go.maximumdirect.net/configkit"
|
|
)
|
|
|
|
const (
|
|
// CommandModeRun is the Scriptorium CLI mode for production generation.
|
|
CommandModeRun = "run"
|
|
// CommandModeRender identifies the prepared request inspection command.
|
|
CommandModeRender = "promptkit show prepared"
|
|
)
|
|
|
|
// Runner is the adapter boundary for Scriptorium artifact invocations.
|
|
type Runner interface {
|
|
RunArtifact(ctx context.Context, req RunArtifactRequest) (ArtifactResult, error)
|
|
RenderArtifact(ctx context.Context, req RenderArtifactRequest) (ArtifactResult, error)
|
|
InspectRequirements(ctx context.Context, req RequirementsRequest) (RequirementsReport, error)
|
|
}
|
|
|
|
// RequestContext holds the effective selections shared by Scriptorium operations.
|
|
type RequestContext struct {
|
|
Binary string
|
|
ConfigPath string
|
|
PromptID string
|
|
ProfileID string
|
|
Vars map[string]string
|
|
Credentials []configkit.Secret
|
|
WorkingDir string
|
|
Timeout time.Duration
|
|
}
|
|
|
|
// RequirementsRequest selects a prompt and variables for read-only discovery.
|
|
type RequirementsRequest = RequestContext
|
|
|
|
type RequirementsReport struct {
|
|
PromptID string `json:"prompt_id"`
|
|
ProfileID string `json:"profile_id"`
|
|
Complete bool `json:"complete"`
|
|
Inputs []RequirementInput `json:"inputs"`
|
|
Variables []RequirementVariable `json:"variables"`
|
|
Issues []RequirementIssue `json:"issues"`
|
|
}
|
|
|
|
type RequirementInput struct {
|
|
Name string `json:"name"`
|
|
Kind string `json:"kind"`
|
|
Declared bool `json:"declared"`
|
|
ContentType *string `json:"content_type"`
|
|
Description *string `json:"description"`
|
|
Explanation string `json:"explanation"`
|
|
}
|
|
|
|
type RequirementVariable struct {
|
|
Name string `json:"name"`
|
|
Kind string `json:"kind"`
|
|
Supplied bool `json:"supplied"`
|
|
Explanation string `json:"explanation"`
|
|
}
|
|
|
|
type RequirementIssue struct {
|
|
Code string `json:"code"`
|
|
InputName string `json:"input_name"`
|
|
VariableName string `json:"variable_name"`
|
|
Description string `json:"description"`
|
|
}
|
|
|
|
// RunArtifactRequest describes a production artifact-generation invocation.
|
|
type RunArtifactRequest struct {
|
|
Binary string
|
|
ConfigPath string
|
|
PromptID string
|
|
ProfileID string
|
|
InputPaths map[string]string
|
|
Vars map[string]string
|
|
OutputPath string
|
|
StdoutLogPath string
|
|
StderrLogPath string
|
|
GeneratedConfigPath string
|
|
Timeout time.Duration
|
|
Credentials []configkit.Secret
|
|
WorkingDir string
|
|
}
|
|
|
|
// RenderArtifactRequest describes a render-debug invocation.
|
|
type RenderArtifactRequest struct {
|
|
Binary string
|
|
ConfigPath string
|
|
PromptID string
|
|
ProfileID string
|
|
InputPaths map[string]string
|
|
Vars map[string]string
|
|
OutputPath string
|
|
StdoutLogPath string
|
|
StderrLogPath string
|
|
GeneratedConfigPath string
|
|
Timeout time.Duration
|
|
Credentials []configkit.Secret
|
|
WorkingDir string
|
|
}
|
|
|
|
// ArtifactResult describes Scriptorium invocation output and provenance.
|
|
type ArtifactResult struct {
|
|
OutputPath string
|
|
StdoutLogPath string
|
|
StderrLogPath string
|
|
GeneratedConfigPath string
|
|
ExitCode int
|
|
Duration time.Duration
|
|
CommandMode string
|
|
PromptID string
|
|
ProfileID string
|
|
ValidationFailed bool
|
|
Metadata map[string]any
|
|
}
|