Skip to content

Shared types, traits, and interface contracts for agent subsystems #998

Closed

Description

@malibio

Overview

Establish the foundational type definitions, trait interfaces, message formats, and Tauri event constants that all agent-related issues code against. This issue produces no runtime behavior — only type definitions, trait declarations, and module scaffolding.

This is the single prerequisite that unblocks all parallel implementation streams.

Acceptance Criteria

  • All types compile with cargo check
  • All traits have complete async method signatures with async_trait
  • Serde derives on all types that cross the Tauri boundary
  • Constants for all Tauri event channel names
  • Module re-exports everything from agent_types for ergonomic imports
  • No runtime implementation — traits have no default method bodies
  • Doc comments on every public type and trait method explaining the contract
  • TypeScript interface equivalents for frontend event payloads
  • Code passes bun run quality:fix

Technical Specifications

New Module

  • packages/desktop-app/src-tauri/src/agent_types.rs (or agent_types/ module)

Chat Inference Contract

  • ChatInferenceEngine trait with generate(), model_info(), token_count()
  • InferenceRequest — messages, temperature, max_tokens, stop_sequences
  • ChatMessage — role (System/User/Assistant/Tool), content, tool_calls, tool_result
  • StreamingChunk — Token, ToolCall, Done, Error variants
  • ToolCallRaw — function_name, arguments_json

Model Management Contract

  • ModelManager trait — list, download, cancel, delete, load, loaded_model
  • ModelInfo — id, name, filename, size, sha256, quantization, context_length, model_type
  • ModelStatus — NotDownloaded, Downloading, Verifying, Ready, Loaded, Error
  • DownloadEvent — Progress, Complete, Failed
  • ChatModelSpec — display_name, download_url, family, recommended, description
  • ModelFamily enum — Mistral, Qwen (future), Llama3 (future), DeepSeek (future)

Local Agent Contract

  • AgentToolExecutor trait — available_tools(), execute()
  • AgentSession — id, started_at, model_id, message_count, status
  • LocalAgentStatus — Idle, Thinking, ToolExecution, Streaming, Error
  • AgentTurnResult — response, tool_calls_made, tokens_used
  • ToolDefinition — name, description, parameters_schema
  • ToolResult — tool_name, success, output
  • ToolExecutionRecord — tool_name, arguments, result, duration_ms, success

ACP Contract

  • AcpTransport trait — send(), receive(), close(), is_connected()
  • AgentRegistry trait — discover_agents(), check_health(), get_agent()
  • ContextAssembler trait — assemble()
  • AcpMessage — jsonrpc, id, method, params, result, error
  • AcpAgentInfo — id, name, binary_name, auth_method, available
  • AcpAuthMethod — AgentManaged, EnvApiKey
  • AcpSessionState — Idle, Initializing, Active, Completing, Completed, Failed
  • ContextPacket — selected_nodes, semantic_neighbors, relationships, system_prompt, token_budget

Tauri Event Constants

pub mod events {
    pub const LOCAL_AGENT_CHUNK: &str = "local-agent://chunk";
    pub const LOCAL_AGENT_TOOL: &str = "local-agent://tool";
    pub const LOCAL_AGENT_STATUS: &str = "local-agent://status";
    pub const LOCAL_AGENT_ERROR: &str = "local-agent://error";
    pub const MODEL_DOWNLOAD_PROGRESS: &str = "model://download-progress";
    pub const ACP_SESSION_STATE: &str = "acp://session-state";
    pub const ACP_AGENT_MESSAGE: &str = "acp://agent-message";
}

TypeScript Equivalents

  • Event payload interfaces matching Rust serde output
  • Command return type interfaces
  • Located in src/lib/types/agent-types.ts

Reference Files

  • packages/desktop-app/src-tauri/src/app_services.rs — existing service pattern
  • packages/core/src/playbook/types.rs — example of well-structured type module
  • packages/nlp-engine/src/lib.rs — existing NLP engine public API

Dependencies

  • None (this unblocks everything)

Related Issues

Activity

  1. malibio commented on Apr 3, 2026

    @malibio
    CollaboratorAuthor

    Baseline: Frontend tests crash in worktree with pre-existing vitest startup error (TypeError: Attempted to assign to readonly property). This is a worktree-specific tsconfig resolution issue, not a code regression. Rust compilation will be the primary validation for this types-only issue.

  2. self-assigned this
    on Apr 3, 2026
  3. added a commit that references this issue on Apr 3, 2026
    13dff2d
  4. added a commit that references this issue on Apr 3, 2026
    55074c6
  5. added a commit that references this issue on Jun 22, 2026
    9fdeefc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions