refactor(tools): rename rhema-tools-contract to rhema-claw-tools-contract
The crate binds the claw to its client tools, not tools at large, so it carries the claw's name: package, lib and dep names, the mock's binary, and the conformance suite's use paths. Specs and README follow. The tools/contract directory keeps its name, and no reference to the old name remains.
This commit is contained in:
1 parent
9e132fdf71
commit
d067f4632f
11 files changed
+91
-76
No files matched your search
@@ -49,7 +49,7 @@ rhema-rsd = { path = "../rhema-rsd" }
|
||||
# The tool contract: the agent-token allowlist and version the auth
|
||||
# middleware enforces (rhema-tools spec). The arrow runs claw ->
|
||||
# contract only — never the reverse.
|
||||
rhema-tools-contract = { path = "../../tools/contract" }
|
||||
rhema-claw-tools-contract = { path = "../../tools/contract" }
|
||||
# The resident tier's durable memory: its tools join the resolver chain
|
||||
rhema-memory = { path = "../rhema-memory" }
|
||||
# The shared ModelCard the backend registry's listings return
|
||||
|
||||
@@ -42,13 +42,13 @@ use axum::routing::put;
|
||||
use axum::routing::{delete, get, post};
|
||||
use axum::{Router, middleware};
|
||||
use rhema_autonomous_agent::Driver;
|
||||
use rhema_claw_tools_contract::Auth;
|
||||
use rhema_claw_tools_contract::CONTRACT_HEADER;
|
||||
use rhema_claw_tools_contract::CONTRACT_VERSION;
|
||||
use rhema_core::ImageMediaType;
|
||||
use rhema_rsd::{
|
||||
DispatchError, Dispatcher, IngestResult, KeyRecord, KeyState, ResourceKey, SqliteStore, Store,
|
||||
};
|
||||
use rhema_tools_contract::Auth;
|
||||
use rhema_tools_contract::CONTRACT_HEADER;
|
||||
use rhema_tools_contract::CONTRACT_VERSION;
|
||||
use serde::{Deserialize, Deserializer};
|
||||
use serde_json::{Value, json};
|
||||
use tokio::sync::broadcast::error::RecvError;
|
||||
@@ -401,8 +401,10 @@ async fn require_auth(State(state): State<ClawState>, request: Request, next: Ne
|
||||
)
|
||||
.into_response();
|
||||
}
|
||||
if rhema_tools_contract::agent_allowed(request.method().as_str(), request.uri().path())
|
||||
{
|
||||
if rhema_claw_tools_contract::agent_allowed(
|
||||
request.method().as_str(),
|
||||
request.uri().path(),
|
||||
) {
|
||||
next.run(request).await
|
||||
} else {
|
||||
(
|
||||
@@ -427,8 +429,10 @@ async fn require_auth(State(state): State<ClawState>, request: Request, next: Ne
|
||||
)
|
||||
.into_response();
|
||||
}
|
||||
if rhema_tools_contract::ingest_allowed(request.method().as_str(), request.uri().path())
|
||||
{
|
||||
if rhema_claw_tools_contract::ingest_allowed(
|
||||
request.method().as_str(),
|
||||
request.uri().path(),
|
||||
) {
|
||||
next.run(request).await
|
||||
} else {
|
||||
(
|
||||
|
||||
@@ -1483,42 +1483,44 @@ async fn the_surface_speaks_the_tool_contract() {
|
||||
.expect("the daemon assembles");
|
||||
let base = serve(&daemon).await;
|
||||
let client = reqwest::Client::new();
|
||||
let result = rhema_tools_contract::conformance(|request: rhema_tools_contract::CallRequest| {
|
||||
let client = client.clone();
|
||||
let base = base.clone();
|
||||
async move {
|
||||
let method = reqwest::Method::from_bytes(request.method.as_bytes())
|
||||
.map_err(|e| e.to_string())?;
|
||||
let builder = client.request(method, format!("{base}{}", request.path));
|
||||
let builder = match request.auth {
|
||||
rhema_tools_contract::Auth::None => builder,
|
||||
rhema_tools_contract::Auth::Human => {
|
||||
builder.header(reqwest::header::AUTHORIZATION, "Bearer human-token")
|
||||
}
|
||||
rhema_tools_contract::Auth::Agent => {
|
||||
builder.header(reqwest::header::AUTHORIZATION, "Bearer agent-token")
|
||||
}
|
||||
rhema_tools_contract::Auth::Invalid => {
|
||||
builder.header(reqwest::header::AUTHORIZATION, "Bearer a-stranger")
|
||||
}
|
||||
rhema_tools_contract::Auth::Ingest => {
|
||||
builder.header(reqwest::header::AUTHORIZATION, "Bearer ingest-token")
|
||||
}
|
||||
};
|
||||
let builder = match request.contract {
|
||||
Some(version) => builder.header("x-rhema-contract", version.to_string()),
|
||||
None => builder,
|
||||
};
|
||||
let builder = match request.body {
|
||||
Some(body) => builder.json(&body),
|
||||
None => builder,
|
||||
};
|
||||
let response = builder.send().await.map_err(|e| e.to_string())?;
|
||||
let status = response.status().as_u16();
|
||||
let body = response.json().await.unwrap_or(serde_json::json!({}));
|
||||
Ok(rhema_tools_contract::CallResponse { status, body })
|
||||
}
|
||||
})
|
||||
let result = rhema_claw_tools_contract::conformance(
|
||||
|request: rhema_claw_tools_contract::CallRequest| {
|
||||
let client = client.clone();
|
||||
let base = base.clone();
|
||||
async move {
|
||||
let method = reqwest::Method::from_bytes(request.method.as_bytes())
|
||||
.map_err(|e| e.to_string())?;
|
||||
let builder = client.request(method, format!("{base}{}", request.path));
|
||||
let builder = match request.auth {
|
||||
rhema_claw_tools_contract::Auth::None => builder,
|
||||
rhema_claw_tools_contract::Auth::Human => {
|
||||
builder.header(reqwest::header::AUTHORIZATION, "Bearer human-token")
|
||||
}
|
||||
rhema_claw_tools_contract::Auth::Agent => {
|
||||
builder.header(reqwest::header::AUTHORIZATION, "Bearer agent-token")
|
||||
}
|
||||
rhema_claw_tools_contract::Auth::Invalid => {
|
||||
builder.header(reqwest::header::AUTHORIZATION, "Bearer a-stranger")
|
||||
}
|
||||
rhema_claw_tools_contract::Auth::Ingest => {
|
||||
builder.header(reqwest::header::AUTHORIZATION, "Bearer ingest-token")
|
||||
}
|
||||
};
|
||||
let builder = match request.contract {
|
||||
Some(version) => builder.header("x-rhema-contract", version.to_string()),
|
||||
None => builder,
|
||||
};
|
||||
let builder = match request.body {
|
||||
Some(body) => builder.json(&body),
|
||||
None => builder,
|
||||
};
|
||||
let response = builder.send().await.map_err(|e| e.to_string())?;
|
||||
let status = response.status().as_u16();
|
||||
let body = response.json().await.unwrap_or(serde_json::json!({}));
|
||||
Ok(rhema_claw_tools_contract::CallResponse { status, body })
|
||||
}
|
||||
},
|
||||
)
|
||||
.await;
|
||||
assert_eq!(result, Ok(()), "the daemon speaks the tool contract");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user