Documentation
¶
Overview ¶
Package aiapproval contains the ai-approval node: a human-in-the-loop pause. Wired into a flow (typically inside a tool flow ahead of ai-tool-return), it emits an approval request — question + approvalId — on output 2 and waits for a reply message carrying the same approvalId on its input. The pending record lives in the host's context store, so a restart re-driving the hop sees the same approvalId and either keeps waiting or resumes immediately when the decision already landed.
Index ¶
Constants ¶
const DecisionKey = "aiApproval"
DecisionKey is the message-metadata key the resumed message carries: {approvalId, approved, comment}.
const ReplyKey = "aiApprovalReply"
ReplyKey is the message-metadata key marking an approval reply: a map with "approvalId" (required), "approved" (bool, default true) and an optional "comment".
const Type = "ai-approval"
Type is the registered node type id.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApprovalNode ¶
ApprovalNode is the ai-approval executor.
func NewApprovalNode ¶
func NewApprovalNode(node nodestore.NodeInterface, config *Config, host nodebase.NodeHost) *ApprovalNode
NewApprovalNode creates a new ai-approval node.
func (*ApprovalNode) Execute ¶
func (n *ApprovalNode) Execute(ctx context.Context, input nodestore.MessageInterface) (nodestore.MessageInterface, error)
Execute routes the message: a reply (metadata aiApprovalReply) resolves a pending approval and dies here; anything else is a request — the node emits the approval request on output 2, blocks for the decision and returns the resumed message on output 1.
func (*ApprovalNode) SelectPorts ¶
func (n *ApprovalNode) SelectPorts(input, output nodestore.MessageInterface) []string
SelectPorts kills the reply message after it resolved a pending approval; request-resume messages go to output 1.
type Config ¶
type Config struct {
// Question is the mustache template rendered against the
// incoming message — the question asked of the approver. Empty
// stringifies the payload.
Question string `json:"question"`
// TimeoutSeconds bounds the wait; <= 0 waits until the run
// context ends.
TimeoutSeconds float64 `json:"timeoutSeconds"`
}
Config holds the ai-approval configuration.