calternal-plugin-ai
Core AI Plugin for per-User Agent containers and undoable Agent turns. Revoke credentials durably before removing recovery bindings (#824, DESIGN §2).
Source: crates/plugins/ai/src/lib.rs
AgentProvider
Section titled “AgentProvider”pub enum AgentProviderThe official coding Agent selected by a prompt mention.
Variants
Claude: Anthropic’s Claude Code CLI.Codex: OpenAI’s Codex CLI.
Implements: Clone, Copy, Debug, Eq, PartialEq, Deserialize, Serialize, ToSchema
AgentProvider::as_str
Section titled “AgentProvider::as_str”pub const fn as_str(self) -> &'static strStable provider ID stored in the Index and API.
AgentProvider::from_prompt
Section titled “AgentProvider::from_prompt”pub fn from_prompt(prompt: &str) -> Result<Self, ProviderError>Select one Agent from a whole-token @claude or @codex mention.
Source: crates/plugins/ai/src/lib.rs:29
ProviderError
Section titled “ProviderError”pub enum ProviderErrorA prompt does not name exactly one supported Agent.
Variants
MissingMention: The prompt has no@claudeor@codexmention.AmbiguousMention: The prompt names both supported Agents.
Implements: Clone, Copy, Debug, Eq, PartialEq
Source: crates/plugins/ai/src/lib.rs:38
Functions
Section titled “Functions”agent_turn_scope
Section titled “agent_turn_scope”pub async fn agent_turn_scope( db: &Db, token_hash: &[u8],) -> Result<Option<AgentTurnScope>, sqlx::Error>Resolve an authenticated data token to its active turn attribution scope. Call only after the auth middleware has validated the bearer token.
Source: crates/plugins/ai/src/lib.rs:152
configure_agent_runtime
Section titled “configure_agent_runtime”pub fn configure_agent_runtime( auth: SqliteAuthStore, files: Arc<FilesState>, server_url: String,) -> Result<(), &'static str>Install server-owned Agent services. The Podman socket is opened lazily so a host without nested Podman can still serve non-AI APIs and credentials.
Source: crates/plugins/ai/src/lib.rs:97
configure_instance_secret_key
Section titled “configure_instance_secret_key”pub fn configure_instance_secret_key(key: [u8; 32]) -> Result<(), &'static str>Configure encryption for credentials with a key kept in the Index’s instance-secret table. This call must happen once before live routes build.
Source: crates/plugins/ai/src/lib.rs:88
migrations
Section titled “migrations”pub fn migrations() -> MigrationSetAI Plugin Index migrations.
Source: crates/plugins/ai/src/store.rs:13
recover_agent_turns
Section titled “recover_agent_turns”pub async fn recover_agent_turns(db: &Db, auth: &SqliteAuthStore) -> Result<(), sqlx::Error>Revoke stale Agent credentials and stop queued or running turns left by a previous server process. Turn prompts are not persisted, so queued turns cannot be resumed safely after restart. A failed revoke keeps all recovery bindings and stops startup; only durable revocation permits deletion (#824).
Source: crates/plugins/ai/src/lib.rs:184