diff --git a/docs/mermaid/img/gemini_cli_request_detailed.png b/docs/mermaid/img/gemini_cli_request_detailed.png new file mode 100644 index 0000000000..380f766def Binary files /dev/null and b/docs/mermaid/img/gemini_cli_request_detailed.png differ diff --git a/docs/mermaid/src/gemini_cli_request_detailed.mmd b/docs/mermaid/src/gemini_cli_request_detailed.mmd new file mode 100644 index 0000000000..043303b0f6 --- /dev/null +++ b/docs/mermaid/src/gemini_cli_request_detailed.mmd @@ -0,0 +1,57 @@ +sequenceDiagram + accTitle: Detailed Gemini CLI Request Flow + accDescr: Exhaustive sequential flow from user input to Ink rendering, including prompt construction, tool scheduling, and user confirmation loops. + + participant U as User + participant Ink as Ink UI (AppContainer) + participant AS as AgentSession (Core) + participant PP as PromptProvider + participant GC as GeminiClient + participant Sch as Scheduler + participant TR as ToolRegistry + participant Bus as MessageBus / Confirmation + participant TE as ToolExecutor + + U->>Ink: Type Command / Text + Ink->>AS: sendStream(payload) + + rect rgb(240, 240, 255) + Note over AS,PP: Turn Loop (_runLoop) + AS->>PP: getCoreSystemPrompt() + PP->>PP: Resolve Config & Approval Mode + PP->>PP: Gather Agent/Skill Metadata + PP->>PP: Render Template (snippets.ts) + PP-->>AS: Full System Prompt + + AS->>GC: sendMessageStream(Prompt + History) + GC-->>AS: Stream [ContentChunk | ToolCallRequest] + end + + loop For each ToolCallRequest + AS->>Sch: schedule(ToolCallRequests) + Sch->>TR: getTool(name) + TR-->>Sch: Tool Definition + + Sch->>Sch: checkPolicy() & evaluateHooks() + + alt Policy requires Confirmation + Sch->>Bus: publish(TOOL_CONFIRMATION_REQUEST) + Bus->>Ink: Event: Confirmation Required + Ink-->>U: Render [Approve/Deny] Prompt + U->>Ink: Click "Approve" + Ink->>Bus: publish(TOOL_CONFIRMATION_RESPONSE) + Bus-->>Sch: Confirmed + end + + Sch->>TE: execute(invocation) + TE->>TE: Run Shell / Read FS / Web Fetch + TE-->>Sch: ToolOutput + Sch-->>AS: [CompletedToolCall] + + Note over AS: Feedback Turn + AS->>GC: send(ToolOutput) + GC-->>AS: Stream [Final Response] + end + + AS-->>Ink: Stream [AgentEvent] + Ink-->>U: Re-render UI (Ink Components) diff --git a/gemini_cli_request.png b/gemini_cli_request.png index 45084830b5..380f766def 100644 Binary files a/gemini_cli_request.png and b/gemini_cli_request.png differ