Files
leleka/desktop-core/src/runtime_tools.rs
T
Pavlo Ratushnyi 6b5fcd242e STRA-338 S12b: fns and impl blocks of 59 cold oversize modules move into child modules (model-format, gateway, desktop-core, leaf libraries)
scripts/dev/split_module.py (lexer-based, with 16 self-tests) moves the top-level fn and impl items of 59 oversize module files in control-plane, desktop-core, model-format, gateway-text, leleka-memory, experimental-ref, context, serving-policy, tokenizer, backend-api, quant-core, harmony, igpu, libc-shim, npu-service and runtime-client into foo/<name>.rs groups of about 250 lines; types, constants, macros, nested modules and tests stay, every path stays valid through pub use re-exports, restricted visibilities keep their scope one level down, include paths and super:: paths are shifted. Not touched: leleka-runtime, cuda-driver, native-cpu-expert, sampler-ref and cpu-* (hot path, next wave) and the files kar-off-ab edits.

The baseline drops from 311 to 263 oversize files and from 273,600 to about 233,000 lines; the path-include ratchet ignores dir/name.rs child declarations.
2026-11-05 15:29:39 +01:00

75 lines
1.6 KiB
Rust

//! Bounded, whole-completion tool semantics for the experimental native adapter.
//! This module performs no publication or execution and mints no identifiers.
use std::collections::{HashMap, HashSet};
use std::io::{self, Write};
use serde_json::{Value, json};
use crate::runtime_prompt::{Effort, Message, Role};
use crate::runtime_tool_catalog::{Catalog, alias};
use crate::runtime_tool_parser::{self, Segment};
const REQUEST_LIMIT: usize = 1024 * 1024;
const OUTPUT_LIMIT: usize = 8 * 1024 * 1024;
const TOOL_LIMIT: usize = 128;
const ITEM_LIMIT: usize = 1024;
pub struct ToolPlan {
pub prompt: String,
pub max_output_tokens: u32,
pub policy: ToolPolicy,
pub sampling: leleka_sampler_ref::params::FixedPoint,
}
pub enum ValidatedSegment {
Text(String),
Call(Value),
}
pub struct ToolPolicy {
catalog: Catalog,
identities: HashMap<String, Identity>,
schemas: HashMap<String, jsonschema::Validator>,
choice: Choice,
parallel: bool,
}
struct Identity {
name: String,
namespace: Option<String>,
custom: bool,
}
enum Choice {
None,
Auto,
Required,
Forced(String),
Allowed {
required: bool,
names: HashSet<String>,
},
}
struct Count(usize);
struct Pending {
id: String,
custom: bool,
markup: String,
output: Option<String>,
}
mod fields;
#[allow(unused_imports)]
pub use fields::*;
mod impl_toolpolicy;
#[allow(unused_imports)]
pub use impl_toolpolicy::*;
mod impl_write_for_count;
#[allow(unused_imports)]
pub use impl_write_for_count::*;
mod history;
#[allow(unused_imports)]
pub use history::*;