Expand description
Proc macros for the Cognis framework.
§Macros
tool—#[cognis::tool]attribute that generates acognis_core::tools::BaseToolimplementation from anasync fn(or from animplblock containing one). Uses [schemars] under the hood for parameter schema generation.GraphState— derive macro for graph state schemas with per-field reducers (see attributes#[reducer(append|last_value|add|merge)]).
§JSON Schema generation
For #[derive(JsonSchema)] on your own structs/enums, use the re-export
at cognis_core::JsonSchema (which is schemars::JsonSchema). The legacy
hand-rolled JsonSchema / ToolSchema derives in this crate were removed
in favor of the upstream schemars crate, which supports recursive types,
$ref/definitions, doc-comment → description, and richer attribute
syntax.
ⓘ
use cognis_core::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(JsonSchema, Serialize, Deserialize)]
struct SearchFilter {
/// Minimum relevance score
min_score: f64,
/// Categories to include
categories: Vec<String>,
}
let schema = serde_json::to_value(schemars::schema_for!(SearchFilter)).unwrap();Attribute Macros§
- tool
#[cognis::tool]— attribute macro that generates a [cognis_core::tools::BaseTool] implementation from anasync fn.- tools_
impl #[tools_impl]— outer attribute that scans animplblock for inner#[tool]-marked async methods and generates one [cognis_core::tools::BaseTool] wrapper per method, plus aninto_tools()collector method on the user’s struct.
Derive Macros§
- Graph
State - Derive macro for generating graph state schemas with per-field reducers.
- Graph
State V2 #[derive(GraphStateV2)]— v2-shape state derive that emits a typed sibling<Name>Updatestruct and animpl GraphState for <Name>. Use in v2 code via the re-exportcognis_core::GraphState(the rename happens in cognis-core’s lib.rs in Plan #2).