feat: prepare agen crates for publication
This commit is contained in:
@@ -11,11 +11,9 @@
|
||||
//! `UsageTracker` にも stash しておき、後続の `LlmUsage` と組で
|
||||
//! `prune.post_request` を吐けるようにする。
|
||||
|
||||
use llm_engine::Item;
|
||||
use llm_engine::llm_client::client::LlmClient;
|
||||
use llm_engine::prune::{
|
||||
PruneConfig, PruneDecision, PruneObserver, SavingsEstimator, TokenEstimator,
|
||||
};
|
||||
use agen::Item;
|
||||
use agen::llm_client::client::LlmClient;
|
||||
use agen::prune::{PruneConfig, PruneDecision, PruneObserver, SavingsEstimator, TokenEstimator};
|
||||
use session_metrics::Metric;
|
||||
use session_store::Store;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Compact / prune 専用のトークン会計補助。
|
||||
//!
|
||||
//! 汎用部分(`prefix_bytes`, `tokens_at`, `total_tokens`, `total_tokens_at`)は
|
||||
//! [`llm_engine::token_counter`] にあり、`UsageRecord` の列と現在の history から
|
||||
//! [`agen::token_counter`] にあり、`UsageRecord` の列と現在の history から
|
||||
//! pure に推定する。本モジュールは compact / prune 固有のロジック
|
||||
//! (`split_for_retained`, `savings_for_prune`)と、Worker 上の公開 API に
|
||||
//! 限定する。
|
||||
@@ -17,12 +17,12 @@
|
||||
//! - 推定の出どころは [`EstimateSource`] で呼び出し側に明示する。
|
||||
//! 課金判断には使えないが、compact / prune の閾値判定には十分な精度
|
||||
|
||||
use llm_engine::llm_client::client::LlmClient;
|
||||
use llm_engine::token_counter::{item_bytes, prefix_bytes, tokens_at};
|
||||
use llm_engine::{Item, UsageRecord};
|
||||
use agen::llm_client::client::LlmClient;
|
||||
use agen::token_counter::{item_bytes, prefix_bytes, tokens_at};
|
||||
use agen::{Item, UsageRecord};
|
||||
use session_store::Store;
|
||||
|
||||
pub use llm_engine::token_counter::{EstimateSource, TokenEstimate};
|
||||
pub use agen::token_counter::{EstimateSource, TokenEstimate};
|
||||
|
||||
use crate::Worker;
|
||||
|
||||
@@ -188,7 +188,7 @@ pub(crate) fn token_estimates_for_prune_impl(
|
||||
|
||||
/// Prune 射影(`ToolResult.content = None`)で節約されるトークン数の推定。
|
||||
///
|
||||
/// `indices` は [`llm_engine::prune::prunable_indices`] が返す候補列を
|
||||
/// `indices` は [`agen::prune::prunable_indices`] が返す候補列を
|
||||
/// 想定する。各候補の content バイト差分を合算し、usage 履歴由来の
|
||||
/// tokens/byte レートでトークン数に換算する。範囲を「丸ごと drop」する
|
||||
/// のではなく、item 自体(summary 等)は残したままの値を返す点が
|
||||
@@ -248,7 +248,7 @@ impl<C: LlmClient, St: Store> Worker<C, St> {
|
||||
/// 最後の measurement と、その後に追加された未測定分の byte/4 外挿。
|
||||
pub fn total_tokens(&self) -> TokenEstimate {
|
||||
let usage = self.usage_history();
|
||||
llm_engine::token_counter::total_tokens(self.history(), &usage)
|
||||
agen::token_counter::total_tokens(self.history(), &usage)
|
||||
}
|
||||
|
||||
/// 任意の history index 時点でのプロンプト全長推定。
|
||||
@@ -259,7 +259,7 @@ impl<C: LlmClient, St: Store> Worker<C, St> {
|
||||
/// pointer 以降に増えたプロンプト長を測るのに使う。
|
||||
pub fn total_tokens_at(&self, history_len: usize) -> TokenEstimate {
|
||||
let usage = self.usage_history();
|
||||
llm_engine::token_counter::total_tokens_at(self.history(), &usage, history_len)
|
||||
agen::token_counter::total_tokens_at(self.history(), &usage, history_len)
|
||||
}
|
||||
|
||||
/// 末尾から `retained` トークン以上を残すための分割位置。
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
use std::sync::Mutex;
|
||||
|
||||
use llm_engine::UsageRecord;
|
||||
use llm_engine::timeline::event::UsageEvent;
|
||||
use agen::UsageRecord;
|
||||
use agen::timeline::event::UsageEvent;
|
||||
|
||||
/// One drained measurement: the underlying `UsageRecord` plus an optional
|
||||
/// `correlation_id` stamped by the prune projection (or any other future
|
||||
|
||||
@@ -21,10 +21,10 @@ use std::path::PathBuf;
|
||||
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use agen::Item;
|
||||
use agen::interceptor::{Interceptor, PreRequestAction, PreToolAction, ToolCallInfo};
|
||||
use agen::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput, ToolResult};
|
||||
use async_trait::async_trait;
|
||||
use llm_engine::Item;
|
||||
use llm_engine::interceptor::{Interceptor, PreRequestAction, PreToolAction, ToolCallInfo};
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput, ToolResult};
|
||||
use serde::Deserialize;
|
||||
#[cfg(test)]
|
||||
use workdir::LocalWorkdirSession;
|
||||
@@ -162,7 +162,7 @@ impl Tool for SearchSessionLogTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
_ctx: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: SearchSessionParams = serde_json::from_str(input_json).map_err(|e| {
|
||||
ToolError::InvalidArgument(format!("invalid search_session_log input: {e}"))
|
||||
@@ -243,7 +243,7 @@ impl Tool for ReadSessionItemsTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
_ctx: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: ReadSessionParams = serde_json::from_str(input_json).map_err(|e| {
|
||||
ToolError::InvalidArgument(format!("invalid read_session_items input: {e}"))
|
||||
@@ -343,7 +343,7 @@ impl Tool for MarkReadRequiredTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
_ctx: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: MarkParams = serde_json::from_str(input_json).map_err(|e| {
|
||||
ToolError::InvalidArgument(format!("invalid mark_read_required input: {e}"))
|
||||
@@ -414,7 +414,7 @@ impl Tool for AddReferenceTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
_ctx: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: ReferenceParams = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid add_reference input: {e}")))?;
|
||||
@@ -444,7 +444,7 @@ impl Tool for WriteSummaryTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
_ctx: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: SummaryParams = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid write_summary input: {e}")))?;
|
||||
@@ -603,7 +603,7 @@ impl CompactWorkerInterceptor {
|
||||
impl Interceptor for CompactWorkerInterceptor {
|
||||
async fn pre_llm_request(&self, context: &mut Vec<Item>) -> PreRequestAction {
|
||||
let records = self.usage_tracker.records();
|
||||
let estimate = llm_engine::token_counter::total_tokens(context, &records);
|
||||
let estimate = agen::token_counter::total_tokens(context, &records);
|
||||
if estimate.tokens > self.max_input_tokens {
|
||||
return PreRequestAction::Cancel(format!(
|
||||
"compact worker input occupancy exceeded {} tokens",
|
||||
@@ -653,8 +653,8 @@ mod tests {
|
||||
Arc::new(LocalWorkdirSession::new(scope, tmp.to_path_buf()))
|
||||
}
|
||||
|
||||
fn make_usage(input: u64) -> llm_engine::timeline::event::UsageEvent {
|
||||
llm_engine::timeline::event::UsageEvent {
|
||||
fn make_usage(input: u64) -> agen::timeline::event::UsageEvent {
|
||||
agen::timeline::event::UsageEvent {
|
||||
input_tokens: Some(input),
|
||||
output_tokens: Some(0),
|
||||
total_tokens: Some(input),
|
||||
|
||||
@@ -2,8 +2,8 @@ use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
use llm_engine::EngineError;
|
||||
use llm_engine::llm_client::client::LlmClient;
|
||||
use agen::EngineError;
|
||||
use agen::llm_client::client::LlmClient;
|
||||
use session_store::WorkerMetadataStore;
|
||||
use session_store::{LogEntry, SessionExtension, Store};
|
||||
use tokio::sync::{broadcast, mpsc, oneshot};
|
||||
|
||||
@@ -14,9 +14,9 @@ use std::process::Stdio;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use agen::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use async_trait::async_trait;
|
||||
use client::WorkerRuntimeCommand;
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use manifest::{Permission, ScopeRule};
|
||||
use protocol::stream::JsonLineReader;
|
||||
use protocol::{Event, Method, WorkerStatus};
|
||||
@@ -843,7 +843,7 @@ where
|
||||
async fn execute(
|
||||
&self,
|
||||
_input_json: &str,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
_ctx: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let items = self
|
||||
.discovery
|
||||
@@ -871,7 +871,7 @@ where
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
_ctx: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let input: WorkerNameInput = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid RestoreWorker input: {e}")))?;
|
||||
@@ -949,7 +949,7 @@ where
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
_ctx: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let input: SendToPeerWorkerInput = serde_json::from_str(input_json).map_err(|e| {
|
||||
ToolError::InvalidArgument(format!("invalid SendToPeerWorker input: {e}"))
|
||||
|
||||
@@ -16,10 +16,10 @@ use std::collections::{HashMap, HashSet};
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
|
||||
use llm_engine::Engine;
|
||||
use llm_engine::llm_client::client::LlmClient;
|
||||
use llm_engine::state::Mutable;
|
||||
use llm_engine::tool::ToolDefinition;
|
||||
use agen::Engine;
|
||||
use agen::llm_client::client::LlmClient;
|
||||
use agen::state::Mutable;
|
||||
use agen::tool::ToolDefinition;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use thiserror::Error;
|
||||
|
||||
@@ -1732,10 +1732,10 @@ pub mod plugin;
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use agen::llm_client::{ClientError, Request, ResponseStream};
|
||||
use agen::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use async_trait::async_trait;
|
||||
use futures::stream;
|
||||
use llm_engine::llm_client::{ClientError, Request, ResponseStream};
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use serde_json::json;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
|
||||
@@ -1760,7 +1760,7 @@ mod tests {
|
||||
async fn execute(
|
||||
&self,
|
||||
_input_json: &str,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
_ctx: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
Ok(ToolOutput::from("ok".to_string()))
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@ use std::collections::BTreeSet;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use agen::llm_client::client::LlmClient;
|
||||
use agen::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use async_trait::async_trait;
|
||||
use flow::{
|
||||
ConditionVerdict, FlowTransitionAttempt, FlowTransitionResolution, FlowVerifierOutcome,
|
||||
TransitionConditionResult, TransitionId,
|
||||
};
|
||||
use llm_engine::llm_client::client::LlmClient;
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use manifest::{Scope, WorkerManifest};
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
@@ -199,7 +199,7 @@ impl Tool for RequestFlowTransitionTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_context: llm_engine::tool::ToolExecutionContext,
|
||||
_context: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: RequestFlowTransitionParams =
|
||||
serde_json::from_str(input_json).map_err(|error| {
|
||||
@@ -350,7 +350,7 @@ impl Tool for FinishFlowVerificationTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_context: llm_engine::tool::ToolExecutionContext,
|
||||
_context: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: FinishFlowVerificationParams =
|
||||
serde_json::from_str(input_json).map_err(|error| {
|
||||
@@ -630,16 +630,16 @@ impl FeatureModule for ReadOnlyFlowWorkdirFeature {
|
||||
mod tests {
|
||||
use std::sync::atomic::AtomicUsize;
|
||||
|
||||
use flow::{FlowAttemptStatus, FlowTransitionRejection, StateId, TransitionCheckSnapshot};
|
||||
use futures::stream;
|
||||
use llm_engine::llm_client::client::{LlmClient, ResponseStream};
|
||||
use llm_engine::llm_client::error::ClientError;
|
||||
use llm_engine::llm_client::event::{
|
||||
use agen::llm_client::client::{LlmClient, ResponseStream};
|
||||
use agen::llm_client::error::ClientError;
|
||||
use agen::llm_client::event::{
|
||||
BlockDelta, BlockMetadata, BlockStart, BlockStop, BlockType, DeltaContent,
|
||||
Event as LlmEvent, StopReason,
|
||||
};
|
||||
use llm_engine::llm_client::types::Request;
|
||||
use llm_engine::tool::ToolExecutionContext;
|
||||
use agen::llm_client::types::Request;
|
||||
use agen::tool::ToolExecutionContext;
|
||||
use flow::{FlowAttemptStatus, FlowTransitionRejection, StateId, TransitionCheckSnapshot};
|
||||
use futures::stream;
|
||||
use manifest::WorkerManifest;
|
||||
use protocol::Segment;
|
||||
use session_store::{LogEntry, SegmentId, SessionId, Store};
|
||||
|
||||
@@ -7,10 +7,8 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use agen::tool::{Tool, ToolDefinition, ToolError, ToolExecutionContext, ToolMeta, ToolOutput};
|
||||
use async_trait::async_trait;
|
||||
use llm_engine::tool::{
|
||||
Tool, ToolDefinition, ToolError, ToolExecutionContext, ToolMeta, ToolOutput,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
use workdir::http::{WorkdirSessionOperation, WorkdirSessionOperationResult};
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use agen::tool::{Tool, ToolDefinition, ToolError, ToolExecutionContext, ToolMeta, ToolOutput};
|
||||
use async_trait::async_trait;
|
||||
use llm_engine::tool::{
|
||||
Tool, ToolDefinition, ToolError, ToolExecutionContext, ToolMeta, ToolOutput,
|
||||
};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
@@ -6,10 +6,8 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use agen::tool::{Tool, ToolDefinition, ToolError, ToolExecutionContext, ToolMeta, ToolOutput};
|
||||
use async_trait::async_trait;
|
||||
use llm_engine::tool::{
|
||||
Tool, ToolDefinition, ToolError, ToolExecutionContext, ToolMeta, ToolOutput,
|
||||
};
|
||||
use memory::backend::{
|
||||
MemoryBackendHttpResponse, MemoryBackendOperation, MemoryBackendOperationResult,
|
||||
MemoryConsolidateStagingOperation, MemoryConsolidationOutput, MemoryDocumentReadOperation,
|
||||
@@ -343,7 +341,7 @@ fn query_schema() -> serde_json::Value {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use llm_engine::tool::ToolDefinition;
|
||||
use agen::tool::ToolDefinition;
|
||||
|
||||
fn test_client() -> Arc<dyn WorkspaceClient> {
|
||||
Arc::new(crate::worker::TestWorkspaceHttpClient::new(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use agen::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use async_trait::async_trait;
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use memory::backend::{
|
||||
MemoryBackendOperation, MemoryBackendOperationResult, MemoryStageCandidateOperation,
|
||||
};
|
||||
@@ -163,7 +163,7 @@ impl Tool for StageMemoryCandidateTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_context: llm_engine::tool::ToolExecutionContext,
|
||||
_context: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: StageMemoryCandidateParams =
|
||||
serde_json::from_str(input_json).map_err(|error| {
|
||||
@@ -249,7 +249,7 @@ impl Tool for FinishMemoryExtractionTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_context: llm_engine::tool::ToolExecutionContext,
|
||||
_context: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: FinishMemoryExtractionParams =
|
||||
serde_json::from_str(input_json).map_err(|error| {
|
||||
@@ -387,7 +387,7 @@ fn truncate_line(text: &str, max_chars: usize) -> String {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use llm_engine::Item;
|
||||
use agen::Item;
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -451,7 +451,7 @@ mod tests {
|
||||
let error = tool
|
||||
.execute(
|
||||
r#"{"kind":"decision","claim":"claim","why_useful":"useful","entry_refs":["E00000009"]}"#,
|
||||
llm_engine::tool::ToolExecutionContext::direct(),
|
||||
agen::tool::ToolExecutionContext::direct(),
|
||||
)
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
@@ -4,8 +4,8 @@ use crate::feature::{
|
||||
ToolDeclaration, ToolDefinition,
|
||||
};
|
||||
use crate::worker::{WorkspaceClient, WorkspaceRequest, WorkspaceRequestMethod};
|
||||
use agen::tool::{Tool, ToolError, ToolExecutionContext, ToolMeta, ToolOutput};
|
||||
use async_trait::async_trait;
|
||||
use llm_engine::tool::{Tool, ToolError, ToolExecutionContext, ToolMeta, ToolOutput};
|
||||
use manifest::MergeRequestFeatureConfig;
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
|
||||
@@ -7,10 +7,8 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use agen::tool::{Tool, ToolDefinition, ToolError, ToolExecutionContext, ToolMeta, ToolOutput};
|
||||
use async_trait::async_trait;
|
||||
use llm_engine::tool::{
|
||||
Tool, ToolDefinition, ToolError, ToolExecutionContext, ToolMeta, ToolOutput,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
|
||||
@@ -611,7 +609,7 @@ struct ObjectiveDetail {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use llm_engine::tool::ToolDefinition;
|
||||
use agen::tool::ToolDefinition;
|
||||
|
||||
fn tool_names(definitions: Vec<ToolDefinition>) -> Vec<String> {
|
||||
let mut names = definitions
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use agen::tool::{Tool, ToolDefinition, ToolError, ToolExecutionContext, ToolMeta, ToolOutput};
|
||||
use async_trait::async_trait;
|
||||
use llm_engine::tool::{
|
||||
Tool, ToolDefinition, ToolError, ToolExecutionContext, ToolMeta, ToolOutput,
|
||||
};
|
||||
use protocol::Segment;
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -181,7 +181,7 @@ impl Tool for ShowOverviewTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_context: llm_engine::tool::ToolExecutionContext,
|
||||
_context: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: ShowOverviewParams = parse_input("ShowOverview", input_json)?;
|
||||
let limit = bounded_limit(params.limit, DEFAULT_PAGE_LIMIT, MAX_PAGE_LIMIT);
|
||||
@@ -223,7 +223,7 @@ impl Tool for SearchEntriesTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_context: llm_engine::tool::ToolExecutionContext,
|
||||
_context: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: SearchEntriesParams = parse_input("SearchEntries", input_json)?;
|
||||
let kind = params.kind.as_deref().map(parse_kind).transpose()?;
|
||||
@@ -286,7 +286,7 @@ impl Tool for ReadEntryTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_context: llm_engine::tool::ToolExecutionContext,
|
||||
_context: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: ReadEntryParams = parse_input("ReadEntry", input_json)?;
|
||||
let entry_ref = parse_entry_ref(¶ms.entry_ref)?;
|
||||
@@ -390,7 +390,7 @@ fn json_output(summary: String, value: serde_json::Value) -> Result<ToolOutput,
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use llm_engine::Item;
|
||||
use agen::Item;
|
||||
|
||||
use crate::feature::{FeatureRegistryBuilder, HookRegistryBuilder};
|
||||
|
||||
@@ -426,7 +426,7 @@ mod tests {
|
||||
async fn overview_uses_real_entry_refs_and_rejects_unknown_fields() {
|
||||
let tool = show_overview_definition(state())().1;
|
||||
let output = tool
|
||||
.execute("{}", llm_engine::tool::ToolExecutionContext::direct())
|
||||
.execute("{}", agen::tool::ToolExecutionContext::direct())
|
||||
.await
|
||||
.unwrap();
|
||||
let content = output.content.unwrap();
|
||||
@@ -438,7 +438,7 @@ mod tests {
|
||||
let error = tool
|
||||
.execute(
|
||||
r#"{"unexpected":true}"#,
|
||||
llm_engine::tool::ToolExecutionContext::direct(),
|
||||
agen::tool::ToolExecutionContext::direct(),
|
||||
)
|
||||
.await
|
||||
.unwrap_err();
|
||||
@@ -451,7 +451,7 @@ mod tests {
|
||||
let output = search
|
||||
.execute(
|
||||
r#"{"from":"E00000003","through":"E00000003"}"#,
|
||||
llm_engine::tool::ToolExecutionContext::direct(),
|
||||
agen::tool::ToolExecutionContext::direct(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
@@ -463,7 +463,7 @@ mod tests {
|
||||
let output = read
|
||||
.execute(
|
||||
r#"{"entry_ref":"E00000003"}"#,
|
||||
llm_engine::tool::ToolExecutionContext::direct(),
|
||||
agen::tool::ToolExecutionContext::direct(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
|
||||
use agen::Item;
|
||||
use async_trait::async_trait;
|
||||
use llm_engine::Item;
|
||||
|
||||
mod store;
|
||||
mod tool_impl;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use llm_engine::Item;
|
||||
use agen::Item;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)]
|
||||
|
||||
@@ -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 super::store::{DEFAULT_TASK_LIST_LIMIT, TaskEntry, TaskStatus, TaskStore, snapshot_overview};
|
||||
@@ -83,7 +83,7 @@ impl Tool for TaskCreateTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
_ctx: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: TaskCreateParams = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid TaskCreate input: {e}")))?;
|
||||
@@ -106,7 +106,7 @@ impl Tool for TaskListTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
_ctx: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: TaskListParams = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid TaskList input: {e}")))?;
|
||||
@@ -127,7 +127,7 @@ impl Tool for TaskGetTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
_ctx: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: TaskGetParams = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid TaskGet input: {e}")))?;
|
||||
@@ -149,7 +149,7 @@ impl Tool for TaskUpdateTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
_ctx: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: TaskUpdateParams = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid TaskUpdate input: {e}")))?;
|
||||
|
||||
@@ -31,7 +31,7 @@ use crate::feature::{
|
||||
ToolDefinition,
|
||||
};
|
||||
use crate::worker::{WorkspaceClient, WorkspaceRequest, WorkspaceRequestMethod};
|
||||
use llm_engine::tool::{Tool, ToolError, ToolExecutionContext, ToolMeta, ToolOutput};
|
||||
use agen::tool::{Tool, ToolError, ToolExecutionContext, ToolMeta, ToolOutput};
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
enum WorkspaceTicketReadKind {
|
||||
@@ -1230,7 +1230,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn pending_tool_description(
|
||||
pending_tools: &[llm_engine::tool::ToolDefinition],
|
||||
pending_tools: &[agen::tool::ToolDefinition],
|
||||
name: &str,
|
||||
) -> String {
|
||||
pending_tools
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use agen::Item;
|
||||
use agen::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use async_trait::async_trait;
|
||||
use llm_engine::Item;
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use session_store::collect_state;
|
||||
@@ -495,7 +495,7 @@ impl Tool for ViewSessionOverviewTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_context: llm_engine::tool::ToolExecutionContext,
|
||||
_context: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: ViewSessionOverviewParams = parse_input("ViewSessionOverview", input_json)?;
|
||||
let view = latest_view(&*self.provider, ¶ms.subject).await?;
|
||||
@@ -540,7 +540,7 @@ impl Tool for SearchSessionEntriesTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_context: llm_engine::tool::ToolExecutionContext,
|
||||
_context: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: SearchSessionEntriesParams = parse_input("SearchSessionEntries", input_json)?;
|
||||
let view = latest_view(&*self.provider, ¶ms.subject).await?;
|
||||
@@ -598,7 +598,7 @@ impl Tool for ReadSessionEntryTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_context: llm_engine::tool::ToolExecutionContext,
|
||||
_context: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: ReadSessionEntryParams = parse_input("ReadSessionEntry", input_json)?;
|
||||
let entry_ref = parse_entry_ref(¶ms.entry_ref)?;
|
||||
@@ -714,7 +714,7 @@ fn json_output(summary: String, value: serde_json::Value) -> Result<ToolOutput,
|
||||
mod tests {
|
||||
use std::sync::Mutex;
|
||||
|
||||
use llm_engine::Role;
|
||||
use agen::Role;
|
||||
|
||||
use crate::feature::{FeatureRegistryBuilder, HookRegistryBuilder};
|
||||
|
||||
@@ -797,7 +797,7 @@ mod tests {
|
||||
let hidden = read
|
||||
.execute(
|
||||
r#"{"subject":{"kind":"runtime_worker","runtime_id":"runtime-1","worker_id":"unauthorized"},"entry_ref":"E00000000"}"#,
|
||||
llm_engine::tool::ToolExecutionContext::direct(),
|
||||
agen::tool::ToolExecutionContext::direct(),
|
||||
)
|
||||
.await
|
||||
.unwrap_err();
|
||||
@@ -811,7 +811,7 @@ mod tests {
|
||||
let output = read
|
||||
.execute(
|
||||
r#"{"subject":{"kind":"runtime_worker","runtime_id":"runtime-1","worker_id":"granted"},"entry_ref":"E00000000"}"#,
|
||||
llm_engine::tool::ToolExecutionContext::direct(),
|
||||
agen::tool::ToolExecutionContext::direct(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
@@ -820,7 +820,7 @@ mod tests {
|
||||
let output = read
|
||||
.execute(
|
||||
r#"{"subject":{"kind":"runtime_worker","runtime_id":"runtime-1","worker_id":"granted"},"entry_ref":"E00000001"}"#,
|
||||
llm_engine::tool::ToolExecutionContext::direct(),
|
||||
agen::tool::ToolExecutionContext::direct(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@@ -2,10 +2,10 @@ use std::collections::BTreeMap;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use llm_engine::tool::{
|
||||
use agen::tool::{
|
||||
Tool, ToolDefinition, ToolError, ToolExecutionContext, ToolMeta, ToolOrigin, ToolOutput,
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use manifest::McpConfig;
|
||||
use mcp::stdio::{
|
||||
CallToolRequest, CallToolResult, GetPromptRequest, GetPromptResult, ListPromptsResult,
|
||||
|
||||
@@ -18,11 +18,11 @@ use std::sync::{
|
||||
};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use futures_util::{SinkExt, StreamExt};
|
||||
use llm_engine::tool::{
|
||||
use agen::tool::{
|
||||
Tool, ToolDefinition, ToolError, ToolExecutionContext, ToolMeta, ToolOrigin, ToolOutput,
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use futures_util::{SinkExt, StreamExt};
|
||||
use manifest::plugin::{
|
||||
PLUGIN_COMPONENT_INSTANCE_WORLD, PLUGIN_COMPONENT_TOOL_WORLD, PLUGIN_RUNTIME_COMPONENT_KIND,
|
||||
PluginConfig, PluginDiscoveryLimits, PluginFsGrant, PluginFsOperation, PluginHostApi,
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use llm_engine::Item;
|
||||
use agen::Item;
|
||||
use tools::ToolsError;
|
||||
use tracing::warn;
|
||||
#[cfg(test)]
|
||||
@@ -282,7 +282,7 @@ fn format_range(offset: Option<usize>, limit: Option<usize>) -> String {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use llm_engine::ContentPart;
|
||||
use agen::ContentPart;
|
||||
use manifest::{Permission, Scope, ScopeConfig, ScopeRule};
|
||||
use std::sync::Arc;
|
||||
use tempfile::TempDir;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
//! Hooks intentionally cannot mutate the Engine's context, history, tool
|
||||
//! call, or tool result. Internal mechanisms that need such access (e.g.
|
||||
//! compaction, notification injection, output truncation) implement
|
||||
//! `llm_engine::Interceptor` directly inside Worker, never via this trait.
|
||||
//! `agen::Interceptor` directly inside Worker, never via this trait.
|
||||
//!
|
||||
//! This separation lets Hooks be exposed safely to user-facing
|
||||
//! extension surfaces (scripting, plugins) in the future without
|
||||
@@ -18,11 +18,11 @@
|
||||
use std::ops::Deref;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use llm_engine::interceptor::{
|
||||
use agen::interceptor::{
|
||||
PostToolAction, PreRequestAction, PreToolAction, PromptAction, TurnEndAction,
|
||||
};
|
||||
use llm_engine::tool::{ToolOutput, ToolResult};
|
||||
use agen::tool::{ToolOutput, ToolResult};
|
||||
use async_trait::async_trait;
|
||||
use serde_json::Value;
|
||||
use session_store::{SystemItem, SystemReminder};
|
||||
|
||||
@@ -163,7 +163,7 @@ impl From<HookTurnEndAction> for TurnEndAction {
|
||||
/// event-specific context. The handle queues typed requests; the host drains the
|
||||
/// queue, commits each entry through `LogEntry::SystemItem`, and only then makes
|
||||
/// the matching system message visible to the model. It deliberately exposes no
|
||||
/// raw `llm_engine::Item`, history writer, event sender, `Worker`, `Engine`, or
|
||||
/// raw `agen::Item`, history writer, event sender, `Worker`, `Engine`, or
|
||||
/// notification buffer.
|
||||
pub struct SystemItemAppendHandle {
|
||||
pending: Arc<Mutex<Vec<SystemItem>>>,
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use llm_engine::timeline::event::UsageEvent;
|
||||
use llm_engine::{Engine, llm_client::LlmClient};
|
||||
use agen::timeline::event::UsageEvent;
|
||||
use agen::{Engine, llm_client::LlmClient};
|
||||
use manifest::{Scope, WorkerManifest};
|
||||
use protocol::{Event, InFlightSnapshot, WorkerStatus};
|
||||
use session_store::{LogEntry, SegmentId, SessionId, Store, StoreError, TraceEntry};
|
||||
@@ -954,10 +954,10 @@ mod tests {
|
||||
use std::pin::Pin;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
|
||||
use agen::llm_client::event::{Event as LlmEvent, ResponseStatus, StatusEvent};
|
||||
use agen::llm_client::{ClientError, Request};
|
||||
use async_trait::async_trait;
|
||||
use futures::Stream;
|
||||
use llm_engine::llm_client::event::{Event as LlmEvent, ResponseStatus, StatusEvent};
|
||||
use llm_engine::llm_client::{ClientError, Request};
|
||||
|
||||
use super::*;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#[cfg(test)]
|
||||
use crate::prompt::catalog::PromptCatalog;
|
||||
use llm_engine::Item;
|
||||
use agen::Item;
|
||||
|
||||
/// Build synthetic `Item::ToolResult` items for every unanswered
|
||||
/// `Item::ToolCall` in `history`, preserving order.
|
||||
|
||||
@@ -11,15 +11,15 @@ use std::borrow::Cow;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use arc_swap::ArcSwap;
|
||||
use async_trait::async_trait;
|
||||
use llm_engine::Item;
|
||||
use llm_engine::UsageRecord;
|
||||
use llm_engine::interceptor::{
|
||||
use agen::Item;
|
||||
use agen::UsageRecord;
|
||||
use agen::interceptor::{
|
||||
Interceptor, PostToolAction, PreRequestAction, PreToolAction, PromptAction, ToolCallInfo,
|
||||
ToolResultInfo, TurnEndAction,
|
||||
};
|
||||
use llm_engine::tool::ToolOutput;
|
||||
use agen::tool::ToolOutput;
|
||||
use arc_swap::ArcSwap;
|
||||
use async_trait::async_trait;
|
||||
use tracing::info;
|
||||
|
||||
use crate::compact::state::CompactState;
|
||||
@@ -34,7 +34,7 @@ use crate::hook::{
|
||||
use crate::ipc::notify_buffer::{NotifyBuffer, build_system_item_with_provenance};
|
||||
use crate::prompt::catalog::PromptCatalog;
|
||||
use crate::worker::SystemItemCommitter;
|
||||
use llm_engine::token_counter::total_tokens;
|
||||
use agen::token_counter::total_tokens;
|
||||
|
||||
/// Maximum number of bytes copied into `TurnEndInfo::final_text_preview`.
|
||||
const FINAL_TEXT_PREVIEW_LIMIT: usize = 512;
|
||||
@@ -544,14 +544,14 @@ mod tests {
|
||||
.expect("task tool definition");
|
||||
let (meta, tool) = def();
|
||||
ToolCallInfo {
|
||||
call: llm_engine::tool::ToolCall {
|
||||
call: agen::tool::ToolCall {
|
||||
id: "call-id".into(),
|
||||
name: name.into(),
|
||||
input,
|
||||
},
|
||||
meta,
|
||||
tool,
|
||||
context: llm_engine::tool::ToolExecutionContext::new("call-id", "test-batch", 0),
|
||||
context: agen::tool::ToolExecutionContext::new("call-id", "test-batch", 0),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -637,7 +637,7 @@ mod tests {
|
||||
let history = usage_handle_with(ctx_items.len(), 50);
|
||||
let usage_tracker = Arc::new(UsageTracker::new());
|
||||
usage_tracker.note_request(ctx_items.len());
|
||||
usage_tracker.record_usage(&llm_engine::event::UsageEvent {
|
||||
usage_tracker.record_usage(&agen::event::UsageEvent {
|
||||
input_tokens: Some(150),
|
||||
output_tokens: Some(0),
|
||||
total_tokens: Some(150),
|
||||
@@ -701,7 +701,7 @@ mod tests {
|
||||
cache_write_tokens: 0,
|
||||
output_tokens: 0,
|
||||
};
|
||||
let prefix = llm_engine::token_counter::prefix_bytes(&ctx_items);
|
||||
let prefix = agen::token_counter::prefix_bytes(&ctx_items);
|
||||
let delta_bytes = prefix[2].saturating_sub(prefix[1]);
|
||||
let old_projection =
|
||||
11_124 + (delta_bytes as u128 * 11_124_u128 / prefix[1] as u128) as u64;
|
||||
@@ -808,7 +808,7 @@ mod tests {
|
||||
assert!(matches!(
|
||||
&items[0],
|
||||
Item::Message {
|
||||
role: llm_engine::Role::System,
|
||||
role: agen::Role::System,
|
||||
..
|
||||
}
|
||||
));
|
||||
@@ -950,7 +950,7 @@ mod tests {
|
||||
let info = task_tool_call_info("TaskList", serde_json::json!({}));
|
||||
let mut result_info = ToolResultInfo {
|
||||
call: info.call,
|
||||
result: llm_engine::tool::ToolResult::from_output(
|
||||
result: agen::tool::ToolResult::from_output(
|
||||
"call-id",
|
||||
ToolOutput {
|
||||
summary: "ok".into(),
|
||||
@@ -1039,7 +1039,7 @@ mod tests {
|
||||
let mut ctx = ctx_items.clone();
|
||||
let action = interceptor.pre_llm_request(&mut ctx).await;
|
||||
assert!(matches!(action, PreRequestAction::Continue));
|
||||
usage_tracker.record_usage(&llm_engine::event::UsageEvent {
|
||||
usage_tracker.record_usage(&agen::event::UsageEvent {
|
||||
input_tokens: Some(10),
|
||||
output_tokens: Some(0),
|
||||
total_tokens: Some(10),
|
||||
@@ -1055,7 +1055,7 @@ mod tests {
|
||||
other => panic!("expected reminder append, got {other:?}"),
|
||||
};
|
||||
assert_eq!(appended_len, 1);
|
||||
usage_tracker.record_usage(&llm_engine::event::UsageEvent {
|
||||
usage_tracker.record_usage(&agen::event::UsageEvent {
|
||||
input_tokens: Some(11),
|
||||
output_tokens: Some(0),
|
||||
total_tokens: Some(11),
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
//! default_capability > scheme 既定 の順でフォールバック(上位 3 段は
|
||||
//! `catalog::resolve_model_manifest` が [`ModelConfig`] に詰め込む)
|
||||
//!
|
||||
//! llm-engine は低レベル基盤に留める方針なので、高レベル側で必要に
|
||||
//! agen は低レベル基盤に留める方針なので、高レベル側で必要に
|
||||
//! なる認証ストア解決と secret store 解決は worker 側で行う。
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use llm_engine::llm_client::{
|
||||
use agen::llm_client::{
|
||||
LlmClient,
|
||||
capability::ModelCapability,
|
||||
scheme::{
|
||||
@@ -23,7 +23,7 @@ use llm_engine::llm_client::{
|
||||
},
|
||||
transport::{HttpTransport, ResolvedAuth, TransportPolicy},
|
||||
};
|
||||
use llm_engine::providers::codex::CodexAuthProvider;
|
||||
use agen::providers::codex::CodexAuthProvider;
|
||||
|
||||
use manifest::{AuthRef, ModelManifest, SchemeKind, model_catalog as catalog};
|
||||
use secrets::{SecretStore, SecretValue};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use agen::llm_client::client::LlmClient;
|
||||
use async_trait::async_trait;
|
||||
use llm_engine::llm_client::client::LlmClient;
|
||||
use manifest::{ToolPermissionAction, ToolPermissionConfig};
|
||||
use serde_json::Value;
|
||||
use session_store::Store;
|
||||
|
||||
@@ -227,7 +227,7 @@ impl Default for SegmentLogSink {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use llm_engine::llm_client::RequestConfig;
|
||||
use agen::llm_client::RequestConfig;
|
||||
use session_store::segment_log::now_millis;
|
||||
|
||||
fn session_start() -> LogEntry {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use llm_engine::{Item, Role};
|
||||
use agen::{Item, Role};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
const DEFAULT_SEARCH_LIMIT: usize = 20;
|
||||
@@ -661,11 +661,8 @@ mod tests {
|
||||
"attached",
|
||||
None,
|
||||
false,
|
||||
vec![llm_engine::tool::Attachment::Image(
|
||||
llm_engine::tool::ImageAttachment::new(
|
||||
"image/png",
|
||||
b"private-image-body".to_vec(),
|
||||
),
|
||||
vec![agen::tool::Attachment::Image(
|
||||
agen::tool::ImageAttachment::new("image/png", b"private-image-body".to_vec()),
|
||||
)],
|
||||
)],
|
||||
);
|
||||
|
||||
@@ -79,7 +79,7 @@ impl Hook<PostToolCall> for TicketIntakeReadyShutdownHook {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use llm_engine::tool::ToolOutput;
|
||||
use agen::tool::ToolOutput;
|
||||
|
||||
fn tool_result(name: &str, is_error: bool) -> ToolResultSummary {
|
||||
ToolResultSummary {
|
||||
|
||||
@@ -12,8 +12,8 @@ use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use agen::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use async_trait::async_trait;
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use protocol::stream::{JsonLineReader, JsonLineWriter};
|
||||
use protocol::{Event, Method};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -53,7 +53,7 @@ impl Tool for SubWorkerListTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
_ctx: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let _input: SubWorkerListInput = serde_json::from_str(input_json).map_err(|error| {
|
||||
ToolError::InvalidArgument(format!("invalid SubWorkerList input: {error}"))
|
||||
@@ -118,7 +118,7 @@ impl Tool for SubWorkerSendTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
_ctx: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let input: SubWorkerSendInput = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid SubWorkerSend input: {e}")))?;
|
||||
@@ -166,7 +166,7 @@ impl Tool for SubWorkerStopTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
_ctx: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let input: NameInput = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid SubWorkerStop input: {e}")))?;
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
|
||||
use agen::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use arc_swap::ArcSwap;
|
||||
use async_trait::async_trait;
|
||||
use fs_operation::FsPath;
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use manifest::{
|
||||
CompactionConfigPartial, EngineManifestConfig, FileUploadLimitsPartial,
|
||||
PermissionConfigPartial, ProfileDiscovery, ProfileError, ProfileRegistry,
|
||||
@@ -277,12 +277,12 @@ pub struct SubWorkerSpawnTool {
|
||||
prompt_loader: PromptCatalogSource,
|
||||
/// Compact selector list shared by tool description and diagnostics.
|
||||
available_profiles: AvailableProfiles,
|
||||
internal_client_override: Option<Box<dyn llm_engine::llm_client::LlmClient>>,
|
||||
internal_client_override: Option<Box<dyn agen::llm_client::LlmClient>>,
|
||||
}
|
||||
|
||||
impl SubWorkerSpawnTool {
|
||||
#[cfg(test)]
|
||||
fn with_internal_client(mut self, client: Box<dyn llm_engine::llm_client::LlmClient>) -> Self {
|
||||
fn with_internal_client(mut self, client: Box<dyn agen::llm_client::LlmClient>) -> Self {
|
||||
self.internal_client_override = Some(client);
|
||||
self
|
||||
}
|
||||
@@ -346,7 +346,7 @@ impl Tool for SubWorkerSpawnTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
_ctx: agen::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let input: SubWorkerSpawnInput = serde_json::from_str(input_json).map_err(|e| {
|
||||
ToolError::InvalidArgument(format!("invalid SubWorkerSpawn input: {e}"))
|
||||
@@ -452,7 +452,7 @@ impl Tool for SubWorkerSpawnTool {
|
||||
};
|
||||
let store = EphemeralSessionStore::default();
|
||||
let filesystem_authority = WorkerFilesystemAuthority::None;
|
||||
let mut child = Worker::<Box<dyn llm_engine::llm_client::LlmClient>, EphemeralSessionStore>::from_internal_manifest_with_context(
|
||||
let mut child = Worker::<Box<dyn agen::llm_client::LlmClient>, EphemeralSessionStore>::from_internal_manifest_with_context(
|
||||
child_manifest,
|
||||
store.clone(),
|
||||
self.prompt_loader.clone(),
|
||||
@@ -956,12 +956,12 @@ mod tests {
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::WorkspaceId;
|
||||
use agen::llm_client::event::{Event as LlmEvent, ResponseStatus, StatusEvent};
|
||||
use agen::llm_client::types::ContentPart;
|
||||
use agen::llm_client::{ClientError, LlmClient, Request};
|
||||
use agen::{Item, Role};
|
||||
use async_trait::async_trait;
|
||||
use futures::Stream;
|
||||
use llm_engine::llm_client::event::{Event as LlmEvent, ResponseStatus, StatusEvent};
|
||||
use llm_engine::llm_client::types::ContentPart;
|
||||
use llm_engine::llm_client::{ClientError, LlmClient, Request};
|
||||
use llm_engine::{Item, Role};
|
||||
use manifest::{AuthRef, ModelManifest, SchemeKind, WorkerManifest};
|
||||
use tempfile::TempDir;
|
||||
|
||||
@@ -1152,7 +1152,7 @@ extract_threshold = 4000
|
||||
serde_json::json!(runtime.path().join("outside-parent-scope"));
|
||||
tool.execute(
|
||||
&serde_json::to_string(&invalid_input).unwrap(),
|
||||
llm_engine::tool::ToolExecutionContext::direct(),
|
||||
agen::tool::ToolExecutionContext::direct(),
|
||||
)
|
||||
.await
|
||||
.expect_err("invalid delegation must fail before child preparation");
|
||||
@@ -1162,7 +1162,7 @@ extract_threshold = 4000
|
||||
let output = tool
|
||||
.execute(
|
||||
&serde_json::to_string(&input).unwrap(),
|
||||
llm_engine::tool::ToolExecutionContext::direct(),
|
||||
agen::tool::ToolExecutionContext::direct(),
|
||||
)
|
||||
.await
|
||||
.expect("spawn project reviewer as Internal Worker");
|
||||
@@ -1208,7 +1208,7 @@ extract_threshold = 4000
|
||||
let duplicate_error = tool
|
||||
.execute(
|
||||
&serde_json::to_string(&input).unwrap(),
|
||||
llm_engine::tool::ToolExecutionContext::direct(),
|
||||
agen::tool::ToolExecutionContext::direct(),
|
||||
)
|
||||
.await
|
||||
.expect_err("duplicate child name must be rejected before a first turn starts");
|
||||
@@ -1226,7 +1226,7 @@ extract_threshold = 4000
|
||||
Err(tokio::sync::mpsc::error::TryRecvError::Empty)
|
||||
));
|
||||
|
||||
let context = llm_engine::tool::ToolExecutionContext::direct();
|
||||
let context = agen::tool::ToolExecutionContext::direct();
|
||||
let list = (crate::spawn::comm_tools::sub_worker_list_tool(registry.clone()))().1;
|
||||
let listed = list.execute("{}", context.clone()).await.unwrap();
|
||||
assert!(
|
||||
@@ -1308,7 +1308,7 @@ extract_threshold = 4000
|
||||
teardown_input["name"] = serde_json::json!("reviewer-child-parent-drop");
|
||||
tool.execute(
|
||||
&serde_json::to_string(&teardown_input).unwrap(),
|
||||
llm_engine::tool::ToolExecutionContext::direct(),
|
||||
agen::tool::ToolExecutionContext::direct(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
+24
-26
@@ -5,13 +5,13 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Duration;
|
||||
|
||||
use agen::Item;
|
||||
use agen::llm_client::RequestConfig;
|
||||
use agen::llm_client::client::LlmClient;
|
||||
use agen::llm_client::types::Role;
|
||||
use agen::state::Mutable;
|
||||
use agen::{Engine, EngineError, EngineResult, ToolOutputLimits, UsageRecord};
|
||||
use arc_swap::ArcSwap;
|
||||
use llm_engine::Item;
|
||||
use llm_engine::llm_client::RequestConfig;
|
||||
use llm_engine::llm_client::client::LlmClient;
|
||||
use llm_engine::llm_client::types::Role;
|
||||
use llm_engine::state::Mutable;
|
||||
use llm_engine::{Engine, EngineError, EngineResult, ToolOutputLimits, UsageRecord};
|
||||
use session_store::{
|
||||
LogEntry, PromptRenderProvenance, SegmentId, SessionExtension, SessionId, Store, StoreError,
|
||||
SystemItem, segment_log, to_logged,
|
||||
@@ -1191,7 +1191,7 @@ impl<C: LlmClient + Clone + 'static, St: Store + Clone + 'static> Worker<C, St>
|
||||
if matches!(
|
||||
item,
|
||||
Item::Message {
|
||||
role: llm_engine::Role::System,
|
||||
role: agen::Role::System,
|
||||
..
|
||||
}
|
||||
) {
|
||||
@@ -1543,7 +1543,7 @@ impl<C: LlmClient, St: Store> Worker<C, St> {
|
||||
},
|
||||
})?;
|
||||
self.engine_mut()
|
||||
.append_history(std::iter::once(llm_engine::Item::system_message(body)))?;
|
||||
.append_history(std::iter::once(agen::Item::system_message(body)))?;
|
||||
Ok(activation)
|
||||
}
|
||||
|
||||
@@ -2673,9 +2673,7 @@ impl<C: LlmClient, St: Store> Worker<C, St> {
|
||||
},
|
||||
})?;
|
||||
self.engine_mut()
|
||||
.append_history(std::iter::once(llm_engine::Item::system_message(
|
||||
system_note,
|
||||
)))?;
|
||||
.append_history(std::iter::once(agen::Item::system_message(system_note)))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -3173,7 +3171,7 @@ impl<C: LlmClient, St: Store> Worker<C, St> {
|
||||
if matches!(
|
||||
item,
|
||||
Item::Message {
|
||||
role: llm_engine::Role::System,
|
||||
role: agen::Role::System,
|
||||
..
|
||||
}
|
||||
) {
|
||||
@@ -3582,7 +3580,7 @@ impl<C: LlmClient, St: Store> Worker<C, St> {
|
||||
self.task_feature.snapshot_overview(),
|
||||
task_snapshot_text.clone(),
|
||||
));
|
||||
let result_estimate = llm_engine::token_counter::total_tokens(&new_history, &[]);
|
||||
let result_estimate = agen::token_counter::total_tokens(&new_history, &[]);
|
||||
if result_context_max_tokens > 0 && result_estimate.tokens > result_context_max_tokens {
|
||||
return Err(WorkerError::CompactResultContextTooLarge {
|
||||
tokens: result_estimate.tokens,
|
||||
@@ -4296,7 +4294,7 @@ fn lifecycle_status_for_worker_error(err: &WorkerError) -> memory::audit::Worker
|
||||
}
|
||||
|
||||
fn usage_audit_from_event(
|
||||
event: &llm_engine::llm_client::event::UsageEvent,
|
||||
event: &agen::llm_client::event::UsageEvent,
|
||||
) -> memory::audit::UsageAudit {
|
||||
memory::audit::UsageAudit {
|
||||
input_tokens: event.input_tokens,
|
||||
@@ -5024,7 +5022,7 @@ where
|
||||
let anchored_on_summary = matches!(
|
||||
state.history.first(),
|
||||
Some(Item::Message {
|
||||
role: llm_engine::Role::System,
|
||||
role: agen::Role::System,
|
||||
..
|
||||
})
|
||||
);
|
||||
@@ -5520,9 +5518,9 @@ fn message_overview_entry(idx: usize, item: &Item, max_chars: usize) -> Option<S
|
||||
return None;
|
||||
};
|
||||
let role_label = match role {
|
||||
llm_engine::Role::User => "User",
|
||||
llm_engine::Role::Assistant => "Assistant",
|
||||
llm_engine::Role::System => "System",
|
||||
agen::Role::User => "User",
|
||||
agen::Role::Assistant => "Assistant",
|
||||
agen::Role::System => "System",
|
||||
};
|
||||
let text: String = content
|
||||
.iter()
|
||||
@@ -6625,19 +6623,19 @@ mod build_summary_prompt_tests {
|
||||
impl LlmClient for CancelBeforeAiExtractClient {
|
||||
async fn stream(
|
||||
&self,
|
||||
_request: llm_engine::llm_client::Request,
|
||||
_request: agen::llm_client::Request,
|
||||
) -> Result<
|
||||
std::pin::Pin<
|
||||
Box<
|
||||
dyn futures::Stream<
|
||||
Item = Result<
|
||||
llm_engine::llm_client::event::Event,
|
||||
llm_engine::llm_client::ClientError,
|
||||
agen::llm_client::event::Event,
|
||||
agen::llm_client::ClientError,
|
||||
>,
|
||||
> + Send,
|
||||
>,
|
||||
>,
|
||||
llm_engine::llm_client::ClientError,
|
||||
agen::llm_client::ClientError,
|
||||
> {
|
||||
let tx = self
|
||||
.cancel_tx
|
||||
@@ -6779,19 +6777,19 @@ mod build_summary_prompt_tests {
|
||||
impl LlmClient for NoopClient {
|
||||
async fn stream(
|
||||
&self,
|
||||
_request: llm_engine::llm_client::Request,
|
||||
_request: agen::llm_client::Request,
|
||||
) -> Result<
|
||||
std::pin::Pin<
|
||||
Box<
|
||||
dyn futures::Stream<
|
||||
Item = Result<
|
||||
llm_engine::llm_client::event::Event,
|
||||
llm_engine::llm_client::ClientError,
|
||||
agen::llm_client::event::Event,
|
||||
agen::llm_client::ClientError,
|
||||
>,
|
||||
> + Send,
|
||||
>,
|
||||
>,
|
||||
llm_engine::llm_client::ClientError,
|
||||
agen::llm_client::ClientError,
|
||||
> {
|
||||
Ok(Box::pin(futures::stream::empty()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user