refactor: rename llm worker crate to engine
This commit is contained in:
@@ -12,7 +12,7 @@ grep-regex = "0.1.14"
|
||||
grep-searcher = "0.1.16"
|
||||
ignore = "0.4.25"
|
||||
html5ever = "0.26"
|
||||
llm-worker = { workspace = true }
|
||||
llm-engine = { workspace = true }
|
||||
manifest = { workspace = true }
|
||||
secrets = { workspace = true }
|
||||
markup5ever_rcdom = "0.2"
|
||||
|
||||
@@ -16,7 +16,7 @@ Owns:
|
||||
Does not own:
|
||||
|
||||
- manifest permission policy definition (`manifest`)
|
||||
- Worker tool-loop semantics (`llm-worker`)
|
||||
- Engine tool-loop semantics (`llm-engine`)
|
||||
- Pod lifecycle decisions (`pod`)
|
||||
- UI presentation (`tui`)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
//! returned inline and the file is cleaned up. When it is longer the
|
||||
//! full output is left on disk and only the **last 80 lines** are
|
||||
//! returned, prefixed with the saved file's path. This sidesteps the
|
||||
//! Worker's blanket `ToolOutputLimits` (default 64 KiB), which would
|
||||
//! Engine's blanket `ToolOutputLimits` (default 64 KiB), which would
|
||||
//! otherwise drop the *tail* of the output — usually the most useful
|
||||
//! part (errors, exit messages, summary). The saved file lives under
|
||||
//! a caller-supplied directory that the parent has added to the
|
||||
@@ -28,7 +28,7 @@ use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use llm_worker::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use serde::Deserialize;
|
||||
use tokio::process::Command;
|
||||
|
||||
@@ -56,7 +56,7 @@ const TAIL_LINES: usize = 80;
|
||||
|
||||
/// Inline-return budget. Outputs at or below this are returned in full;
|
||||
/// above it triggers the spill-to-file path. Sized to leave headroom under
|
||||
/// the Worker's 64 KiB default `ToolOutputLimits` cap so the inline path
|
||||
/// the Engine's 64 KiB default `ToolOutputLimits` cap so the inline path
|
||||
/// reliably reaches the model intact.
|
||||
const INLINE_BYTE_BUDGET: usize = 12 * 1024;
|
||||
|
||||
@@ -104,7 +104,7 @@ impl Tool for BashTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_worker::tool::ToolExecutionContext,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: BashParams = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid Bash input: {e}")))?;
|
||||
@@ -222,7 +222,7 @@ impl Tool for BashTool {
|
||||
}
|
||||
|
||||
// Inline if the whole output fits in our tail-read window AND is
|
||||
// small enough to ride under the Worker's default cap.
|
||||
// small enough to ride under the Engine's default cap.
|
||||
let line_count = tail_text.lines().count();
|
||||
let fully_loaded = total_bytes <= tail_bytes.len();
|
||||
let fits_inline =
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use llm_worker::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::error::ToolsError;
|
||||
@@ -39,7 +39,7 @@ impl Tool for EditTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
ctx: llm_worker::tool::ToolExecutionContext,
|
||||
ctx: llm_engine::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: EditParams = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid Edit input: {e}")))?;
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
//!
|
||||
//! `ToolsError` is the crate-level error returned by `ScopedFs` and each
|
||||
//! builtin tool's internal logic. Tool `execute()` impls convert it to
|
||||
//! [`llm_worker::tool::ToolError`] via the `From` impl defined here.
|
||||
//! [`llm_engine::tool::ToolError`] via the `From` impl defined here.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use llm_worker::tool::ToolError;
|
||||
use llm_engine::tool::ToolError;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum ToolsError {
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::sync::Arc;
|
||||
use std::time::SystemTime;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use llm_worker::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use manifest::Scope;
|
||||
use serde::Deserialize;
|
||||
|
||||
@@ -38,7 +38,7 @@ impl Tool for GlobTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_worker::tool::ToolExecutionContext,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: GlobParams = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid Glob input: {e}")))?;
|
||||
|
||||
@@ -10,7 +10,7 @@ use grep_searcher::{BinaryDetection, Searcher, SearcherBuilder, Sink, SinkContex
|
||||
use ignore::WalkBuilder;
|
||||
use ignore::overrides::OverrideBuilder;
|
||||
use ignore::types::TypesBuilder;
|
||||
use llm_worker::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use manifest::Scope;
|
||||
use serde::Deserialize;
|
||||
|
||||
@@ -85,7 +85,7 @@ impl Tool for GrepTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_worker::tool::ToolExecutionContext,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: GrepParams = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid Grep input: {e}")))?;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Built-in tools for the Yoi LLM agent.
|
||||
//!
|
||||
//! Implements Read / Write / Edit / Glob / Grep / Bash on top of the
|
||||
//! `llm-worker` `Tool` infrastructure. Filesystem access is mediated by
|
||||
//! `llm-engine` `Tool` infrastructure. Filesystem access is mediated by
|
||||
//! two orthogonal concerns:
|
||||
//!
|
||||
//! - [`ScopedFs`] — Pod-process lifetime, expresses the write-block
|
||||
@@ -12,7 +12,7 @@
|
||||
//! Recreated fresh on each Pod start (including resume).
|
||||
//!
|
||||
//! The Pod layer owns both instances and passes them to
|
||||
//! [`core_builtin_tools`] when registering tools on a `Worker`.
|
||||
//! [`core_builtin_tools`] when registering tools on a `Engine`.
|
||||
//!
|
||||
//! `Bash` is the lone exception — its child processes bypass `ScopedFs`
|
||||
//! entirely. Safety for arbitrary command execution is delegated to the
|
||||
@@ -57,7 +57,7 @@ pub fn core_builtin_tools(
|
||||
fs: ScopedFs,
|
||||
tracker: Tracker,
|
||||
bash_output_dir: std::path::PathBuf,
|
||||
) -> Vec<llm_worker::tool::ToolDefinition> {
|
||||
) -> Vec<llm_engine::tool::ToolDefinition> {
|
||||
vec![
|
||||
read_tool(fs.clone(), tracker.clone()),
|
||||
write_tool(fs.clone(), tracker.clone()),
|
||||
@@ -70,7 +70,7 @@ pub fn core_builtin_tools(
|
||||
|
||||
pub fn web_builtin_tools(
|
||||
web_config: Option<manifest::WebConfig>,
|
||||
) -> Vec<llm_worker::tool::ToolDefinition> {
|
||||
) -> Vec<llm_engine::tool::ToolDefinition> {
|
||||
vec![
|
||||
web_search_tool(web::WebTools::new(web_config.clone())),
|
||||
web_fetch_tool(web::WebTools::new(web_config)),
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use llm_worker::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::scoped_fs::ScopedFs;
|
||||
@@ -39,7 +39,7 @@ impl Tool for ReadTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_worker::tool::ToolExecutionContext,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: ReadParams = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid Read input: {e}")))?;
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::path::{Component, Path, PathBuf};
|
||||
|
||||
use llm_worker::tool::ToolExecutionContext;
|
||||
use llm_engine::tool::ToolExecutionContext;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use sha2::{Digest, Sha256};
|
||||
@@ -142,7 +142,7 @@ impl Tracker {
|
||||
/// Acquire the per-target-file mutation guard shared by `Write` and `Edit`.
|
||||
///
|
||||
/// The guard is keyed by canonical target path where possible so equivalent
|
||||
/// paths serialize through the same lock. Worker still executes tool calls in
|
||||
/// paths serialize through the same lock. Engine still executes tool calls in
|
||||
/// parallel; this only gates the critical filesystem mutation section for
|
||||
/// builtin file mutation tools.
|
||||
pub(crate) async fn acquire_mutation(
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::time::Duration;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use html5ever::tendril::TendrilSink;
|
||||
use llm_worker::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use manifest::{WebConfig, WebFetchConfig, WebSearchConfig, WebSearchProvider};
|
||||
use markup5ever_rcdom::{Handle, NodeData, RcDom};
|
||||
use reqwest::header::{CONTENT_LENGTH, CONTENT_TYPE, HeaderMap, LOCATION};
|
||||
@@ -149,7 +149,7 @@ impl Tool for WebSearchTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_worker::tool::ToolExecutionContext,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let input: WebSearchInput = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid WebSearch input: {e}")))?;
|
||||
@@ -200,7 +200,7 @@ impl Tool for WebFetchTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_worker::tool::ToolExecutionContext,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let input: WebFetchInput = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid WebFetch input: {e}")))?;
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use llm_worker::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::scoped_fs::ScopedFs;
|
||||
@@ -33,7 +33,7 @@ impl Tool for WriteTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
ctx: llm_worker::tool::ToolExecutionContext,
|
||||
ctx: llm_engine::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: WriteParams = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid Write input: {e}")))?;
|
||||
@@ -237,7 +237,7 @@ mod tests {
|
||||
#[tokio::test]
|
||||
async fn write_then_edit_same_file_same_batch_uses_call_order() {
|
||||
use crate::edit::edit_tool;
|
||||
use llm_worker::tool::ToolExecutionContext;
|
||||
use llm_engine::tool::ToolExecutionContext;
|
||||
|
||||
let (dir, fs, tracker) = setup();
|
||||
let file = dir.path().join("ordered.txt");
|
||||
@@ -272,7 +272,7 @@ mod tests {
|
||||
#[tokio::test]
|
||||
async fn failed_same_file_mutation_releases_guard_for_followup() {
|
||||
use crate::edit::edit_tool;
|
||||
use llm_worker::tool::ToolExecutionContext;
|
||||
use llm_engine::tool::ToolExecutionContext;
|
||||
|
||||
let (dir, fs, tracker) = setup();
|
||||
let file = dir.path().join("release.txt");
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use llm_worker::tool::{Tool, ToolDefinition};
|
||||
use llm_engine::tool::{Tool, ToolDefinition};
|
||||
use manifest::{Permission, Scope, ScopeConfig, ScopeRule};
|
||||
use serde_json::json;
|
||||
use tempfile::TempDir;
|
||||
use tools::{ScopedFs, Tracker, core_builtin_tools};
|
||||
|
||||
struct Registry {
|
||||
entries: Vec<(llm_worker::tool::ToolMeta, Arc<dyn Tool>)>,
|
||||
entries: Vec<(llm_engine::tool::ToolMeta, Arc<dyn Tool>)>,
|
||||
}
|
||||
|
||||
impl Registry {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
//! Cross-tool integration tests exercising `core_builtin_tools()` end-to-end.
|
||||
//!
|
||||
//! `ToolServerHandle::register_tool` / `flush_pending` are `pub(crate)` in
|
||||
//! llm-worker, so from here we exercise the factories directly — the same
|
||||
//! llm-engine, so from here we exercise the factories directly — the same
|
||||
//! code path that `flush_pending()` runs at production time.
|
||||
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
|
||||
use llm_worker::tool::{Tool, ToolDefinition, ToolMeta};
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolMeta};
|
||||
use manifest::{Permission, Scope, ScopeConfig, ScopeRule};
|
||||
use serde_json::json;
|
||||
use tempfile::TempDir;
|
||||
@@ -60,13 +60,13 @@ fn setup() -> (TempDir, TempDir, Registry) {
|
||||
(dir, spill, reg)
|
||||
}
|
||||
|
||||
async fn call(tool: &Arc<dyn Tool>, input: serde_json::Value) -> llm_worker::tool::ToolOutput {
|
||||
async fn call(tool: &Arc<dyn Tool>, input: serde_json::Value) -> llm_engine::tool::ToolOutput {
|
||||
tool.execute(&input.to_string(), Default::default())
|
||||
.await
|
||||
.expect("tool execution failed")
|
||||
}
|
||||
|
||||
async fn call_err(tool: &Arc<dyn Tool>, input: serde_json::Value) -> llm_worker::tool::ToolError {
|
||||
async fn call_err(tool: &Arc<dyn Tool>, input: serde_json::Value) -> llm_engine::tool::ToolError {
|
||||
tool.execute(&input.to_string(), Default::default())
|
||||
.await
|
||||
.expect_err("expected error")
|
||||
|
||||
Reference in New Issue
Block a user