Skip to content

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

pub enum AgentProvider

The 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

pub const fn as_str(self) -> &'static str

Stable provider ID stored in the Index and API.

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

pub enum ProviderError

A prompt does not name exactly one supported Agent.

Variants

  • MissingMention: The prompt has no @claude or @codex mention.
  • AmbiguousMention: The prompt names both supported Agents.

Implements: Clone, Copy, Debug, Eq, PartialEq

Source: crates/plugins/ai/src/lib.rs:38

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

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

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

pub fn migrations() -> MigrationSet

AI Plugin Index migrations.

Source: crates/plugins/ai/src/store.rs:13

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