Documentation
¶
Overview ¶
Package prompt is the dashboard's request→response widget: a person fills a form, submits, sees a working state, and the answer returns to the SAME widget. It is the human-initiated mirror of `ask` (which is system asks human); here a human asks the flow and waits for it to answer.
The round trip is a loop the author wires: the widget emits the submission on Out, the flow processes it, and the result is wired back into the widget's In port. A request id rides the whole way so a returning answer is matched to the submission that asked for it — a late answer to a superseded question is ignored rather than shown against the wrong prompt.
The three states a person sees, all in one tile:
- idle: the form and a Submit button (plus the previous answer, if any)
- working: the form hidden, a "working…" line — the feedback whose absence made a bare signal widget feel dead
- answered: the answer rendered as markdown, the form ready to ask again
Index ¶
- Constants
- type Component
- func (c *Component) GetInfo() module.ComponentInfo
- func (c *Component) Handle(ctx context.Context, _ module.Handler, port string, msg any) module.Result
- func (c *Component) Instance() module.Component
- func (c *Component) OnControl(ctx context.Context, msg any) error
- func (c *Component) OnReconcile(ctx context.Context, _ v1alpha1.TinyNode) error
- func (c *Component) OnSettings(_ context.Context, msg any) error
- func (c *Component) Ports() []module.Port
- type In
- type Out
- type Settings
Constants ¶
const ( ComponentName = "prompt" OutPort = "out" InPort = "in" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
func (*Component) GetInfo ¶
func (c *Component) GetInfo() module.ComponentInfo
func (*Component) Handle ¶
func (c *Component) Handle(ctx context.Context, _ module.Handler, port string, msg any) module.Result
Handle receives the answer coming back on In. It also handles the Out/In ports the runtime dispatches here; the submission itself arrives via OnControl (the widget), not Handle.
func (*Component) OnControl ¶
OnControl receives a submission from the widget: the filled form with the submit button true. It emits the values on Out and flips the widget to working.
func (*Component) OnReconcile ¶
OnReconcile rehydrates the widget after a restart: re-publish whatever the persisted session says, so a page reload shows the working state or the last answer rather than a blank form.
type In ¶
type In struct {
RequestID string `json:"requestId" title:"Request ID" description:"The id from Out, unchanged."`
Answer string `json:"answer" title:"Answer" description:"Text to show in the widget. Markdown is rendered."`
Context any `json:"context,omitempty" configurable:"true" title:"Context"`
}
In is the answer coming back: the request id it answers and the text to show. Anything not matching the outstanding request is ignored.
type Out ¶
type Out struct {
RequestID string `json:"requestId" title:"Request ID" description:"Carry this back unchanged on the answer so the widget matches it."`
Values json.RawMessage `json:"values" title:"Values" description:"The submitted form."`
Context any `json:"context,omitempty" configurable:"true" title:"Context"`
}
Out is what a submission emits: the form values, the request id to carry back, and a passthrough context.