lean_ctx/http_server/team/
mod.rs1use std::collections::{BTreeSet, HashMap};
2use std::path::{Path, PathBuf};
3use std::sync::Arc;
4use std::sync::atomic::{AtomicI64, Ordering};
5
6use anyhow::{Context, Result, anyhow};
7use axum::{
8 Router,
9 body::{self, Body},
10 extract::{Extension, Json, Query, State},
11 http::{Request, StatusCode, header},
12 middleware::{self, Next},
13 response::sse::{Event as SseEvent, KeepAlive, Sse},
14 response::{IntoResponse, Response},
15 routing::get,
16};
17use futures::Stream;
18use md5::{Digest, Md5};
19use rmcp::{
20 handler::server::ServerHandler,
21 model::{
22 CallToolRequest, CallToolRequestParams, CallToolResult, ClientJsonRpcMessage,
23 ClientRequest, JsonRpcRequest, NumberOrString, ServerJsonRpcMessage, ServerResult,
24 },
25 service::{RequestContext, RoleServer, serve_directly},
26 transport::{OneshotTransport, StreamableHttpService},
27};
28use serde::{Deserialize, Serialize};
29use serde_json::{Map, Value, json};
30use tokio::io::AsyncWriteExt;
31use tokio::sync::broadcast;
32use tokio::time::Duration;
33
34use crate::tools::LeanCtxServer;
35
36mod config;
37pub mod connectors;
38mod engine;
39mod handlers;
40mod helpers;
41mod request_pipeline;
42pub mod roles;
43mod server;
44mod state;
45
46pub use config::*;
47#[allow(clippy::wildcard_imports)]
48use engine::*;
49#[allow(clippy::wildcard_imports)]
50use handlers::*;
51pub(crate) use helpers::required_scopes;
52use helpers::{hex_lower, parse_sha256_hex, sha256_hex};
53#[allow(clippy::wildcard_imports)]
54use request_pipeline::*;
55pub use roles::TeamRole;
56pub use server::*;
57pub use state::*;
58use state::{EventsQuery, TeamAuthContext, ToolCallBody, ToolsQuery};
59
60const WORKSPACE_ARG_KEY: &str = "workspaceId";
61const CHANNEL_ARG_KEY: &str = "channelId";
62const AGENT_ARG_KEY: &str = "agentId";
67const WORKSPACE_HEADER: &str = "x-leanctx-workspace";
68
69#[cfg(test)]
70mod tests;