* Add multi-user auth and per-user control sessions * Add mission store abstraction and auth UX polish * Fix unused warnings in tooling * Fix Bugbot review issues - Prevent username enumeration by using generic error message - Add pagination support to InMemoryMissionStore::list_missions - Improve config error when JWT_SECRET missing but DASHBOARD_PASSWORD set * Trim stored username in comparison for consistency * Fix mission cleanup to also remove orphaned tree data * Refactor Open Agent as OpenCode workspace host * Remove chromiumoxide and pin @types/react * Pin idna_adapter for MSRV compatibility * Add host-mcp bin target * Use isolated Playwright MCP sessions * Allow Playwright MCP as root * Fix iOS dashboard warnings * Add autoFocus to username field in multi-user login mode Mirrors the iOS implementation behavior where username field is focused when multi-user auth mode is active. * Fix Bugbot review issues - Add conditional ellipsis for tool descriptions (only when > 32 chars) - Add serde(default) to JWT usr field for backward compatibility * Fix empty user ID fallback in multi-user auth Add effective_user_id helper that falls back to username when id is empty, preventing session sharing and token verification issues. * Fix parallel mission history preservation Load existing mission history into runner before starting parallel execution to prevent losing conversation context. * Fix desktop stream controls layout overflow on iPad - Add frame(maxWidth: .infinity) constraints to ensure controls stay within bounds on wide displays - Add alignment: .leading to VStacks for consistent layout - Add Spacer() to buttons row to prevent spreading - Increase label width to 55 for consistent FPS/Quality alignment - Add alignment: .trailing to value text frames * Fix queued user messages not persisted to mission history When a user message was queued (sent while another task was running), it was not being added to the history or persisted to the database. This caused queued messages to be lost from mission history. Added the same persistence logic used for initial messages to the queued message handling code path.
171 lines
3.9 KiB
Rust
171 lines
3.9 KiB
Rust
//! API request and response types.
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
use uuid::Uuid;
|
|
|
|
/// Request to submit a new task.
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
pub struct CreateTaskRequest {
|
|
/// The task description / user prompt
|
|
pub task: String,
|
|
|
|
/// Optional model override (uses default if not specified)
|
|
pub model: Option<String>,
|
|
|
|
/// Optional working directory for relative paths (agent has full system access regardless)
|
|
pub working_dir: Option<String>,
|
|
|
|
/// Optional budget in cents (default: 1000 = $10)
|
|
pub budget_cents: Option<u64>,
|
|
}
|
|
|
|
/// Statistics response.
|
|
#[derive(Debug, Clone, Serialize)]
|
|
pub struct StatsResponse {
|
|
/// Total number of tasks ever created
|
|
pub total_tasks: usize,
|
|
|
|
/// Number of currently running tasks
|
|
pub active_tasks: usize,
|
|
|
|
/// Number of completed tasks
|
|
pub completed_tasks: usize,
|
|
|
|
/// Number of failed tasks
|
|
pub failed_tasks: usize,
|
|
|
|
/// Total cost spent in cents
|
|
pub total_cost_cents: u64,
|
|
|
|
/// Success rate (0.0 - 1.0)
|
|
pub success_rate: f64,
|
|
}
|
|
|
|
/// Response after creating a task.
|
|
#[derive(Debug, Clone, Serialize)]
|
|
pub struct CreateTaskResponse {
|
|
/// Unique task identifier
|
|
pub id: Uuid,
|
|
|
|
/// Current task status
|
|
pub status: TaskStatus,
|
|
}
|
|
|
|
/// Task status enumeration.
|
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum TaskStatus {
|
|
/// Task is queued, waiting to start
|
|
Pending,
|
|
/// Task is currently running
|
|
Running,
|
|
/// Task completed successfully
|
|
Completed,
|
|
/// Task failed with an error
|
|
Failed,
|
|
/// Task was cancelled
|
|
Cancelled,
|
|
}
|
|
|
|
/// Full task state including results.
|
|
#[derive(Debug, Clone, Serialize)]
|
|
pub struct TaskState {
|
|
/// Unique task identifier
|
|
pub id: Uuid,
|
|
|
|
/// Current status
|
|
pub status: TaskStatus,
|
|
|
|
/// Original task description
|
|
pub task: String,
|
|
|
|
/// Model used for this task
|
|
pub model: String,
|
|
|
|
/// Number of iterations completed
|
|
pub iterations: usize,
|
|
|
|
/// Final result or error message
|
|
pub result: Option<String>,
|
|
|
|
/// Detailed execution log
|
|
pub log: Vec<TaskLogEntry>,
|
|
}
|
|
|
|
/// A single entry in the task execution log.
|
|
#[derive(Debug, Clone, Serialize)]
|
|
pub struct TaskLogEntry {
|
|
/// Timestamp (ISO 8601)
|
|
pub timestamp: String,
|
|
|
|
/// Entry type
|
|
pub entry_type: LogEntryType,
|
|
|
|
/// Content of the entry
|
|
pub content: String,
|
|
}
|
|
|
|
/// Types of log entries.
|
|
#[derive(Debug, Clone, Serialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum LogEntryType {
|
|
/// Agent is thinking / planning
|
|
Thinking,
|
|
/// Tool is being called
|
|
ToolCall,
|
|
/// Tool returned a result
|
|
ToolResult,
|
|
/// Agent produced final response
|
|
Response,
|
|
/// An error occurred
|
|
Error,
|
|
}
|
|
|
|
/// Server-Sent Event for streaming task progress.
|
|
#[derive(Debug, Clone, Serialize)]
|
|
pub struct TaskEvent {
|
|
/// Event type
|
|
pub event: String,
|
|
|
|
/// Event data (JSON serialized)
|
|
pub data: serde_json::Value,
|
|
}
|
|
|
|
/// Health check response.
|
|
#[derive(Debug, Clone, Serialize)]
|
|
pub struct HealthResponse {
|
|
/// Service status
|
|
pub status: String,
|
|
|
|
/// Service version
|
|
pub version: String,
|
|
|
|
/// Whether the server is running in dev mode (auth disabled)
|
|
pub dev_mode: bool,
|
|
|
|
/// Whether auth is required for API requests (dev_mode=false)
|
|
pub auth_required: bool,
|
|
|
|
/// Authentication mode ("disabled", "single_tenant", "multi_user")
|
|
pub auth_mode: String,
|
|
|
|
/// Maximum iterations per agent (from MAX_ITERATIONS env var)
|
|
pub max_iterations: usize,
|
|
}
|
|
|
|
/// Login request for dashboard auth.
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
pub struct LoginRequest {
|
|
#[serde(default)]
|
|
pub username: Option<String>,
|
|
pub password: String,
|
|
}
|
|
|
|
/// Login response containing a JWT for API authentication.
|
|
#[derive(Debug, Clone, Serialize)]
|
|
pub struct LoginResponse {
|
|
pub token: String,
|
|
/// Expiration as unix seconds.
|
|
pub exp: i64,
|
|
}
|