//! IPC types: tasks, their timeline entries and the events streamed to the UI. use ide_core::IpcPath; use serde::{Deserialize, Serialize}; use specta::Type; use std::collections::BTreeMap; /// Why a task needs the user's attention (native / in-app notify). #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum AgentAttentionReason { Finished, Input, Failed, } #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum AgentStatus { /// Creating the worktree / starting the agent. Starting, Running, /// Waiting for a permission answer. NeedsInput, /// The turn ended; the result can be reviewed or the conversation continued. Ready, Failed, /// The account's usage limit was reached; the conversation can go on once it resets. Limited, Archived, } /// What a task's agent can do beyond a plain conversation, as it reported when its /// session started. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase", default)] pub struct AgentCapabilities { /// Images in messages. pub images: bool, /// The conversation can be copied into a new task (`session/fork`). pub fork: bool, /// Its latest turns can be dropped. pub rollback: bool, /// A message can join the running turn instead of waiting for it. pub steer: bool, /// It reports its background tasks and stops them one by one. pub background_tasks: bool, /// The connected agent can report a breakdown of its context window. pub context_usage: bool, } /// Why `AgentManager` is shutting down its live tasks. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub enum AgentShutdownReason { WindowClose, #[default] Quit, Restart, BackendUpgrade, BackendStop, } /// Why an in-flight turn stopped before completing. #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum InterruptionReason { WindowClose, Quit, Restart, BackendUpgrade, BackendStop, UnexpectedExit, NetworkTimeout, CursorCapacity, } impl From for InterruptionReason { fn from(reason: AgentShutdownReason) -> Self { match reason { AgentShutdownReason::WindowClose => Self::WindowClose, AgentShutdownReason::Quit => Self::Quit, AgentShutdownReason::Restart => Self::Restart, AgentShutdownReason::BackendUpgrade => Self::BackendUpgrade, AgentShutdownReason::BackendStop => Self::BackendStop, } } } /// Recovery metadata recorded when an active turn was interrupted before finishing. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentInterrupted { pub reason: InterruptionReason, pub at_ms: f64, #[serde(default, skip_serializing_if = "is_false")] pub was_waiting_for_input: bool, #[serde(default, skip_serializing_if = "Option::is_none")] pub approval_mode: Option, #[serde(default, skip_serializing_if = "is_false")] pub auto_resume_once: bool, } /// Summary returned when reconciling interrupted tasks for a connected project window. #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentRecoveryReport { /// Unique identifier of this `AgentManager` process incarnation. pub instance_id: String, /// `true` on the first reconciliation of this `AgentManager` incarnation. pub first_reconcile: bool, /// Task IDs automatically resumed during this reconciliation. pub auto_resumed: Vec, /// Task IDs remaining in `Interrupted` (`Ask to resume`). pub interrupted: Vec, } fn is_false(b: &bool) -> bool { !*b } #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum Isolation { /// A new git worktree on its own branch. Worktree, /// The project's own checkout. #[default] Local, } #[derive(Clone, Debug, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentTask { /// Original project folder; absent in tasks saved before per-task roots. #[serde(default)] pub project_root: Option, pub id: String, pub title: String, /// [`AgentProvider::id`]. pub provider: String, /// Model the task runs on (its `model` setting), when known. pub model: Option, pub status: AgentStatus, pub isolation: Isolation, /// Directory the agent works in (the worktree, or the project root). pub cwd: IpcPath, /// Branch of the task's worktree. pub branch: Option, /// Branch (or revision) the worktree was created from. pub base: Option, /// Commit the task's changes are compared against (worktree tasks; local ones use `HEAD`). pub base_commit: Option, /// Why the task failed, when it did. pub error: Option, pub created_ms: f64, pub updated_ms: f64, /// The session's settings (model, mode, thinking effort…) as last reported, with the /// user's choices applied. pub config: Vec, /// Slash commands the agent offers. pub commands: Vec, /// Context window use, when the agent reports it. pub usage: Option, /// Messages waiting for the current turn to end, oldest first. pub queue: Vec, #[serde(default)] pub capabilities: AgentCapabilities, /// When a [`AgentStatus::Limited`] task's limit resets (ms since the epoch), if the agent said. #[serde(default)] pub resets_ms: Option, /// The agent is retrying a failed API request (connection lost, overloaded…); cleared /// by its next output or any status change. #[serde(default)] pub retry: Option, /// What the agent runs in the background (shells, subagents, monitors), oldest first. // Boxed so that `AgentEvent::Task` stays within clippy's `large_enum_variant` bound on Windows. #[serde(default)] pub background: Box>, /// Per-session MCP server enable/disable overrides (`server_name` -> `enabled`), including `"openidea"`. #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] pub mcp_overrides: BTreeMap, /// Per-session skill modes (`skill name` -> mode), on top of the settings' policies. #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] pub skill_overrides: BTreeMap, /// Per-session memory overrides (auto-memory mode and per-entry modes), boxed to keep `AgentEvent::Task` small. #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub memory_overrides: Option>, /// Token counts of the last turn and context compressions, when the agent reports them. // Boxed so that `AgentEvent::Task` stays within clippy's `large_enum_variant` bound on Windows. #[serde(default)] pub stats: Box, /// Set when the task's last active turn was interrupted (window close, restart, crash, or /// expired network retry window) and has not been resumed or dismissed yet. #[serde(default, skip_serializing_if = "Option::is_none")] pub interrupted: Option>, /// Persisted unseen reply / input / failure state across window closes and remote reattaches. #[serde(default, skip_serializing_if = "is_false")] pub unread: bool, /// Per-session recovery / network auto-retry window override in minutes (`0` = Off; `None` = inherit global). #[serde(default, skip_serializing_if = "Option::is_none")] pub recovery_window_mins: Option, /// Provenance metadata when this task was created or continued by an [`crate::automation::AgentAutomation`]. #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub automation: Option>, } #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentSessionStats { /// The last turn's tokens (`session/prompt` result `usage`). #[serde(default)] pub tokens: Option, /// How many times the agent compressed the conversation (Hermes `compressionDepth`). #[serde(default)] pub compressions: u32, } #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentTokens { pub input: u32, pub cached: u32, pub output: u32, } /// A task the agent runs in the background while the conversation goes on. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentBackgroundTask { pub id: String, /// What it is, as the agent names it (`local_bash`, `local_agent`, `monitor`…). pub kind: String, pub description: String, /// When the client first saw it (ms since the epoch). pub started_ms: f64, } /// An API request the agent is about to retry. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentRetry { pub attempt: u32, pub max_retries: Option, /// When the next attempt starts (ms since the epoch). pub retry_at_ms: f64, pub error: Option, /// Set when OpenIDEA holds an active turn in `Waiting for network` until `deadline_ms`. #[serde(default, skip_serializing_if = "Option::is_none")] pub deadline_ms: Option, } /// Token pricing (Credits per 1M tokens) and context window capacity for one tier. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentTokenPricing { pub input: f64, pub output: f64, #[serde(default)] #[specta(optional)] pub cache_read: Option, #[serde(default)] #[specta(optional)] pub cache_write: Option, #[serde(default)] #[specta(optional)] pub context_tokens: Option, } /// Pricing and context-tier metadata attached to a model [`AgentConfigValue`]. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentModelPricing { /// `"low"`, `"medium"`, `"high"`, or `"very_high"`. #[serde(default)] #[specta(optional)] pub cost_tier: Option, /// Request-based billing multiplier (e.g. `1.0`, `0.33`, `3.0`), when applicable. #[serde(default)] #[specta(optional)] pub multiplier: Option, /// Token pricing keyed by context tier (`"default"`, `"long_context"`). #[serde(default)] pub tiers: BTreeMap, } /// One value of a select-type session setting. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentConfigValue { pub value: String, pub name: String, pub description: Option, /// Relative cost category from ACP `_meta` (`copilotPriceCategory`, e.g. `low`, `medium`, `high`, `very_high`). #[serde(default)] #[specta(optional)] pub cost_category: Option, /// Usage multiplier from ACP `_meta` (`copilotUsage`, e.g. `1x`, `0x`, `3x`). #[serde(default)] #[specta(optional)] pub usage_multiplier: Option, /// Detailed per-tier token pricing from `_meta.pricing` when available. #[serde(default)] #[specta(optional)] pub pricing: Option>, } /// How a setting is changed. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum AgentConfigVia { /// `session/set_config_option`. #[default] Option, /// `session/set_mode` (agents that report `modes` instead of a mode config option). Mode, /// `session/set_model` (agents that report `models` instead of a model config option). Model, } /// A session setting: an ACP select config option, or the older `modes` / `models`. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentConfigOption { pub id: String, pub name: String, pub description: Option, /// ACP category: `model`, `mode`, `thought_level`, or agent-specific. pub category: Option, pub current: Option, /// Initial default value reported by the agent, preserved across session updates for Reset. #[serde(default)] #[specta(optional)] pub default_value: Option, pub values: Vec, pub via: AgentConfigVia, } #[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum AgentCommandSource { #[default] Command, Skill, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentCommandChoice { pub name: String, #[serde(default)] pub description: String, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentCommand { /// Without the leading `/`. pub name: String, pub description: String, /// What to type after the command, when it takes input. pub hint: Option, #[serde(default)] pub source: AgentCommandSource, /// Fixed subcommand/argument choices advertised by the agent (e.g. `list`, `info` for `/skills`). #[serde(default)] pub choices: Vec, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentUsage { /// Tokens in the context window. pub used: u32, /// Size of the context window. pub size: u32, /// What the session has cost so far (ACP `usage_update.cost`), when the agent reports it. // Boxed so that `AgentEvent::Task` stays within clippy's `large_enum_variant` bound on Windows. #[serde(default)] pub cost: Option>, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentContextUsage { pub categories: Vec, pub total_tokens: u32, pub max_tokens: u32, pub model: String, pub is_auto_compact_enabled: Option, pub auto_compact_threshold: Option, /// Tokens reserved for model response / output buffer, when the agent reports it. #[serde(default)] pub reserved_tokens: Option, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] pub struct AgentContextCategory { pub name: String, pub tokens: u32, pub kind: Option, /// Visual section group (e.g. `"System"`, `"User Context"`). #[serde(default)] pub group: Option, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentCost { pub amount: f64, /// ISO 4217 code (e.g. `USD`), or `"credits"` for AI-credit billing. pub currency: String, } /// One usage-limit window of an agent's account. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentLimit { /// The window as the agent names it: `five_hour`, `seven_day`, `seven_day_opus`… pub window: String, /// Share of the window used, 0–100. pub used_percent: f64, /// When the window resets (ms since the epoch), if the agent said. pub resets_ms: Option, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentImage { pub mime_type: String, /// Base64, without a `data:` prefix. pub data: String, pub name: Option, /// The `[Image #n]` label in the prompt text for an inline attachment. #[specta(optional)] pub inline_number: Option, } impl AgentImage { /// The type the bytes are in. Agents reject an image whose declared type doesn't match its /// bytes, and a pasted image's declared type can be wrong (a browser's JPEG or WebP copied as /// `image/png`). Falls back to `mime_type` for formats not recognised here. pub fn media_type(&self) -> &str { let head = crate::acp::normalize_base64(&self.data[..self.data.len().min(16)]); match head.as_slice() { [0x89, b'P', b'N', b'G', ..] => "image/png", [0xFF, 0xD8, 0xFF, ..] => "image/jpeg", [b'G', b'I', b'F', b'8', ..] => "image/gif", [b'R', b'I', b'F', b'F', _, _, _, _, b'W', b'E', b'B', b'P', ..] => "image/webp", _ => &self.mime_type, } } } /// A message to the agent: text, plus files to look at and images. #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentPrompt { pub text: String, pub files: Vec, pub images: Vec, } /// Provenance carried with a scheduled turn (`SameTask`, `Send Later`, or `/loop`), including /// while queued behind a busy turn, so trust and approval ceilings are re-checked at dispatch. #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ScheduledTurnMeta { #[serde(default, skip_serializing_if = "Option::is_none")] pub permissions: Option, #[serde(default, skip_serializing_if = "Vec::is_empty")] pub extra_choices: Vec, #[serde(default, skip_serializing_if = "Option::is_none")] pub automation_id: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub session_schedule_id: Option, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentQueued { pub id: String, pub prompt: AgentPrompt, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(skip)] pub scheduled: Option, } /// A setting chosen for a new task, by [`AgentConfigOption::id`]. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentConfigChoice { pub id: String, pub value: String, } #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum AgentToolStatus { Pending, Running, Completed, Failed, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentToolDiff { pub path: IpcPath, pub added: u32, pub removed: u32, } /// What a subagent is doing, as its parent reports it. #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum AgentSubagentStatus { Running, /// One of its requests (a permission) waits for an answer. NeedsInput, Done, Cancelled, Failed, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentPlanItem { pub content: String, /// `pending`, `in_progress` or `completed`. pub status: String, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentPermissionOption { pub id: String, pub name: String, /// `allow_once`, `allow_always`, `reject_once` or `reject_always`. pub kind: String, } /// A question the agent asks with `AskUserQuestion`, answered by picking options or typing. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentQuestion { /// Stable answer identity when the provider supplies question ids. #[serde(default)] pub answer_key: Option, #[serde(default)] pub header: String, pub question: String, #[serde(default)] pub multi_select: bool, pub options: Vec, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentQuestionOption { pub label: String, #[serde(default)] pub description: String, #[serde(default)] pub preview: Option, } /// A form the agent asks the user to fill in (ACP `elicitation/create`, form mode). #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentForm { pub fields: Vec, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentFormField { /// The property name the answer is keyed by. pub name: String, pub title: String, #[serde(default)] pub description: String, #[serde(default)] pub required: bool, pub kind: AgentFormFieldKind, /// The choices of a `choice` or `choices` field. #[serde(default)] pub options: Vec, /// The initial answer: option values, a text, a number, or `true` / `false`. #[serde(default)] pub default: Vec, /// Bounds: the number of a `number` / `integer`, the length of a `text`, the count of `choices`. #[serde(default)] pub min: Option, #[serde(default)] pub max: Option, } #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum AgentFormFieldKind { Text, Number, Integer, Boolean, /// One of `options`. Choice, /// Any of `options`. Choices, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentFormOption { pub value: String, pub label: String, #[serde(default)] pub description: String, } /// One item of a task's conversation. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(tag = "type", rename_all = "camelCase", rename_all_fields = "camelCase")] pub enum AgentEntry { User { text: String, /// Names of the files and images sent with it. attachments: Vec, /// The images sent with it, shown in the conversation. #[serde(default)] images: Vec, /// When it was sent (ms since the epoch); `None` in tasks saved before this was kept. #[serde(default)] sent_ms: Option, /// When the turn it started ended; `None` while it runs or when it was cut off. #[serde(default)] done_ms: Option, /// Sent into a running turn rather than starting one. #[serde(default)] steered: bool, /// Set when this turn was started automatically or via 1-click Resume to recover an interrupted turn. #[serde(default)] recovery: Option, /// One-based automatic retry number for this continuation. #[serde(default)] retry_attempt: Option, }, Agent { text: String, }, /// A question that can be answered while the agent keeps working, or after the turn ends. Question { id: String, title: String, questions: Vec, /// The submitted answers, or `Skipped`; `None` while unanswered. chosen: Option, }, Thought { text: String, /// When the reasoning started (ms since the epoch); `None` in tasks saved before. #[serde(default)] started_ms: Option, }, Tool { id: String, title: String, /// ACP tool kind: `read`, `edit`, `execute`, `search`, `fetch`, `think`… kind: String, status: AgentToolStatus, locations: Vec, /// Images returned by the tool, kept separately from its truncated text. #[serde(default)] images: Vec, /// Text the tool reported (command output…), truncated. output: Option, diffs: Vec, /// When the call started and ended (ms since the epoch); `None` in tasks saved before. #[serde(default)] started_ms: Option, #[serde(default)] ended_ms: Option, /// The command an `execute` call runs, from its structured input; `None` when the agent gave none. #[serde(default)] command: Option, }, Plan { items: Vec, }, /// A subagent the agent started: its own session, whose entries are listed separately. Subagent { /// The subagent's session id. id: String, title: Option, description: Option, status: AgentSubagentStatus, error: Option, /// What it was asked to do, last. prompt: Option, /// Its answer. reply: Option, /// Tool calls it made. tools: u32, /// Title of its latest tool call. activity: Option, started_ms: f64, /// When it last stopped working; `None` while it works. ended_ms: Option, /// Whether it can be stopped on its own. cancellable: bool, }, /// A message between sessions in a subagent's conversation: its task (`incoming`) or its report. Message { incoming: bool, text: String, }, Permission { id: u32, title: String, /// The shell command the request asks to run, from its structured input; `None` for /// any other request, whatever its title says. #[serde(default)] command: Option, options: Vec, /// Set when the request asks `AskUserQuestion`'s questions; answered with a JSON object /// of question to answer instead of an option. #[serde(default)] questions: Vec, /// Set when the agent asks for a form (ACP elicitation); answered with a JSON object of /// field name to its values, `decline`, or nothing to cancel. #[serde(default)] form: Option, /// Name of the chosen option, or `None` while pending. Cancelled requests read "Cancelled". chosen: Option, }, Error { message: String, }, } #[derive(Clone, Debug, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentProvider { pub id: String, pub name: String, /// The command line that starts its ACP server. pub command: String, /// Executable and arguments actually launched, without flattening paths containing spaces. pub program: String, pub args: Vec, /// Settings-managed suffix of `args`; absent for launches that cannot be edited. #[serde(default, skip_serializing_if = "Option::is_none")] pub additional_args: Option>, pub default_program: Option, pub default_args: Vec, pub login_hint: Option, pub command_overridden: bool, pub command_editable: bool, pub command_read_only_reason: Option, /// Whether the command was found (on `PATH`). pub installed: bool, /// Command the project host can run to install this missing built-in CLI. #[serde(default, skip_serializing_if = "Option::is_none")] pub cli_install_command: Option, /// Whether OpenIDEA can run this agent's sign-in flow directly in an embedded terminal. #[serde(default)] pub can_sign_in: bool, /// The built-in command can be owned by a global npm package. #[serde(default)] pub can_check_cli_update: bool, /// The built-in agent this one is an instance of. #[serde(default, skip_serializing_if = "Option::is_none")] pub base: Option, /// A built-in agent, of which another instance can be added. #[serde(default)] pub can_duplicate: bool, /// Environment variables it starts with (from its agent file). pub env: BTreeMap, /// Settings (models, modes…) the agent offered last time it ran; empty before its first session. pub config: Vec, /// Thinking-level options by model value; absent models have not reported their levels. #[serde(default)] pub thought_levels: BTreeMap>, /// Slash commands it offered last time. pub commands: Vec, pub source: AgentSource, } /// Why the executable cannot be changed in built-in agent settings. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum AgentCommandReadOnlyReason { PackageRunner, Registry, CustomAgent, } /// An authenticated `github.com` account stored in GitHub CLI (`gh`). #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct GhAuthAccount { pub login: String, pub active: bool, } /// GitHub Copilot's default sign-in status alongside the accounts available through `gh`. #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct CopilotAuthStatus { pub authenticated: bool, pub login: Option, pub auth_type: Option, pub status_message: Option, pub gh_installed: bool, pub gh_accounts: Vec, } /// Output and completion of an interactive sign-in PTY started by the IDE. #[derive(Clone, Debug, Serialize, Deserialize, Type)] #[serde(tag = "type", rename_all = "camelCase")] pub enum AgentLoginEvent { Output { data: String }, Exited { code: Option }, } /// Where an agent comes from. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(tag = "kind", rename_all = "camelCase")] pub enum AgentSource { Builtin, /// Defined by the user in `/agents/.toml`. Custom, /// Installed from the ACP Registry. Registry { version: String, /// A newer version the registry offers. update: Option, }, } /// What an agent says about itself when it starts (`initialize` only: no session, so no /// MCP servers, hooks or sign-in run). #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentProbe { pub provider: String, /// The agent's own name and version, when it reports them. pub name: Option, pub version: Option, /// How it is driven: `ACP v1`, `ACP v2` or `native`. pub protocol: String, pub capabilities: AgentCapabilities, /// Ways to sign in it offers. pub auth_methods: Vec, /// Why it could not be started. pub error: Option, } #[derive(Clone, Debug, Default, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct NewAgentTask { /// Validated by the host; defaults to the window project root. #[serde(default)] pub project_root: Option, pub prompt: AgentPrompt, pub provider: String, /// Settings for the new session (model, mode…). pub config: Vec, pub isolation: Isolation, /// Branch to start the worktree from; the current branch when `None`. pub base: Option, /// Per-session MCP server enable/disable overrides (`server_name` -> `enabled`). #[serde(default)] pub mcp_overrides: BTreeMap, /// Per-session skill modes (`skill name` -> mode). #[serde(default)] pub skill_overrides: BTreeMap, /// Per-session memory overrides (auto-memory mode and per-entry modes). #[serde(default)] #[specta(optional)] pub memory_overrides: Option, /// Creates the task without sending `prompt` (it only names the task): the composer's /// `!` command runs in it first. #[serde(default)] pub idle: bool, /// A throwaway task (Generate Commit Message): it isn't saved, so it doesn't outlive a /// restart, and the agent keeps no session history of its own for it. #[serde(default)] pub ephemeral: bool, } /// A file the task changed: against [`AgentTask::base_commit`], or against `HEAD` in the /// grouped view. #[derive(Clone, Debug, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentChange { pub path: IpcPath, pub rel_path: String, pub kind: ide_vcs::ChangeKind, pub added: u32, pub removed: u32, /// Path before a rename; the left side of its diff reads this path. pub old_path: Option, /// The repository the file is in, when the task's project holds nested repositories. pub repo: Option, } /// A commit made while the task ran, with the files it changed against its first parent. #[derive(Clone, Debug, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentCommit { pub id: String, pub short_id: String, pub summary: String, pub message: String, pub time_ms: f64, /// First parent, or `None` for a root commit. pub parent: Option, pub files: Vec, } /// Which comparison a rollback of the task's changes uses. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum AgentChangesView { /// Everything since the commit the task started from. #[default] SinceStart, /// The uncommitted files against `HEAD`; commits made since the start stay. Group, /// What the last turn changed, against the checkout as that turn started. LastTurn, } /// A task's uncommitted files and the commits made since it started. #[derive(Clone, Debug, Default, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentChanges { /// Files changed against `HEAD`, less those changed before the task started and untouched since. pub uncommitted: Vec, /// Commits from the task's start (exclusive) to `HEAD` (inclusive), newest first. Empty /// for tasks working in the project's own checkout. pub commits: Vec, } /// Authoritative choices for new tasks, independent of any running session's settings. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentModelCatalog { pub provider: String, pub config: Vec, pub thought_levels: BTreeMap>, pub refreshing: bool, pub refreshed_at_ms: Option, pub retry_at_ms: Option, pub error: Option, } /// Streamed to the window that subscribed (`AgentManager::subscribe_as`). #[derive(Clone, Debug, Serialize, Deserialize, Type)] #[serde(tag = "type", rename_all = "camelCase", rename_all_fields = "camelCase")] pub enum AgentEvent { /// A task was created or its metadata changed. Task { task: Box, }, Removed { id: String, }, /// The task's conversation was cut to its first `length` entries (turns rolled back). Truncated { task: String, length: u32, }, /// Entry `index` of `task` (of its subagent `subagent`) was added or replaced. Entry { task: String, subagent: Option, index: u32, entry: AgentEntry, }, /// Text was appended to entry `index` (an agent message or a thought): it read the first /// `from` UTF-16 units of its text when the previous event for it was sent. Append { task: String, subagent: Option, index: u32, from: u32, text: String, }, /// Text was appended to the output of tool entry `index`: it read the first `from` UTF-16 /// units of its output when the previous event for it was sent. Any other change of the /// tool (status, title, diffs…) arrives as an `Entry`. ToolOutput { task: String, subagent: Option, index: u32, from: u32, text: String, }, /// An agent reported the usage limits of its account (shared by every task of `provider`). Limits { provider: String, limits: Vec, }, /// A model lookup started or completed, including unsuccessful lookups. ModelCatalog { catalog: AgentModelCatalog, }, /// The installed or configured agent providers changed. Providers, /// The task needs attention once (finished turn, explicit input, or failure). Attention { task: String, event_id: String, reason: AgentAttentionReason, }, } pub use ide_core::settings::{AgentMcpServer, McpTransport}; /// Where an MCP server configuration is stored (`settings.toml` vs `.openidea/settings.toml`). #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum McpScope { User, Workspace, } /// A named environment variable or HTTP header for an MCP server. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct McpKeyValue { pub name: String, pub value: String, } /// One configured Model Context Protocol (MCP) server. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct McpServer { pub id: String, pub name: String, pub scope: McpScope, pub transport: McpTransport, pub enabled: bool, pub command: Option, pub args: Vec, pub env: Vec, pub url: Option, pub headers: Vec, /// Agent provider ids this server is enabled for; empty means enabled for all agents. #[serde(default)] pub agents: Vec, /// True when this Workspace server was added outside OpenIDEA and has not been approved yet. #[serde(default)] pub unapproved: bool, /// Parent agent plugin ID when this server is live-projected from an enabled agent plugin bundle. #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub plugin_id: Option, /// Display name of the parent agent plugin. #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub plugin_name: Option, /// Canonical MCP registry server identifier when installed from an MCP registry. #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub registry_name: Option, /// Normalized MCP registry base URL when installed from an MCP registry. #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub registry_url: Option, } /// Payload for creating or updating a user or workspace MCP server. #[derive(Clone, Debug, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct McpServerInput { #[serde(default)] pub id: Option, pub name: String, pub scope: McpScope, pub transport: McpTransport, #[serde(default = "default_true")] pub enabled: bool, #[serde(default)] pub command: Option, #[serde(default)] pub args: Vec, #[serde(default)] pub env: Vec, #[serde(default)] pub url: Option, #[serde(default)] pub headers: Vec, /// Agent provider ids this server is enabled for; empty means enabled for all agents. #[serde(default)] pub agents: Vec, /// Canonical MCP registry server identifier when installed from an MCP registry. #[serde(default)] #[specta(optional)] pub registry_name: Option, /// Normalized MCP registry base URL when installed from an MCP registry. #[serde(default)] #[specta(optional)] pub registry_url: Option, } fn default_true() -> bool { true } pub use ide_core::settings::{ AgentMemoryEntryPolicy, AgentMemoryMode, AgentMemorySettings, AgentPluginEntryPolicy, AgentPluginSettings, AgentProviderMemoryPolicy, AgentSkillMode, AgentSkillPolicy, AutoMemoryMode, }; /// Kind of discovered agent memory entry. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum AgentMemoryKind { /// Always-loaded instruction document (`AGENTS.md`, `CLAUDE.md`, `copilot-instructions.md`, `GEMINI.md`). #[default] Instruction, /// Path-scoped or conditional rule (`.claude/rules/*.md`, `*.instructions.md`, `.cursor/rules/*.mdc`). Rule, /// Agent-authored cross-session memory note (`MEMORY.md`, Claude topic files, Codex summaries, Hermes `USER.md`). AutoNote, } /// Which workspace, user, or CLI store a memory entry was discovered in. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum AgentMemorySource { /// Portable workspace instructions: `AGENTS.md`, `AGENTS.override.md`. #[default] Workspace, /// `CLAUDE.md`, `.claude/CLAUDE.md`, `CLAUDE.local.md`, `.claude/rules/**`. ClaudeWorkspace, /// `~/.claude/CLAUDE.md`, `~/.claude/rules/**`. ClaudeUser, /// `~/.claude/projects//memory/**` (or custom `autoMemoryDirectory`). ClaudeAuto, /// `.github/copilot-instructions.md`, `.github/instructions/**/*.instructions.md`. GithubWorkspace, /// `~/.copilot/copilot-instructions.md`, `~/.copilot/instructions/**/*.instructions.md`. CopilotUser, /// `~/.codex/AGENTS.md`, `~/.codex/AGENTS.override.md`. CodexUser, /// `~/.codex/memories/**` / `~/.codex/memories_v2/**`. CodexAuto, /// `.cursor/rules/**/*.mdc`, `.cursorrules`. CursorWorkspace, /// `GEMINI.md`. GeminiWorkspace, /// `~/.gemini/GEMINI.md`. GeminiUser, /// `/memories/{MEMORY.md,USER.md}`. HermesAuto, } impl AgentMemorySource { /// True when the entry lives inside the current workspace and requires Workspace Trust. pub fn is_workspace(self) -> bool { matches!( self, Self::Workspace | Self::ClaudeWorkspace | Self::GithubWorkspace | Self::CursorWorkspace | Self::GeminiWorkspace ) } /// True when the entry is an agent's learned cross-session auto-memory store. pub fn is_auto(self) -> bool { matches!(self, Self::ClaudeAuto | Self::CodexAuto | Self::HermesAuto) } } /// Which layer decided an [`AgentMemoryState::mode`] or [`AutoMemoryMode`]. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum AgentMemoryOrigin { #[default] None, Session, Workspace, User, /// Locked `Off` because the workspace is untrusted. Trust, } /// One discovered instruction file, rule file, or learned auto-memory note. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentMemoryEntry { /// Stable identifier (`"::"`). pub id: String, pub title: String, pub description: String, pub kind: AgentMemoryKind, pub source: AgentMemorySource, /// Secondary sources whose symlink or `@AGENTS.md` import resolved to this same canonical file. #[serde(default, skip_serializing_if = "Vec::is_empty")] pub also_in: Vec, /// Canonical file path on disk. pub path: IpcPath, /// Normalized path-scoping globs (`paths:` in Claude, `applyTo:` in Copilot, `globs:` in Cursor). #[serde(default, skip_serializing_if = "Vec::is_empty")] pub paths: Vec, /// Optional memory category (`user`, `feedback`, `project`, `reference`, `profile`). #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub category: Option, /// Approximate prompt token cost (~4 chars/token). pub approx_tokens: u32, pub line_count: u32, pub byte_len: u64, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub modified_ms: Option, /// True when OpenIDEA allows deleting or promoting-and-removing this file (auto-memory notes). pub writable: bool, pub valid: bool, #[serde(default, skip_serializing_if = "Vec::is_empty")] pub warnings: Vec, /// Parent agent plugin ID when this rule/instruction is live-projected from an enabled agent plugin bundle. #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub plugin_id: Option, /// Display name of the parent agent plugin. #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub plugin_name: Option, } /// A discovered memory entry paired with its resolved [`AgentMemoryMode`] and origin. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentMemoryState { pub entry: AgentMemoryEntry, pub mode: AgentMemoryMode, /// Optional provider filter from `[agents.memory.entries.]`; empty means all agents. #[serde(default, skip_serializing_if = "Vec::is_empty")] pub agents: Vec, pub origin: AgentMemoryOrigin, } /// Live auto-memory status and capability summary for one agent family. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentAutoMemoryStatus { pub provider: String, pub label: String, pub mode: AutoMemoryMode, pub origin: AgentMemoryOrigin, pub note_count: u32, pub rollout_count: u32, pub approx_tokens: u32, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub storage_path: Option, pub supports_auto_control: bool, pub supports_file_exclusion: bool, pub supports_reset: bool, } /// Full catalog returned to Settings › Agents › Memory and the Composer `MemoryPicker`. #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentMemoryCatalog { pub entries: Vec, pub providers: Vec, pub auto_memory: AutoMemoryMode, pub auto_memory_origin: AgentMemoryOrigin, } /// Per-session memory overrides stored on an [`AgentTask`]. #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(default, rename_all = "camelCase")] pub struct AgentMemoryOverrides { #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub auto_memory: Option, #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] pub entries: BTreeMap, } impl AgentMemoryOverrides { pub fn is_empty(&self) -> bool { self.auto_memory.is_none() && self.entries.is_empty() } } /// Target format when creating a new memory or instruction file from Settings › Agents › Memory. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum AgentMemoryCreateTarget { /// `/AGENTS.md` (or `~/.codex/AGENTS.md` in User scope). #[default] AgentsMd, /// `/.claude/rules/.md` or `~/.claude/rules/.md`. ClaudeRule, /// `/.github/instructions/.instructions.md` or `~/.copilot/instructions/.instructions.md`. CopilotInstruction, /// `/.cursor/rules/.mdc`. CursorRule, } /// Payload for creating a new instruction or rule file. #[derive(Clone, Debug, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct CreateAgentMemoryInput { pub scope: McpScope, pub target: AgentMemoryCreateTarget, #[serde(default)] pub name: String, #[serde(default)] #[specta(optional)] pub description: Option, #[serde(default)] pub paths: Vec, pub content: String, } /// Payload for promoting an auto-memory note into `AGENTS.md`. #[derive(Clone, Debug, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct PromoteAgentMemoryInput { pub source_id: String, #[serde(default)] #[specta(optional)] pub heading: Option, #[serde(default)] pub remove_source: bool, } /// Which CLI's own folders a skill was discovered in (Settings › Agents › Skills groups by it). #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum AgentSkillSource { /// The project's `.agents/skills` and `.openidea/skills`. #[default] Workspace, /// The user's `~/.agents/skills` (what `npx skills add` fills). User, /// Contributed by an enabled OpenIDEA plugin (`[[contributes.skills]]`). Plugin, /// The project's `.claude/skills`. ClaudeWorkspace, /// `~/.claude/skills`. ClaudeUser, /// The project's `.github/skills` (Copilot's repository skills). GithubWorkspace, /// `~/.copilot/skills` and `~/.copilot/installed-plugins/*`. CopilotUser, /// The project's `.codex/skills`. CodexWorkspace, /// `~/.codex/skills`. CodexUser, /// The project's `.cursor/skills`. CursorWorkspace, /// `~/.cursor/skills`. CursorUser, } impl AgentSkillSource { /// Whether skills of this source are only read, never delivered by OpenIDEA: the CLI /// discovers them itself, so "off" holds only where the CLI supports a native disable. pub fn discovered(&self) -> bool { !matches!(self, Self::Workspace | Self::User | Self::Plugin) } } /// One discovered skill: a folder with a `SKILL.md`. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentSkill { /// The frontmatter `name`, else the folder's name. pub name: String, pub description: String, /// Optional `argument-hint` from frontmatter, completed in the `/` menu. #[serde(default, skip_serializing_if = "Option::is_none")] pub hint: Option, /// Canonical folder holding `SKILL.md` (symlinks resolved, so duplicates collapse). pub path: IpcPath, pub source: AgentSkillSource, /// Other skill roots whose symlinked entry resolved to this same canonical `path`. #[serde(default, skip_serializing_if = "Vec::is_empty")] pub also_in: Vec, /// False when frontmatter sets `user-invocable: false` (omitted from `/` completion). #[serde(default = "default_true")] pub user_invocable: bool, /// True when frontmatter sets `disable-model-invocation: true` (defaults to `slashOnly`). #[serde(default)] pub disable_model_invocation: bool, /// True when frontmatter sets `context: fork` (passed through natively to supporting CLIs). #[serde(default)] pub context_fork: bool, /// Optional `paths` / `globs` patterns from frontmatter (passed through natively to supporting CLIs). #[serde(default, skip_serializing_if = "Vec::is_empty")] pub paths: Vec, /// The `SKILL.md` passes validation (`name` matches its folder, `description` present). pub valid: bool, /// What validation found (`name` mismatch, missing or over-long description…). pub warnings: Vec, /// Parent agent plugin ID when this skill comes from an agent plugin bundle. #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub plugin_id: Option, /// Display name of the parent agent plugin. #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub plugin_name: Option, } /// A skill as Settings › Agents › Skills shows it: discovery plus the effective mode and /// which layer decided it. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentSkillState { pub skill: AgentSkill, pub mode: AgentSkillMode, /// What set `mode`: a session override, the workspace, the user's settings, workspace /// trust, or nothing (the default `auto`). pub origin: AgentSkillOrigin, } /// Which layer decided a skill's [`AgentSkillState::mode`]. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum AgentSkillOrigin { #[default] None, Session, Workspace, User, /// An untrusted workspace's skills and policies may only turn skills off. Trust, } /// An external MCP configuration file discovered on disk (user CLI config or workspace file). #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct McpExternalSource { /// Stable source identifier (e.g. `"copilot-cli"`, `"jetbrains-air"`, `"claude-code"`, `"cursor"`, `"workspace-mcp"`, `"vscode-mcp"`). pub id: String, /// Human-readable source label (e.g. `"GitHub Copilot CLI"`). pub label: String, /// Absolute path of the discovered configuration file. pub path: IpcPath, /// Suggested target scope when importing this source into OpenIDEA settings. pub suggested_scope: McpScope, /// Agent provider ID this external CLI reads natively (`Some("copilot")`, `Some("claude")`, `Some("cursor")`, or `None`). pub native_provider: Option, /// Servers found inside this external configuration file (values omitted for safety; imported directly on the host). pub servers: Vec, } /// Summary of one server discovered inside an external MCP configuration file. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct McpDiscoveredServer { pub name: String, pub transport: McpTransport, pub enabled: bool, pub command: Option, pub args: Vec, pub url: Option, /// Environment variable names declared on this server (values stay on the host). pub env_keys: Vec, /// HTTP header names declared on this server (values stay on the host). pub header_keys: Vec, } /// Which workspace, user, or CLI store an agent plugin bundle was discovered in. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum AgentPluginSource { /// `~/.copilot/installed-plugins/{,_direct}/*`. #[default] CopilotUser, /// `~/.claude/plugins/installed_plugins.json` & `~/.claude/plugins/cache/*`. ClaudeUser, /// `~/.codex/plugins/cache/*`. CodexUser, /// `~/.gemini/extensions/*`. GeminiUser, } /// Manifest format(s) recognized inside an agent plugin directory. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum AgentPluginFormat { /// Vendor-neutral Agent Plugins 1.0 / 1.1 (`plugin.json` with `$schema`). #[default] AgentPluginsV1, /// `.openidea/plugin.json`. OpenIdea, /// `.claude-plugin/plugin.json`. Claude, /// `.plugin/plugin.json`, `.github/plugin/plugin.json`, or legacy root `plugin.json`. Copilot, /// `.codex-plugin/plugin.json`. Codex, /// `gemini-extension.json`. GeminiExtension, } /// Which policy layer decided an [`AgentPluginState::enabled`] status. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum AgentPluginOrigin { /// Native harness configuration owns the enabled state. #[default] None, /// Locked `Off` because the workspace is untrusted. Trust, /// Locked `Off` until executable capabilities (stdio MCP / lifecycle hooks) are approved. Consent, } /// Data type of a plugin `userConfig` / `variables` / `settings` option. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub enum AgentPluginConfigFieldKind { #[default] String, Number, Boolean, Secret, } /// One configurable option declared by an agent plugin (`userConfig`, `variables`, or Gemini `settings`). #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentPluginConfigField { pub key: String, pub title: String, #[serde(default)] pub description: String, pub kind: AgentPluginConfigFieldKind, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub default_value: Option, #[serde(default)] pub required: bool, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub env_var: Option, /// Current non-sensitive value (always empty when `kind == Secret`). #[serde(default)] pub value: String, /// True when a secret is stored in OS Keychain for this field. #[serde(default)] pub has_secret: bool, } /// Summary of components and executable capabilities bundled inside an agent plugin. #[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentPluginCapabilities { pub skill_count: u32, #[serde(default, skip_serializing_if = "Vec::is_empty")] pub skill_names: Vec, pub mcp_count: u32, #[serde(default, skip_serializing_if = "Vec::is_empty")] pub mcp_names: Vec, pub rule_count: u32, pub subagent_count: u32, pub command_count: u32, #[serde(default, skip_serializing_if = "Vec::is_empty")] pub hook_files: Vec, #[serde(default, skip_serializing_if = "Vec::is_empty")] pub stdio_commands: Vec, #[serde(default)] pub has_lsp: bool, #[serde(default)] pub has_canvas_or_app: bool, /// Harnesses that have native non-portable components (hooks, subagents, canvases/apps, LSP) in this bundle. #[serde(default, skip_serializing_if = "Vec::is_empty")] pub native_harnesses: Vec, /// Deterministic BLAKE3 hex digest of executable capabilities (`stdio_commands` + `hook_files` contents). #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub capability_hash: Option, #[serde(default)] pub requires_consent: bool, } /// One discovered agent plugin bundle on disk (or built-in). #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentPlugin { pub id: String, pub name: String, pub display_name: String, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub version: Option, pub description: String, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub author: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub homepage: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub repository: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub license: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub marketplace: Option, pub source: AgentPluginSource, /// Scope this bundle is installed in. Native plugin folders and enablement config are /// resolved relative to this scope. pub scope: McpScope, /// Workspace whose native configuration owns this row's enablement (workspace scope only). #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub workspace_root: Option, #[serde(default, skip_serializing_if = "Vec::is_empty")] pub also_in: Vec, pub formats: Vec, pub root_path: IpcPath, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub manifest_path: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub readme_path: Option, pub default_enabled: bool, pub approx_tokens: u32, pub capabilities: AgentPluginCapabilities, #[serde(default, skip_serializing_if = "Vec::is_empty")] pub config_fields: Vec, pub valid: bool, #[serde(default, skip_serializing_if = "Vec::is_empty")] pub warnings: Vec, } /// Resolved agent plugin state paired with its policy origin and consent status. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentPluginState { pub plugin: AgentPlugin, pub enabled: bool, pub origin: AgentPluginOrigin, /// True when executable stdio MCP / hook capabilities require user approval before enabling. pub consent_required: bool, } /// Summary of a configured or repository-discovered plugin marketplace. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentMarketplaceInfo { pub id: String, pub name: String, pub source: String, pub scope: McpScope, /// True when discovered from a harness-native marketplace/configuration file. pub discovered: bool, } /// Full catalog returned to Settings › Agents › Plugins. #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentPluginCatalog { pub plugins: Vec, pub marketplaces: Vec, pub projected_skills: u32, pub projected_mcp_servers: u32, pub projected_rules: u32, } /// One installable plugin entry listed inside a marketplace or repository. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentMarketplaceCandidate { pub name: String, pub display_name: String, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub version: Option, pub description: String, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub author: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub marketplace: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub icon_url: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub icon_dark_url: Option, /// Source spec to pass to preview (`"owner/repo[/subpath][@ref]"` or local directory path). pub source_spec: String, pub subpath: String, #[serde(default, skip_serializing_if = "Vec::is_empty")] pub keywords: Vec, pub already_installed_user: bool, pub already_installed_workspace: bool, } /// Result of browsing a marketplace (`owner/repo`, local marketplace path, or direct plugin repo). #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentMarketplaceBrowseResult { pub source: String, pub marketplace_name: String, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub owner: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub repo: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub git_ref: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub tree_sha: Option, pub candidates: Vec, } /// Whether a previewed plugin can be installed for one harness, and where it is already installed. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentPluginInstallTarget { pub harness: String, pub supported: bool, /// Why the harness cannot install this plugin. #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub reason: Option, /// Whether this harness can enable the plugin for just one workspace. pub workspace_supported: bool, /// This harness already records the plugin for the user / for the current workspace. pub installed_user: bool, pub installed_workspace: bool, /// The harness store already holds this plugin version's folder, so installing replaces it. pub overwrite_required: bool, } /// Security and capability preview of an agent plugin bundle before installation. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentPluginPreview { /// `"github"` or `"local"`. pub source_kind: String, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub owner: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub repo: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub git_ref: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub tree_sha: Option, /// Pinned commit SHA from preview when `source_kind == "github"`. #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub commit_sha: Option, #[serde(default)] pub subpath: String, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub local_path: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub marketplace: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub marketplace_source: Option, pub name: String, pub display_name: String, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub version: Option, pub description: String, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub icon_url: Option, #[serde(default, skip_serializing_if = "Option::is_none")] #[specta(optional)] pub icon_dark_url: Option, pub formats: Vec, pub capabilities: AgentPluginCapabilities, pub files: Vec, pub scan_warnings: Vec, /// Per-harness install eligibility and existing installs for this plugin and marketplace. pub targets: Vec, } /// Request payload to install a previewed agent plugin into a selected harness's native plugin directory. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct InstallAgentPluginRequest { /// `"github"` or `"local"`. pub source_kind: String, #[serde(default)] #[specta(optional)] pub owner: Option, #[serde(default)] #[specta(optional)] pub repo: Option, #[serde(default)] #[specta(optional)] pub git_ref: Option, /// Pinned root tree SHA from preview when `source_kind == "github"`. #[serde(default)] #[specta(optional)] pub tree_sha: Option, /// Pinned commit SHA from preview when `source_kind == "github"`. #[serde(default)] #[specta(optional)] pub commit_sha: Option, #[serde(default)] pub subpath: String, #[serde(default)] #[specta(optional)] pub local_path: Option, #[serde(default)] #[specta(optional)] pub marketplace: Option, #[serde(default)] #[specta(optional)] pub marketplace_source: Option, pub scope: McpScope, /// Native harness the plugin is installed for (`claude`, `copilot`, `codex`, or `gemini`). pub harness: String, #[serde(default)] pub approve_capabilities: bool, /// The preview's `capabilityHash` the user approved; the install is refused if the installed /// folder resolves to different executable capabilities. #[serde(default)] #[specta(optional)] pub approved_capability_hash: Option, #[serde(default)] pub confirm_warnings: bool, #[serde(default)] pub overwrite: bool, } /// Selection of one server from an external MCP configuration source to import. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct McpImportSelection { pub source_id: String, pub name: String, } /// One tool advertised by an MCP server during `tools/list`. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct McpToolSummary { pub name: String, pub description: Option, } /// Result of testing/probing an MCP server (`initialize` + `tools/list`). #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct McpProbeResult { pub ok: bool, pub server_name: Option, pub server_version: Option, pub protocol_version: Option, pub tools: Vec, pub duration_ms: u32, pub error: Option, } /// Payload for creating a custom ACP agent, or an instance of built-in `base` (which /// launches as its base does when `command` is empty); the id becomes the /// `/agents/.toml` file name. #[derive(Clone, Debug, Deserialize, Type)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct CustomAgentInput { pub id: String, pub name: String, #[serde(default)] pub base: Option, pub command: String, #[serde(default)] pub args: Vec, #[serde(default)] pub env: BTreeMap, } /// What importing one entry of a JetBrains `acp.json` file did. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AcpImportOutcome { /// The `agent_servers` key the entry was imported from. pub name: String, /// The id its agent file would get (also when skipped). pub id: String, pub saved: bool, /// Why the entry was skipped; empty when it was saved. #[serde(default)] pub reason: String, } /// What accepting a worktree task's changes copied into the local checkout. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentAcceptOutcome { /// Relative paths copied into the checkout (uncommitted), including ones already identical. pub accepted: Vec, /// Files left alone because the checkout has its own edits to them. pub skipped: Vec, } /// A file accept left alone, with why. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] #[serde(rename_all = "camelCase")] pub struct AgentAcceptSkipped { pub path: String, pub reason: String, }