PlaygroundController class

Controller managing the state of the AI Agent Playground, chat messages, active tool loop execution, and server manager.

Inheritance
Available extensions

Constructors

PlaygroundController({LlmConfig? initialLlmConfig, List<LlmConfig>? initialLlmConfigs, List<McpServerConfig>? initialServers, List<McpLocalTool>? customLocalTools, McpPlaygroundStorageDelegate? storageDelegate, bool enableLogging = false, bool progressiveMcpDiscovery = false, String toolDeliveryStrategy = 'auto', bool injectToolCallingRules = true, String toolFilteringLlmSource = 'llm1', List<SystemPromptTemplate>? systemPromptTemplates, bool showSystemPromptTemplates = true})
Creates a new PlaygroundController instance.

Properties

activeLlmConfig → LlmConfig
no setter
activeModelPrice → ModelPriceInfo?
no setter
activeSkill → SkillDef?
no setter
activeSkillNames → Set<String>
no setter
chatBackgroundDecoration ↔ Decoration?
Optional decoration (e.g. background image, gradient, or color) for the chat/conversation view.
getter/setter pair
chatMode ↔ bool
getter/setter pair
codingSubMode ↔ String
Active working mode (/code, /plan, /ask, /rag).
getter/setter pair
currentInputPrompt ↔ String
getter/setter pair
customLlmConfig ↔ LlmConfig?
getter/setter pair
dynamicSkills → List<SkillDefinition>
no setter
emptyChatBuilder ↔ Widget Function(BuildContext context)?
Optional custom builder for the empty chat state. If provided, this overrides the default welcome/empty state widget.
getter/setter pair
enabledToolNames → Set<String>
no setter
enableEpisodicMemory ↔ bool
getter/setter pair
enableLogging → bool
final
enableSubAgents ↔ bool
getter/setter pair
episodicMemoryStore → EpisodicMemoryStore
no setter
errorMessage → String?
no setter
evalController → EvalController
no setter
externalTools → List<MCPTool>
no setter
hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
Whether any listeners are currently registered.
no setterinherited
imageGenConfig → ImageGenConfig
Active configuration for GenerateImageTool (preset or custom model/endpoint/API key).
no setter
injectToolCallingRules → bool
no setter
isGenerating → bool
no setter
isInspectorVisible ↔ bool
Whether the Agent Inspector pane/dialog is visible.
getter/setter pair
isLoading → bool
no setter
isLoadingPrice → bool
no setter
llmConfig → LlmConfig
no setter
llmConfigs → List<LlmConfig>
no setter
loadedWorkflowId → String?
no setter
localTools → List<McpLocalTool>
no setter
maxToolCalls ↔ int
getter/setter pair
maxToolIterations ↔ int
getter/setter pair
maxTurns ↔ int
getter/setter pair
mcpClients → List<MCPClientDef>
no setter
mcpManager → MultiMCPManager
Direct access to the internal MultiMCPManager.
no setter
memoryArchive → List<EpisodicMemoryEntry>
no setter
messageContentBuilder ↔ Widget? Function(BuildContext context, ChatMessage message)?
Optional builder to customize rendering of chat bubble message contents dynamically.
getter/setter pair
messages → List<ChatMessage>
no setter
onSessionRotate ↔ VoidCallback?
Optional callback invoked when max conversation turns are reached for session rotation.
getter/setter pair
pendingInputPrompt → String?
no setter
pendingParts → List<ChatContentPart>
no setter
pendingToolApproval → PendingToolApproval?
Active tool call paused and waiting for human approval.
no setter
permissions ↔ ToolPermissionSettings
Tool permission settings controlling auto-approval per risk category.
getter/setter pair
progressiveMcpDiscovery ↔ bool
Whether to use on-demand progressive tool discovery (McpListToolsTool & McpCallToolTool) instead of sending all MCP tool schemas in the initial prompt context.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
savedSetups → List<SavedPlaygroundSetup>
no setter
selectedLlmId → String
no setter
servers → List<McpServerConfig>
no setter
showEmptyChatState ↔ bool
Whether to display the default welcome/empty state widget when there are no messages. Defaults to true. Set to false to show a clean background (e.g. background image without text).
getter/setter pair
showSystemPromptTemplates ↔ bool
getter/setter pair
skills → List<SkillDef>
no setter
skillsRootPath → String?
The root directory where skill ZIPs are stored (desktop/mobile only).
no setter
skillStorage → SkillStorageAdapter
The SkillStorageAdapter used for saving/loading skill ZIPs.
no setter
stopAfterToolCall ↔ bool
getter/setter pair
storage → McpPlaygroundStorageDelegate
no setter
subAgentList → List<SubAgentExecution>
no setter
subAgents → Map<String, SubAgentExecution>
no setter
systemPrompt ↔ String
getter/setter pair
systemPromptTemplates ↔ List<SystemPromptTemplate>?
getter/setter pair
toolDeliveryStrategy → String
no setter
toolFilteringLlmSource → String
no setter
turnLimit ↔ int
getter/setter pair
workflows → List<PlaygroundWorkflow>
no setter
workspaceDirectory ↔ String
Active workspace root directory.
getter/setter pair

Methods

activateSkills(List<String> names) → void
addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
addLocalTools(Iterable<McpLocalTool> tools) → void
Dynamically registers multiple local tools at runtime.
addMemoryEntry(EpisodicMemoryEntry entry) → void
addMessage(ChatMessage message) → void
Adds a message to the conversation history and notifies listeners.
addPendingPart(ChatContentPart part) → void
addServer(McpServerConfig server, {bool autoSelectTools = true}) → Future<void>
cancelGeneration() → void
Requests cancellation of the currently executing prompt/sub-prompt chain. Safe to call from any thread.
checkPlanModeToolRestriction(String toolName, Map<String, dynamic> arguments) → MCPToolResult?
Guards against modifying production source code in /plan mode. Permits modifying planning and task files (*.md, tasks.md, implementation_plan.md).
clearChat() → void
clearMemoryArchive() → void
clearPendingParts() → void
cloneProfile(String id, {String? newName}) → Future<LlmConfig>
Clones a profile and appends it to the profiles list.
connectServer(String id) → Future<void>
consumePendingInputPrompt() → String?
Consumes and clears the pending input prompt.
deactivateSkills(List<String> names) → void
deleteProfile(String id) → Future<void>
Deletes a profile by ID.
deleteSetup(String id) → Future<void>
deleteSkill(String id) → Future<void>
deleteWorkflow(String id) → Future<void>
dispose() → void
Discards any resources used by the object.
override
fetchActiveModelPrice() → Future<void>
Queries the live token price for the currently active model configuration.
initializeAllUndiscoveredServers() → Future<void>
loadMessages(List<ChatMessage> messages, {bool clearExisting = true}) → void
Loads external or restored messages into the conversation history.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
openInspector(BuildContext context) → Future<void>

Available on PlaygroundController, provided by the McpPlaygroundDialogExtensions extension

Opens the agent inspector dialog.
openSettings(BuildContext context, {int initialTab = 0, McpSettingsDialogBuilder? customBuilder}) → Future<void>

Available on PlaygroundController, provided by the McpPlaygroundDialogExtensions extension

Opens the settings dialog or sheet.
registerDynamicSkill(SkillDefinition skill) → void
registerDynamicSkills(List<SkillDefinition> skills) → void
registerLocalTool(McpLocalTool tool) → void
Dynamically registers an additional local tool at runtime.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
removePendingPart(int index) → void
removeServer(String id) → Future<void>
respondToToolApproval(ToolApprovalDecision decision) → void
Submits the user's decision on a pending tool approval request.
saveProfile(LlmConfig profile) → Future<void>
Saves or creates a named LLM profile.
saveSetup(SavedPlaygroundSetup setup) → Future<void>
saveSkill(SkillDef skill) → Future<void>
saveWorkflow(PlaygroundWorkflow workflow) → Future<void>
selectLlm(String id) → Future<void>
Selects an active LLM profile by ID and persists selection.
sendMessage(String text, {List<MessageAttachment>? attachments}) → Future<void>
setActiveSkill(SkillDef? skill) → void
setChatBackgroundDecoration(Decoration? decoration) → void
Updates the chat background decoration and notifies listeners.
setChatBackgroundImage(ImageProvider<Object> image, {BoxFit fit = BoxFit.cover, Alignment alignment = Alignment.center, ColorFilter? colorFilter, double opacity = 1.0, bool showEmptyText = true}) → void
Convenience helper to set a chat background image with optional fitting, opacity, and text suppression.
setEmptyChatBuilder(Widget builder(BuildContext context)?) → void
Sets a custom builder for the empty chat state and notifies listeners.
setInjectToolCallingRules(bool value) → Future<void>
Toggles whether tool calling instructions are appended to system prompts.
setInputPrompt(String prompt) → void
Sets a prompt to be populated into the chat input bar and notifies listeners.
setLoadedWorkflowId(String? id) → void
setShowEmptyChatState(bool show) → void
Sets whether the empty chat state text/icon should be displayed and notifies listeners.
setSkillStorageAdapter(SkillStorageAdapter adapter) → void
Allows injecting a custom SkillStorageAdapter (e.g., DB-backed).
setToolDeliveryStrategy(String strategy) → Future<void>
Updates global tool delivery strategy ('auto', 'progressive', 'prefilter', 'direct').
setToolFilteringLlmSource(String source) → Future<void>
Updates the secondary model used for tool prefiltering.
stopGeneration() → void
Alias for cancelGeneration.
submitPrompt(String text) → void
Sends a message and triggers the agentic tool call loop. Submits a user prompt, executing turns and tools.
syncMcpServers() → Future<void>
toggleDynamicSkill(String name) → void
toggleInspector() → void
Toggles visibility of the Agent Inspector pane.
toggleServer(String id, bool enabled) → Future<void>
toggleToolEnabled(String toolName, bool enabled) → void
toggleToolsEnabled(Iterable<String> toolNames, bool enabled) → void
toString() → String
A string representation of this object.
inherited
updateEnabledTools(Set<String> toolNames) → void
updateImageGenConfig(ImageGenConfig config) → Future<void>
Updates and persists the GenerateImageTool configuration.
updateLlmConfig(LlmConfig config) → Future<void>
updateLocalTools(List<McpLocalTool> tools) → void
Updates or replaces the local tools catalog and preserves enabled tools.
updateServer(McpServerConfig server) → Future<void>

Operators

operator ==(Object other) → bool
The equality operator.
inherited