feat: prepare agen crates for publication

This commit is contained in:
2026-08-23 03:41:51 +09:00
parent aa8dd4f89e
commit d69c367285
206 changed files with 1316 additions and 1145 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ license.workspace = true
async-trait = { workspace = true }
fs-operation.workspace = true
html5ever = "0.26"
llm-engine = { workspace = true }
agen = { workspace = true }
manifest = { workspace = true }
secrets = { workspace = true }
markup5ever_rcdom = "0.2"
+1 -1
View File
@@ -16,7 +16,7 @@ Owns:
Does not own:
- manifest permission policy definition (`manifest`)
- Engine tool-loop semantics (`llm-engine`)
- Engine tool-loop semantics (`agen`)
- Worker lifecycle decisions (`worker`)
- UI presentation (`tui`)
+2 -2
View File
@@ -1,8 +1,8 @@
use std::path::PathBuf;
use std::sync::Arc;
use agen::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
use async_trait::async_trait;
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
use schemars::JsonSchema;
use serde::Deserialize;
use workdir::{CommandHandle, CommandOutputRequest, CommandRequest, WorkdirSessionHandle};
@@ -43,7 +43,7 @@ impl Tool for BashTool {
async fn execute(
&self,
input_json: &str,
ctx: llm_engine::tool::ToolExecutionContext,
ctx: agen::tool::ToolExecutionContext,
) -> Result<ToolOutput, ToolError> {
let params: BashParams = serde_json::from_str(input_json)
.map_err(|error| ToolError::InvalidArgument(format!("invalid Bash input: {error}")))?;
+2 -2
View File
@@ -3,8 +3,8 @@
use std::path::PathBuf;
use std::sync::Arc;
use agen::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
use async_trait::async_trait;
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_engine::tool::ToolExecutionContext,
ctx: agen::tool::ToolExecutionContext,
) -> Result<ToolOutput, ToolError> {
let params: EditParams = serde_json::from_str(input_json)
.map_err(|e| ToolError::InvalidArgument(format!("invalid Edit input: {e}")))?;
+1 -1
View File
@@ -6,7 +6,7 @@
use std::path::PathBuf;
use llm_engine::tool::ToolError;
use agen::tool::ToolError;
#[derive(Debug, thiserror::Error)]
pub enum ToolsError {
+2 -2
View File
@@ -1,7 +1,7 @@
use std::sync::Arc;
use agen::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
use async_trait::async_trait;
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
use schemars::JsonSchema;
use serde::Deserialize;
use workdir::{GlobRequest, WorkdirPath, WorkdirSessionHandle};
@@ -28,7 +28,7 @@ impl Tool for GlobTool {
async fn execute(
&self,
input_json: &str,
_ctx: llm_engine::tool::ToolExecutionContext,
_ctx: agen::tool::ToolExecutionContext,
) -> Result<ToolOutput, ToolError> {
let params: GlobParams = serde_json::from_str(input_json)
.map_err(|error| ToolError::InvalidArgument(format!("invalid Glob input: {error}")))?;
+2 -2
View File
@@ -1,7 +1,7 @@
use std::sync::Arc;
use agen::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
use async_trait::async_trait;
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
use schemars::JsonSchema;
use serde::Deserialize;
use workdir::{GrepOutputMode, GrepRequest, WorkdirPath, WorkdirSessionHandle};
@@ -56,7 +56,7 @@ impl Tool for GrepTool {
async fn execute(
&self,
input_json: &str,
_ctx: llm_engine::tool::ToolExecutionContext,
_ctx: agen::tool::ToolExecutionContext,
) -> Result<ToolOutput, ToolError> {
let params: GrepParams = serde_json::from_str(input_json)
.map_err(|error| ToolError::InvalidArgument(format!("invalid Grep input: {error}")))?;
+3 -3
View File
@@ -38,7 +38,7 @@ pub fn core_builtin_tools(
session: workdir::WorkdirSessionHandle,
tracker: Tracker,
bash_output_dir: std::path::PathBuf,
) -> Vec<llm_engine::tool::ToolDefinition> {
) -> Vec<agen::tool::ToolDefinition> {
use workdir::WorkdirSessionCapability;
let capabilities = session.capabilities();
@@ -66,7 +66,7 @@ pub fn core_builtin_tools(
pub fn read_only_builtin_tools(
session: workdir::WorkdirSessionHandle,
) -> Vec<llm_engine::tool::ToolDefinition> {
) -> Vec<agen::tool::ToolDefinition> {
debug_assert_eq!(
session.capabilities(),
workdir::WorkdirSessionCapabilities::READ_ONLY,
@@ -77,7 +77,7 @@ pub fn read_only_builtin_tools(
pub fn web_builtin_tools(
web_config: Option<manifest::WebConfig>,
) -> Vec<llm_engine::tool::ToolDefinition> {
) -> Vec<agen::tool::ToolDefinition> {
vec![
web_search_tool(web::WebTools::new(web_config.clone())),
web_fetch_tool(web::WebTools::new(web_config)),
+2 -2
View File
@@ -2,8 +2,8 @@
use std::sync::Arc;
use agen::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
use async_trait::async_trait;
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
use serde::Deserialize;
use crate::error::ToolsError;
@@ -40,7 +40,7 @@ impl Tool for ReadTool {
async fn execute(
&self,
input_json: &str,
_ctx: llm_engine::tool::ToolExecutionContext,
_ctx: agen::tool::ToolExecutionContext,
) -> Result<ToolOutput, ToolError> {
let params: ReadParams = serde_json::from_str(input_json)
.map_err(|e| ToolError::InvalidArgument(format!("invalid Read input: {e}")))?;
+1 -1
View File
@@ -45,7 +45,7 @@
use std::collections::{HashMap, VecDeque};
use std::path::{Component, Path, PathBuf};
use llm_engine::tool::ToolExecutionContext;
use agen::tool::ToolExecutionContext;
use std::sync::{Arc, Mutex};
use sha2::{Digest, Sha256};
+3 -3
View File
@@ -2,10 +2,10 @@
use std::sync::Arc;
use async_trait::async_trait;
use llm_engine::tool::{
use agen::tool::{
Attachment, ImageAttachment, Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput,
};
use async_trait::async_trait;
use serde::Deserialize;
use workdir::{ReadRequest, WorkdirPath, WorkdirSessionHandle};
@@ -32,7 +32,7 @@ impl Tool for ViewImageTool {
async fn execute(
&self,
input_json: &str,
_ctx: llm_engine::tool::ToolExecutionContext,
_ctx: agen::tool::ToolExecutionContext,
) -> Result<ToolOutput, ToolError> {
let input: ViewImageParams = serde_json::from_str(input_json).map_err(|error| {
ToolError::InvalidArgument(format!("invalid ViewImage input: {error}"))
+3 -3
View File
@@ -4,9 +4,9 @@ use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use std::sync::Arc;
use std::time::Duration;
use agen::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
use async_trait::async_trait;
use html5ever::tendril::TendrilSink;
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_engine::tool::ToolExecutionContext,
_ctx: agen::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_engine::tool::ToolExecutionContext,
_ctx: agen::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 -4
View File
@@ -3,8 +3,8 @@
use std::path::PathBuf;
use std::sync::Arc;
use agen::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
use async_trait::async_trait;
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
use serde::Deserialize;
use crate::error::ToolsError;
@@ -34,7 +34,7 @@ impl Tool for WriteTool {
async fn execute(
&self,
input_json: &str,
ctx: llm_engine::tool::ToolExecutionContext,
ctx: agen::tool::ToolExecutionContext,
) -> Result<ToolOutput, ToolError> {
let params: WriteParams = serde_json::from_str(input_json)
.map_err(|e| ToolError::InvalidArgument(format!("invalid Write input: {e}")))?;
@@ -244,7 +244,7 @@ mod tests {
#[tokio::test]
async fn write_then_edit_same_file_same_batch_uses_call_order() {
use crate::edit::edit_tool;
use llm_engine::tool::ToolExecutionContext;
use agen::tool::ToolExecutionContext;
let (dir, fs, tracker) = setup();
let file = dir.path().join("ordered.txt");
@@ -279,7 +279,7 @@ mod tests {
#[tokio::test]
async fn failed_same_file_mutation_releases_guard_for_followup() {
use crate::edit::edit_tool;
use llm_engine::tool::ToolExecutionContext;
use agen::tool::ToolExecutionContext;
let (dir, fs, tracker) = setup();
let file = dir.path().join("release.txt");
+2 -2
View File
@@ -2,7 +2,7 @@
use std::sync::Arc;
use llm_engine::tool::{Tool, ToolDefinition};
use agen::tool::{Tool, ToolDefinition};
use manifest::{Permission, Scope, ScopeConfig, ScopeRule};
use serde_json::json;
use tempfile::TempDir;
@@ -10,7 +10,7 @@ use tools::{Tracker, core_builtin_tools};
use workdir::{LocalWorkdirSession, WorkdirSessionHandle};
struct Registry {
entries: Vec<(llm_engine::tool::ToolMeta, Arc<dyn Tool>)>,
entries: Vec<(agen::tool::ToolMeta, Arc<dyn Tool>)>,
}
impl Registry {
+7 -7
View File
@@ -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-engine, so from here we exercise the factories directly — the same
//! agen, 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_engine::tool::{Tool, ToolDefinition, ToolMeta};
use agen::tool::{Tool, ToolDefinition, ToolMeta};
use manifest::{Permission, Scope, ScopeConfig, ScopeRule};
use serde_json::json;
use tempfile::TempDir;
@@ -62,13 +62,13 @@ fn setup() -> (TempDir, TempDir, Registry) {
(dir, spill, reg)
}
async fn call(tool: &Arc<dyn Tool>, input: serde_json::Value) -> llm_engine::tool::ToolOutput {
async fn call(tool: &Arc<dyn Tool>, input: serde_json::Value) -> agen::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_engine::tool::ToolError {
async fn call_err(tool: &Arc<dyn Tool>, input: serde_json::Value) -> agen::tool::ToolError {
tool.execute(&input.to_string(), Default::default())
.await
.expect_err("expected error")
@@ -114,14 +114,14 @@ async fn view_image_reads_scoped_bytes_into_durable_tool_detail() {
let output = call(&tool, json!({ "path": "image.png" })).await;
assert_eq!(output.attachments.len(), 1);
let llm_engine::tool::Attachment::Image(image) = &output.attachments[0];
let agen::tool::Attachment::Image(image) = &output.attachments[0];
assert_eq!(image.mime_type(), "image/png");
assert_eq!(image.data(), png);
let serialized = serde_json::to_string(&output).unwrap();
assert!(!serialized.contains("private-image-body"));
assert!(serialized.contains("attachments"));
let restored: llm_engine::tool::ToolOutput = serde_json::from_str(&serialized).unwrap();
let llm_engine::tool::Attachment::Image(restored_image) = &restored.attachments[0];
let restored: agen::tool::ToolOutput = serde_json::from_str(&serialized).unwrap();
let agen::tool::Attachment::Image(restored_image) = &restored.attachments[0];
assert_eq!(restored_image.data(), png);
let escaped = call_err(&tool, json!({ "path": "../outside.png" })).await;