Skip to main content

htmlp/runtime/
mod.rs

1//! Typed model requests and runtime accounting, independent of any provider SDK.
2//! Every fragment requires a source and role. Estimates, tokenizer-measured
3//! document budgets, and reported usage are distinct; none implies the others.
4mod request;
5mod usage;
6pub use request::*;
7use serde::{Deserialize, Serialize};
8pub use usage::*;
9
10/// Message role; source attribution remains independent of role.
11#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
12#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
13#[serde(rename_all = "lowercase")]
14pub enum Role {
15    User,
16    Assistant,
17    System,
18}
19
20/// Opaque provider-neutral tool-call identity. The caller generates IDs;
21/// HTMLP has no UUID, clock, or random-number dependency.
22#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
23#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
24#[serde(transparent)]
25pub struct ToolUseId(String);
26impl ToolUseId {
27    pub fn from_string(value: String) -> Self {
28        Self(value)
29    }
30    pub fn as_str(&self) -> &str {
31        &self.0
32    }
33}
34impl std::fmt::Display for ToolUseId {
35    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
36        f.write_str(&self.0)
37    }
38}