Documentation
¶
Overview ¶
Package chat is the flow's human touchpoint: one conversation surface that replaces the form-era pair of `prompt` (human asks flow) and `ask` (flow asks human). The widget renders a message thread, not a form:
- a human types in the composer → a message bubble, and the flow receives it on the `message` port with a request id
- the flow speaks via `say` → a markdown bubble; when its request id matches an outstanding human message, that message stops "working"
- the flow asks via `ask` → a question card inline in the thread, with the form's buttons/fields; the human's submission emits on `answer`
- a question nobody answers in time expires onto `error` and leaves a note in the thread
This restores the conversation contract that fire-and-forget dropped — correlation, working state, completion, expiry — explicitly, on top of the async transport. Nothing blocks: continuity lives in this node's persisted state, and every hop is its own message.
The thread is a DISPLAY buffer (capped at historyLimit), not conversation memory — flows that need memory keep it in a store component.
Index ¶
- Constants
- type Answer
- type AskRequest
- type ClearRequest
- 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 Context
- type ErrorMessage
- type Message
- type Say
- type Settings
Constants ¶
const ( ComponentName = "chat" SayPort = "say" AskPort = "ask" ClearPort = "clear" MessagePort = "message" AnswerPort = "answer" ErrorPort = "error" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Answer ¶
type Answer struct {
QuestionID string `json:"questionId" title:"Question ID"`
Values map[string]interface{} `json:"values" title:"Values" description:"What the human submitted, keyed by the form's field names."`
Context Context `json:"context,omitempty" title:"Context" description:"The ask request payload, unchanged."`
}
Answer is the human's reply to an ask question.
type AskRequest ¶
type AskRequest struct {
Context Context `` /* 160-byte string literal not displayed */
Form string `` /* 212-byte string literal not displayed */
}
AskRequest is flow → human structured question.
type ClearRequest ¶ added in v0.9.20
type ClearRequest struct {
Context Context `` /* 296-byte string literal not displayed */
}
ClearRequest starts the conversation over: the arrival is the whole instruction, so the payload carries nothing but passthrough context.
type Component ¶
Component is the conversation. Thread and queue live in the node's State (TinyNode status metadata), so they survive pod restarts and are visible to every replica.
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 Say, Ask and Clear. NOT leader-gated: flow traffic is routed to whichever replica the runtime picks, and State converges through the shared backend. (Leader-gating an answer path silently dropped every answer once — see prompt's history. OnControl and OnReconcile DO gate.)
func (*Component) OnControl ¶
OnControl receives the widget's submission: {_kind: "message", text} from the composer, or {_kind: "answer", _qid, ...values} from a question card.
func (*Component) OnReconcile ¶
OnReconcile rehydrates the widget once per pod lifetime and is the idle expiry tick. Republish only on actual change — never re-render a thread a human is mid-interaction with.
type Context ¶
type Context any
Context is the passthrough payload, unchanged through the human's decision.
type ErrorMessage ¶
type ErrorMessage struct {
Context Context `json:"context,omitempty" title:"Context" description:"The ask request payload of the expired question, unchanged."`
Error string `json:"error" title:"Error"`
}
ErrorMessage reports a question nobody answered in time.
type Message ¶
type Message struct {
RequestID string `json:"requestId" title:"Request ID" description:"Carry this back on Say so the thread marks the message answered."`
Text string `json:"text" title:"Text"`
Context Context `json:"context,omitempty" title:"Context"`
}
Message is a human's free composer input.
type Say ¶
type Say struct {
RequestID string `` /* 221-byte string literal not displayed */
Role string `` /* 151-byte string literal not displayed */
Text string `json:"text" title:"Text" description:"Markdown is rendered."`
Context Context `json:"context,omitempty" configurable:"true" title:"Context"`
}
Say is flow → human content.
type Settings ¶
type Settings struct {
Form string `` /* 192-byte string literal not displayed */
TimeoutSeconds int `` /* 253-byte string literal not displayed */
EnableErrorPort bool `` /* 238-byte string literal not displayed */
HistoryLimit int `` /* 171-byte string literal not displayed */
Placeholder string `json:"placeholder,omitempty" title:"Composer Placeholder" description:"Hint text in the input box, e.g. 'Ask the agent…'."`
HideComposer bool `` /* 256-byte string literal not displayed */
}