# iamsonal/aiagentstudio architecture

> Architecture diagram of the GitHub repository iamsonal/aiagentstudio, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/iamsonal/aiagentstudio
- Repository: https://github.com/iamsonal/aiagentstudio

## Overview

Pluto is a Salesforce-native AI-agent framework. Users interact through chat or supported messaging/API channels; ingress is normalized as needed, then an agent runtime gathers context and memory, invokes an LLM and configured actions, records execution state, and returns a response. The README also identifies direct and conversational runtimes, sequential pipelines, approvals, provider extensibility, security, and auditability. UI-to-service relationships are supported by sampled LWC excerpts; most Apex runtime connections are documented at capability level, so unsampled implementation links are not asserted.

Main entry points: [`force-app/main/default/classes/OrchestrationService.cls`](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/OrchestrationService.cls) (Agent Orchestration), [`force-app/main/default/lwc/aiAssistantChat/aiAssistantChat.js`](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/lwc/aiAssistantChat/aiAssistantChat.js) (Chat Component), [`force-app/main/default/classes/ChatConversationalRuntimeService.cls`](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/ChatConversationalRuntimeService.cls) (Conversational Runtime), [`force-app/main/default/classes/InteractionSessionService.cls`](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/InteractionSessionService.cls) (Interaction Sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Interaction UI"]
  node_chat["Chat Component<br/>[aiAssistantChat.js]"]
  node_session_ui["Chat Session Manager"]
  node_formatter["Message Formatter"]
  node_events["Event Subscriptions"]
  node_emp["EMP API Client<br/>[universalEmpApi.js]"]
  node_voice["Speech Input"]
  node_speech_service["Speech Recognition"]
  node_markdown["Markdown Viewer<br/>[markdownViewer.js]"]
end

subgraph group_ingress["Ingress and Sessions"]
  node_ingress["Normalized Ingress"]
  node_pipeline_ingress["Ingress Event Service"]
  node_sessions["Interaction Sessions"]
  node_messages["Interaction Messages"]
end

subgraph group_runtime["Agent Runtime"]
  node_conversational["Conversational Runtime"]
  node_direct["Direct Runtime"]
  node_orchestration["Agent Orchestration"]
  node_context["Context Resolution"]
  node_memory["Conversation Memory"]
  node_llm["LLM Interaction"]
  node_provider["OpenAI Adapter"]
  node_execution[("Execution Records")]
end

subgraph group_capabilities["Tools and Governance"]
  node_action["Standard Actions"]
  node_capability["Capability Execution"]
  node_pipeline["Pipeline Composition"]
  node_hitl["Human Approval"]
  node_security["PII Masking"]
end

node_user(("User"))
node_salesforce[("Salesforce Data")]
node_provider_service(("LLM Provider"))
node_channels(("Messaging Channels"))

node_user -->|"uses"| node_chat
node_chat -->|"delegates"| node_session_ui
node_session_ui -->|"formats"| node_formatter
node_chat -.->|"subscribes"| node_events
node_events -->|"uses"| node_emp
node_voice -->|"captures speech"| node_speech_service
node_user -.->|"speaks"| node_voice
node_user -->|"sends requests"| node_channels
node_channels -->|"normalizes"| node_ingress
node_chat -->|"sends message"| node_conversational
node_ingress -.->|"stages events"| node_pipeline_ingress
node_pipeline_ingress -->|"hands off"| node_sessions
node_sessions -->|"stores conversation"| node_messages
node_sessions -.->|"starts execution"| node_conversational
node_conversational -.->|"orchestrates"| node_orchestration
node_direct -.->|"orchestrates"| node_orchestration
node_orchestration -->|"gathers context"| node_context
node_orchestration -->|"uses history"| node_memory
node_orchestration -->|"analyzes request"| node_llm
node_llm -.->|"dispatches request"| node_provider
node_provider -.->|"calls model"| node_provider_service
node_orchestration -->|"executes tools"| node_capability
node_capability -.->|"dispatches actions"| node_action
node_action -->|"reads and writes"| node_salesforce
node_orchestration -->|"runs workflows"| node_pipeline
node_orchestration -->|"requests approval"| node_hitl
node_orchestration -.->|"masks sensitive data"| node_security
node_conversational -->|"tracks execution"| node_execution
node_llm -.->|"records interaction"| node_messages
node_conversational -->|"delivers response"| node_chat
node_markdown -.->|"renders content"| node_chat

click node_chat "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/lwc/aiAssistantChat/aiAssistantChat.js"
click node_session_ui "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/lwc/aiAssistantChat/services/chatSessionManager.js"
click node_formatter "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/lwc/aiAssistantChat/utils/messageFormatter.js"
click node_events "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/lwc/aiAssistantChat/services/eventSubscriptionManager.js"
click node_emp "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/lwc/universalEmpApi/universalEmpApi.js"
click node_voice "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/lwc/speechToTextInput/speechToTextInput.js"
click node_speech_service "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/lwc/speechToTextInput/services/speechToTextService.js"
click node_markdown "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/lwc/markdownViewer/markdownViewer.js"
click node_ingress "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/IngressProcessingService.cls"
click node_pipeline_ingress "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/IngressEventService.cls"
click node_sessions "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/InteractionSessionService.cls"
click node_messages "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/InteractionMessageService.cls"
click node_conversational "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/ChatConversationalRuntimeService.cls"
click node_direct "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/DirectRuntimeService.cls"
click node_orchestration "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/OrchestrationService.cls"
click node_context "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/ContextResolverService.cls"
click node_memory "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/BufferWindowMemoryManager.cls"
click node_llm "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/LLMInteractionService.cls"
click node_provider "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/OpenAIProviderAdapter.cls"
click node_action "https://github.com/iamsonal/aiagentstudio/tree/main/force-app/main/default/classes/actions"
click node_capability "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/CapabilityExecutionService.cls"
click node_pipeline "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/PipelineCompositionService.cls"
click node_hitl "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/HITLGatewayService.cls"
click node_security "https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/PIIMaskingService.cls"
click node_execution "https://github.com/iamsonal/aiagentstudio/tree/main/force-app/main/default/objects/AgentExecution__c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_chat,node_session_ui,node_formatter,node_events,node_emp,node_voice,node_speech_service,node_markdown,node_user toneBlue
class node_ingress,node_pipeline_ingress,node_sessions,node_messages,node_salesforce toneAmber
class node_conversational,node_direct,node_orchestration,node_context,node_memory,node_llm,node_provider,node_execution toneMint
class node_action,node_capability,node_pipeline,node_hitl,node_security toneRose
class node_provider_service,node_channels toneIndigo
```

## Components

### Interaction UI

- [Chat Component](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/lwc/aiAssistantChat/aiAssistantChat.js): `force-app/main/default/lwc/aiAssistantChat/aiAssistantChat.js`
- [Chat Session Manager](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/lwc/aiAssistantChat/services/chatSessionManager.js): `force-app/main/default/lwc/aiAssistantChat/services/chatSessionManager.js`
- [Message Formatter](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/lwc/aiAssistantChat/utils/messageFormatter.js): `force-app/main/default/lwc/aiAssistantChat/utils/messageFormatter.js`
- [Event Subscriptions](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/lwc/aiAssistantChat/services/eventSubscriptionManager.js): `force-app/main/default/lwc/aiAssistantChat/services/eventSubscriptionManager.js`
- [EMP API Client](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/lwc/universalEmpApi/universalEmpApi.js): `force-app/main/default/lwc/universalEmpApi/universalEmpApi.js`
- [Speech Input](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/lwc/speechToTextInput/speechToTextInput.js): `force-app/main/default/lwc/speechToTextInput/speechToTextInput.js`
- [Speech Recognition](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/lwc/speechToTextInput/services/speechToTextService.js): `force-app/main/default/lwc/speechToTextInput/services/speechToTextService.js`
- [Markdown Viewer](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/lwc/markdownViewer/markdownViewer.js): `force-app/main/default/lwc/markdownViewer/markdownViewer.js`

### Ingress and Sessions

- [Normalized Ingress](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/IngressProcessingService.cls): `force-app/main/default/classes/IngressProcessingService.cls`
- [Ingress Event Service](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/IngressEventService.cls): `force-app/main/default/classes/IngressEventService.cls`
- [Interaction Sessions](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/InteractionSessionService.cls): `force-app/main/default/classes/InteractionSessionService.cls`
- [Interaction Messages](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/InteractionMessageService.cls): `force-app/main/default/classes/InteractionMessageService.cls`

### Agent Runtime

- [Conversational Runtime](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/ChatConversationalRuntimeService.cls): `force-app/main/default/classes/ChatConversationalRuntimeService.cls`
- [Direct Runtime](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/DirectRuntimeService.cls): `force-app/main/default/classes/DirectRuntimeService.cls`
- [Agent Orchestration](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/OrchestrationService.cls): `force-app/main/default/classes/OrchestrationService.cls`
- [Context Resolution](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/ContextResolverService.cls): `force-app/main/default/classes/ContextResolverService.cls`
- [Conversation Memory](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/BufferWindowMemoryManager.cls): `force-app/main/default/classes/BufferWindowMemoryManager.cls`
- [LLM Interaction](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/LLMInteractionService.cls): `force-app/main/default/classes/LLMInteractionService.cls`
- [OpenAI Adapter](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/OpenAIProviderAdapter.cls): `force-app/main/default/classes/OpenAIProviderAdapter.cls`
- [Execution Records](https://github.com/iamsonal/aiagentstudio/tree/main/force-app/main/default/objects/AgentExecution__c): `force-app/main/default/objects/AgentExecution__c`

### Tools and Governance

- [Standard Actions](https://github.com/iamsonal/aiagentstudio/tree/main/force-app/main/default/classes/actions): `force-app/main/default/classes/actions`
- [Capability Execution](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/CapabilityExecutionService.cls): `force-app/main/default/classes/CapabilityExecutionService.cls`
- [Pipeline Composition](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/PipelineCompositionService.cls): `force-app/main/default/classes/PipelineCompositionService.cls`
- [Human Approval](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/HITLGatewayService.cls): `force-app/main/default/classes/HITLGatewayService.cls`
- [PII Masking](https://github.com/iamsonal/aiagentstudio/blob/main/force-app/main/default/classes/PIIMaskingService.cls): `force-app/main/default/classes/PIIMaskingService.cls`

### Other components

- **User**
- **Salesforce Data**
- **LLM Provider**
- **Messaging Channels**

## Connections

- User → Chat Component: uses (evidence: `README.md`)
- Chat Component → Chat Session Manager: delegates (evidence: `force-app/main/default/lwc/aiAssistantChat/aiAssistantChat.js`)
- Chat Session Manager → Message Formatter: formats (evidence: `force-app/main/default/lwc/aiAssistantChat/services/chatSessionManager.js`)
- Chat Component → Event Subscriptions: subscribes (evidence: `force-app/main/default/lwc/aiAssistantChat/aiAssistantChat.js`)
- Event Subscriptions → EMP API Client: uses (evidence: `force-app/main/default/lwc/aiAssistantChat/services/eventSubscriptionManager.js`)
- Speech Input → Speech Recognition: captures speech (evidence: `force-app/main/default/lwc/speechToTextInput/speechToTextInput.js`)
- User → Speech Input: speaks
- User → Messaging Channels: sends requests (evidence: `README.md`)
- Messaging Channels → Normalized Ingress: normalizes (evidence: `README.md`)
- Chat Component → Conversational Runtime: sends message (evidence: `README.md`)
- Normalized Ingress → Ingress Event Service: stages events
- Ingress Event Service → Interaction Sessions: hands off (evidence: `README.md`)
- Interaction Sessions → Interaction Messages: stores conversation (evidence: `README.md`)
- Interaction Sessions → Conversational Runtime: starts execution
- Conversational Runtime → Agent Orchestration: orchestrates
- Direct Runtime → Agent Orchestration: orchestrates
- Agent Orchestration → Context Resolution: gathers context (evidence: `README.md`)
- Agent Orchestration → Conversation Memory: uses history (evidence: `README.md`)
- Agent Orchestration → LLM Interaction: analyzes request (evidence: `README.md`)
- LLM Interaction → OpenAI Adapter: dispatches request
- OpenAI Adapter → LLM Provider: calls model
- Agent Orchestration → Capability Execution: executes tools (evidence: `README.md`)
- Capability Execution → Standard Actions: dispatches actions
- Standard Actions → Salesforce Data: reads and writes (evidence: `README.md`)
- Agent Orchestration → Pipeline Composition: runs workflows (evidence: `README.md`)
- Agent Orchestration → Human Approval: requests approval (evidence: `README.md`)
- Agent Orchestration → PII Masking: masks sensitive data
- Conversational Runtime → Execution Records: tracks execution (evidence: `README.md`)
- LLM Interaction → Interaction Messages: records interaction
- Conversational Runtime → Chat Component: delivers response (evidence: `README.md`)
- Markdown Viewer → Chat Component: renders content
