liminal-cli 0.3.30

The liminal command: serve the network, maintain its stores, or serve its discovery MCP over stdio
Documentation
//! Proposals carry paths and invocation data; the server pins and holds them.

use super::tools::ToolResult;
use crate::network::Rail;
use serde_json::{Map, Value, json};

/// The proposal names no subjects or digest: both come from the server's site.
#[must_use]
pub fn tool_entries() -> Vec<Value> {
    vec![
        json!({"name":"propose_template","description":"Propose the bound builder's command for its site while it is building. The server validates operator roots, hashes the file and holds exact path, digest, args, environment names and subjects for a person's approval.",
        "inputSchema":invocation()}),
        json!({"name":"templates_update","description":"Change a complete site's program after it is rebuilt: the server hashes the file again under the operator roots; on an open exchange the change executes now, on a gated one it is held for approvers. The next start runs the new digest.",
        "inputSchema":invocation()}),
    ]
}

/// The exact invocation both template tools carry.
fn invocation() -> Value {
    json!({"type":"object","required":["service","command","args","env","stop_timeout_ms"],"additionalProperties":false,
        "properties":{"service":{"type":"string"},"command":{"type":"string"},"args":{"type":"array","items":{"type":"string"}},
            "env":{"type":"array","items":{"type":"string"}},"stop_timeout_ms":{"type":"integer","minimum":1},"operation":{"type":"string"}}})
}

/// Forwards the invocation on the ticket's rail, never running the command.
#[must_use]
pub fn tool<R: Rail>(rail: &R, name: &str, arguments: &Map<String, Value>) -> Option<ToolResult> {
    let subject = match name {
        "propose_template" => "services.propose_template",
        "templates_update" => "templates.update",
        _ => return None,
    };
    Some(super::plan_tools::forward(rail, name, subject, arguments))
}

#[cfg(test)]
#[path = "template_tools_tests.rs"]
mod tests;