Where to Find the Definition of Agents in Palmier Pro: Complete File Guide
The definition of agents in Palmier Pro is located in the Sources/PalmierPro/Agent directory, with core orchestration logic in AgentService.swift, client protocols in AgentClientTypes.swift, and SwiftUI components in the Panel subdirectory.
The Palmier Pro repository implements AI agent functionality through a modular Swift architecture centered on chat session management. Understanding the definition of agents in Palmier Pro requires examining three distinct layers: the service orchestration layer, the network client abstraction layer, and the user interface layer.
Core Agent Service and Domain Model
AgentService.swift Implementation
The primary definition of agents lives in Sources/PalmierPro/Agent/AgentService.swift. This file contains the AgentService class, which serves as the main orchestrator for AI chat sessions. According to the Palmier Pro source code, this class manages API keys, model selection, streaming state, and provides essential methods including send(text:mentions:), newChat(), and selectSession(_:).
The service maintains the current draft text and mentions, exposing them through the draft and mentions properties. It also handles tool execution resolution and response streaming from LLM backends.
Message Schema and Data Types
Within the same file, several supporting types define the data exchanged with the LLM:
AgentMessage: ACodablerepresentation of chat messages containing user or assistant content with an array ofAgentContentBlockAgentContentBlock: An enum describing three payload types: plain text, tool-use calls, and tool-result blocksAgentMentionandAgentMentionContext: Helper structs for embedding media, clip, or timeline-range references inside a draft
Tool Definitions and System Prompts
Server-side system prompts and skill definitions used during streaming are located in Sources/PalmierPro/Agent/Tools/AgentInstructions.swift. This file contains the structured instructions sent to the LLM to define available capabilities and response formatting.
Client Protocol and Backend Implementations
AgentClientTypes.swift Protocol Definition
The client abstraction is defined in Sources/PalmierPro/Agent/Clients/AgentClientTypes.swift. This file declares the AgentClient protocol that any backend implementation must adopt to handle authentication, request formatting, and streaming responses.
Concrete Client Implementations
Two implementations satisfy this protocol:
AnthropicClient: Communicates directly with the Anthropic API when users provide personal API keysPalmierClient: Routes calls through the Palmier Pro account service when users are authenticated through the platform
The AgentService determines which client to instantiate based on the user's authentication state and API key availability, checking availableModels to determine which LLM variants are accessible.
User Interface Layer
Panel Views and Input Handling
The UI components that render the agent chat interface reside in Sources/PalmierPro/Agent/Panel/:
AgentPanelView.swift: The main container view hosting the chat interface, bound to anAgentServiceinstanceAgentMessageView.swift: Renders individual messages including text content and tool resultsAgentInputBox.swift: Handles text composition and "@mention" token insertion for referencing media elements
These SwiftUI views bind to the AgentService instance exposed by the editor's view model, creating a reactive interface that updates as streaming responses arrive.
Working with AgentService Code Examples
Creating and configuring an agent instance:
let agent = AgentService()
agent.editor = someEditorViewModel
agent.send(text: "Summarize the selected clip.", mentions: [])
Inspecting draft content and mentions:
print(agent.draft) // Current text the user is typing
print(agent.mentions) // Array of AgentMention objects
Configuring the LLM model:
agent.model = .sonnet46
print(agent.availableModels) // Shows usable models based on auth state
Integrating the UI panel into a SwiftUI view hierarchy:
AgentPanelView(agentService: agent)
Summary
- The definition of agents in Palmier Pro centers on
AgentService.swiftinSources/PalmierPro/Agent/ AgentServicemanages chat sessions, streaming responses, and tool execution lifecycleAgentClientTypes.swiftdefines the protocol for backend clients withAnthropicClientandPalmierClientimplementations- Message schemas (
AgentMessage,AgentContentBlock) codify LLM interactions within the service file - UI components in
Agent/Panel/provide the complete SwiftUI chat interface - The architecture cleanly separates domain logic, network abstraction, and presentation concerns
Frequently Asked Questions
What is the main file that defines the agent service in Palmier Pro?
The main file is Sources/PalmierPro/Agent/AgentService.swift, which contains the AgentService class that orchestrates AI chat sessions, manages streaming responses, and handles tool resolution and session management.
How does Palmier Pro handle different AI backend providers?
Palmier Pro uses the AgentClient protocol defined in Sources/PalmierPro/Agent/Clients/AgentClientTypes.swift to abstract backend implementations. Two concrete classes, AnthropicClient for direct API access and PalmierClient for authenticated service routing, handle the actual network communication.
Where are the agent message types defined in the Palmier Pro source code?
The message types are defined within Sources/PalmierPro/Agent/AgentService.swift. This includes AgentMessage for chat content, AgentContentBlock for payload variants (text, tool-use, tool-result), and AgentMention for media references.
Which files contain the SwiftUI views for the agent chat interface?
The SwiftUI views are located in Sources/PalmierPro/Agent/Panel/, specifically AgentPanelView.swift (main container), AgentMessageView.swift (message rendering), and AgentInputBox.swift (text input with mention support).
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →