The puller's end of a run carries the run's program's last line of standard output as `output` up to StepEndedInlineMost, else keeps it with KeepOutput and names the object in `output-object`; a program that exits other than 0 ends failed. OutputTool serves the seat's verb `output` from the kept object, as the whole file the tool runner sends in chunks; OutputsStore names the store. Builds: design 47 G A-254, A-257, §602 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
43 lines
1.5 KiB
Go
43 lines
1.5 KiB
Go
package steprun
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/buscalls"
|
|
)
|
|
|
|
// OutputsStore is the local name of the object store a build seat's holder keeps a run's answer in when it is over what
|
|
// step-ended carries inline (design 47 G A-254), as the holder's manifest `requires` asks for it with the template objects.
|
|
const OutputsStore = "outputs"
|
|
|
|
// OutputObjects is the object store of OutputsStore as a holder uses it (mesh-sdk busstate.ObjectsOf(OutputsStore)).
|
|
type OutputObjects interface {
|
|
Put(name string, data []byte, description string) (buscalls.ObjectInfo, error)
|
|
Get(name string) (buscalls.ObjectData, error)
|
|
}
|
|
|
|
// KeepOutputIn is a holder's Puller.KeepOutput over its store of outputs.
|
|
func KeepOutputIn(o OutputObjects) func(object string, body []byte) error {
|
|
return func(object string, body []byte) error {
|
|
if o == nil {
|
|
return fmt.Errorf("this module keeps no %s store", OutputsStore)
|
|
}
|
|
_, err := o.Put(object, body, "a run's answer, named by its step-ended")
|
|
return err
|
|
}
|
|
}
|
|
|
|
// ReadOutputFrom is a holder's read of a kept answer for OutputTool over its store of outputs.
|
|
func ReadOutputFrom(o OutputObjects) func(object string) ([]byte, error) {
|
|
return func(object string) ([]byte, error) {
|
|
if o == nil {
|
|
return nil, fmt.Errorf("this module keeps no %s store", OutputsStore)
|
|
}
|
|
got, err := o.Get(object)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("the answer %s in the %s store: %w", object, OutputsStore, err)
|
|
}
|
|
return got.Data, nil
|
|
}
|
|
}
|