Skip to main content

Module user_interaction

Module user_interaction 

Source
Expand description

AskUserQuestion sequential sequencing. Mirrors upstream’s agent-sdk/src/bridge/user_interaction.ts (323 LoC) - focused on the multi-question loop + answer-payload assembly.

The actual loop driver lives in forge_sdk_worker::run_ask_user_question because it needs the worker’s pending map + event_tx + the oneshot machinery. This module owns the pure parsing helpers.

Re-exports§

use serde_json::Map; 🔒
use serde_json::Value; 🔒
use forge_primitives::QuestionAnnotation; 🔒
use forge_primitives::QuestionOption; 🔒
use forge_primitives::QuestionPrompt; 🔒
use forge_primitives::QuestionRequest; 🔒
use forge_primitives::ToolCall; 🔒

Structs§

AskUserQuestionOption
AskUserQuestionPrompt
MonitorInput
Monitor tool’s tool_use.input payload. The renderer consumes description for the chat one-liner + the MONITORS-section header; command is informational; persistent toggles the “(persistent)” suffix on the chat notice; timeout_ms is honoured by the CLI’s task-lifecycle handler.

Constants§

ASK_USER_QUESTION_TOOL_NAME

Functions§

ask_user_question_wire_options 🔒
Mirrors askUserQuestionOptions(prompt) - synthesises wire option_id slugs as question_<index> so a view can map back to the upstream label list when responding.
build_question_request
Mirrors buildQuestionRequest(promptToolCall, prompt, index, total).
build_updated_input
Helper used by the worker’s loop driver: build the final updatedInput payload after every question has been answered. Mirrors the tail of requestAskUserQuestionAnswers upstream.
derive_annotation
Mirrors deriveAnnotation. Joins option previews with a blank line separator when no caller-supplied annotation preview is present.
has_recommended_suffix 🔒
#273: CLI 2.1.156 marks the “best” choice in an AskUserQuestion option list with a literal (Recommended) suffix on the option label (space + paren + capital R). The label itself reaches the UI verbatim; this only reports the marker’s presence. Match is case-sensitive because the CLI emits the canonical form; lower-case recommended from the model’s own prose is just label text.
parse_ask_user_question_prompts
Mirrors upstream’s parseAskUserQuestionPrompts. Walks the raw input.questions JSON array, dropping malformed entries and requiring at least 2 options per question (matches upstream’s validity rule).
parse_monitor_input
Parse a Monitor tool_use’s raw_input into a MonitorInput. Returns None when description or command is missing or non-string - both are required for a meaningful render.