Documentation
¶
Overview ¶
Package run implements the agent-factory run command behavior.
Index ¶
- func CountTokenStates(snap *petri.MarkingSnapshot) (wip, completed, failed int)
- func DashboardURL(host string, port int) string
- func FormatDuration(d time.Duration) string
- func LoadWorkFile(path string) (interfaces.WorkRequest, error)
- func PrepareFactoryPromptWorkFile(factoryConfigPath, prompt string) (workFilePath string, err error)
- func Run(ctx context.Context, cfg RunConfig) error
- func SetBuildFactoryService(builder FactoryServiceBuilder)
- type FactoryServiceBuildFunc
- type FactoryServiceBuilder
- type RunConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountTokenStates ¶
func CountTokenStates(snap *petri.MarkingSnapshot) (wip, completed, failed int)
CountTokenStates counts tokens by their state category based on place ID conventions. Place IDs follow the pattern '{work_type_id}:{state_value}'. Terminal states contain "completed", failed states contain "failed".
func DashboardURL ¶
DashboardURL returns the embedded browser dashboard URL for the configured local factory server host and port.
func FormatDuration ¶
FormatDuration formats a duration as "Xm" or "Xh Ym".
func LoadWorkFile ¶
func LoadWorkFile(path string) (interfaces.WorkRequest, error)
LoadWorkFile reads a canonical FACTORY_REQUEST_BATCH from a JSON file.
func PrepareFactoryPromptWorkFile ¶ added in v0.0.5
func PrepareFactoryPromptWorkFile(factoryConfigPath, prompt string) (workFilePath string, err error)
PrepareFactoryPromptWorkFile validates the factory config, builds a canonical FACTORY_REQUEST_BATCH for the prompt, and writes it to a temporary JSON file.
func Run ¶
Run loads a workflow from factory.json and starts the factory via FactoryService. The CLI is a thin wrapper — all orchestration logic (file watcher, dashboard, API server, engine) lives in the service layer.
func SetBuildFactoryService ¶ added in v0.0.5
func SetBuildFactoryService(builder FactoryServiceBuilder)
SetBuildFactoryService registers the factory service builder used by Run. cmd/factory/main should call this before cli.Execute. Tests may assign buildFactoryService directly without calling SetBuildFactoryService.
Types ¶
type FactoryServiceBuildFunc ¶ added in v0.0.5
type FactoryServiceBuildFunc func( context.Context, *service.FactoryServiceConfig, ) (*service.FactoryService, error)
FactoryServiceBuildFunc constructs *service.FactoryService for registration from cmd/ when the builder is defined outside pkg/cli/run.
type FactoryServiceBuilder ¶ added in v0.0.5
type FactoryServiceBuilder func( context.Context, *service.FactoryServiceConfig, ) (factoryServiceRunner, error)
FactoryServiceBuilder constructs the factory service used by Run.
func FactoryServiceBuilderFromService ¶ added in v0.0.5
func FactoryServiceBuilderFromService(build FactoryServiceBuildFunc) FactoryServiceBuilder
FactoryServiceBuilderFromService adapts a concrete service constructor for SetBuildFactoryService when the builder is defined outside pkg/cli/run.
type RunConfig ¶
type RunConfig struct {
Workflow string
Continuously bool
WorkFile string
Dir string
// FactoryConfigPath is the factory.json file path from you run --factory.
// The service uses Dir as the resolved factory root directory.
FactoryConfigPath string
RunnerID string
// ExecutionBaseDir overrides the base directory used to resolve relative
// runtime execution paths. Empty defaults to the caller's current working
// directory for CLI-style runs.
ExecutionBaseDir string
Bootstrap bool
// BindHost is the hostname from --server used in dashboard URLs (for example localhost or 127.0.0.1).
BindHost string
Port int
// AutoPort resolves Port to the next available local TCP port when the
// preferred port is unavailable. Explicit port selections should leave this
// false so operator intent is preserved.
AutoPort bool
RecordPath string
ReplayPath string
// DisableDefaultRecording disables the default live-run replay artifact
// generation for a single invocation.
DisableDefaultRecording bool
// RuntimeLogDir overrides the service-owned structured runtime log root.
// Empty uses the service default under the user's home directory.
RuntimeLogDir string
// RuntimeLogConfig controls service-owned structured runtime log rotation.
RuntimeLogConfig logging.RuntimeLogConfig
// MockWorkersEnabled enables deterministic mock-worker execution. When
// true and MockWorkersConfigPath is empty, the runtime uses the default
// accept behavior for all worker dispatches.
MockWorkersEnabled bool
MockWorkersConfigPath string
Verbose bool
// SuppressDashboardRendering disables the simple stdout dashboard while
// preserving the normal service-layer run path.
SuppressDashboardRendering bool
// OpenDashboard attempts to open the embedded dashboard URL in a browser.
OpenDashboard bool
// StartupOutput receives human-facing startup messages. Nil suppresses
// startup output for programmatic callers and tests.
StartupOutput io.Writer
// Diagnostics receives metadata-only verbose command diagnostics. Nil
// suppresses diagnostics for programmatic callers and tests.
Diagnostics io.Writer
Logger *zap.Logger
}
RunConfig holds parameters for the run command.