feat: complete Epic 1 production foundation

This commit is contained in:
bsodfather committed 2026-08-25 01:24:11 +03:00
1 parent 767428436d
commit 182bde8ac0
298 files changed
+35711 -5291

No files matched your search

@@ -0,0 +1,60 @@
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
#[derive(Debug, Serialize, Deserialize)]
pub(super) struct InitializeParams {
#[serde(rename = "protocolVersion")]
pub(super) protocol_version: String,
#[serde(default)]
pub(super) capabilities: Value,
}
#[derive(Debug, Serialize, Deserialize)]
pub(super) struct ToolCallParams {
pub(super) name: String,
#[serde(default)]
pub(super) arguments: Value,
}
#[derive(Debug, Deserialize)]
pub(super) struct ToolsListParams {
#[serde(default)]
pub(super) cursor: Option<String>,
#[serde(default)]
pub(super) limit: Option<usize>,
}
pub(super) fn paginate_tools_list(
definitions: Vec<Value>,
params: ToolsListParams,
) -> Result<Value, &'static str> {
const MAX_TOOLS_LIST_LIMIT: usize = 100;
let start = match params.cursor {
Some(cursor) if cursor.is_empty() => 0,
Some(cursor) => cursor
.parse::<usize>()
.map_err(|_| "invalid tools/list cursor")?,
None => 0,
};
if start > definitions.len() {
return Err("tools/list cursor is out of range");
}
let limit = params
.limit
.unwrap_or(definitions.len())
.clamp(1, MAX_TOOLS_LIST_LIMIT);
let end = start.saturating_add(limit).min(definitions.len());
let page = definitions[start..end].to_vec();
let mut result = json!({ "tools": page });
if end < definitions.len() {
result["nextCursor"] = json!(end.to_string());
}
Ok(result)
}
#[derive(Debug, Deserialize)]
pub(super) struct ApprovalDecisionPayload {
pub(super) approve: String,
#[serde(default)]
pub(super) note: Option<String>,
}