diff --git a/Cargo.lock b/Cargo.lock index 841114d3..38ebe4e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2242,7 +2242,7 @@ dependencies = [ [[package]] name = "harness-gateway-client" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=c581ba338e39fe84b98a7200bd56c2cf147c7d59#c581ba338e39fe84b98a7200bd56c2cf147c7d59" +source = "git+https://github.com/cppalliance/runvil-harness?rev=f87bfbf5155dae6b8b6ed2752b29fb91ac29c182#f87bfbf5155dae6b8b6ed2752b29fb91ac29c182" dependencies = [ "bytes", "reqwest", @@ -2256,7 +2256,7 @@ dependencies = [ [[package]] name = "harness-plugin-loader" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=c581ba338e39fe84b98a7200bd56c2cf147c7d59#c581ba338e39fe84b98a7200bd56c2cf147c7d59" +source = "git+https://github.com/cppalliance/runvil-harness?rev=f87bfbf5155dae6b8b6ed2752b29fb91ac29c182#f87bfbf5155dae6b8b6ed2752b29fb91ac29c182" dependencies = [ "libloading 0.8.9", "runvil-plugin", @@ -2267,7 +2267,7 @@ dependencies = [ [[package]] name = "harness-runner" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=c581ba338e39fe84b98a7200bd56c2cf147c7d59#c581ba338e39fe84b98a7200bd56c2cf147c7d59" +source = "git+https://github.com/cppalliance/runvil-harness?rev=f87bfbf5155dae6b8b6ed2752b29fb91ac29c182#f87bfbf5155dae6b8b6ed2752b29fb91ac29c182" dependencies = [ "futures-util", "rand 0.9.5", @@ -4056,7 +4056,7 @@ dependencies = [ [[package]] name = "plugin-mcp" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=c581ba338e39fe84b98a7200bd56c2cf147c7d59#c581ba338e39fe84b98a7200bd56c2cf147c7d59" +source = "git+https://github.com/cppalliance/runvil-harness?rev=f87bfbf5155dae6b8b6ed2752b29fb91ac29c182#f87bfbf5155dae6b8b6ed2752b29fb91ac29c182" dependencies = [ "reqwest", "rmcp", @@ -4724,7 +4724,7 @@ dependencies = [ [[package]] name = "runvil" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=c581ba338e39fe84b98a7200bd56c2cf147c7d59#c581ba338e39fe84b98a7200bd56c2cf147c7d59" +source = "git+https://github.com/cppalliance/runvil-harness?rev=f87bfbf5155dae6b8b6ed2752b29fb91ac29c182#f87bfbf5155dae6b8b6ed2752b29fb91ac29c182" dependencies = [ "harness-plugin-loader", "harness-runner", @@ -4735,7 +4735,7 @@ dependencies = [ [[package]] name = "runvil-engine" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=c581ba338e39fe84b98a7200bd56c2cf147c7d59#c581ba338e39fe84b98a7200bd56c2cf147c7d59" +source = "git+https://github.com/cppalliance/runvil-harness?rev=f87bfbf5155dae6b8b6ed2752b29fb91ac29c182#f87bfbf5155dae6b8b6ed2752b29fb91ac29c182" dependencies = [ "runvil-lua", "runvil-model-client", @@ -4748,7 +4748,7 @@ dependencies = [ [[package]] name = "runvil-lua" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=c581ba338e39fe84b98a7200bd56c2cf147c7d59#c581ba338e39fe84b98a7200bd56c2cf147c7d59" +source = "git+https://github.com/cppalliance/runvil-harness?rev=f87bfbf5155dae6b8b6ed2752b29fb91ac29c182#f87bfbf5155dae6b8b6ed2752b29fb91ac29c182" dependencies = [ "mlua", "runvil-markdown", @@ -4762,7 +4762,7 @@ dependencies = [ [[package]] name = "runvil-markdown" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=c581ba338e39fe84b98a7200bd56c2cf147c7d59#c581ba338e39fe84b98a7200bd56c2cf147c7d59" +source = "git+https://github.com/cppalliance/runvil-harness?rev=f87bfbf5155dae6b8b6ed2752b29fb91ac29c182#f87bfbf5155dae6b8b6ed2752b29fb91ac29c182" dependencies = [ "pulldown-cmark", "serde_json", @@ -4772,7 +4772,7 @@ dependencies = [ [[package]] name = "runvil-model-client" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=c581ba338e39fe84b98a7200bd56c2cf147c7d59#c581ba338e39fe84b98a7200bd56c2cf147c7d59" +source = "git+https://github.com/cppalliance/runvil-harness?rev=f87bfbf5155dae6b8b6ed2752b29fb91ac29c182#f87bfbf5155dae6b8b6ed2752b29fb91ac29c182" dependencies = [ "runvil-types", "serde", @@ -4782,7 +4782,7 @@ dependencies = [ [[package]] name = "runvil-plugin" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=c581ba338e39fe84b98a7200bd56c2cf147c7d59#c581ba338e39fe84b98a7200bd56c2cf147c7d59" +source = "git+https://github.com/cppalliance/runvil-harness?rev=f87bfbf5155dae6b8b6ed2752b29fb91ac29c182#f87bfbf5155dae6b8b6ed2752b29fb91ac29c182" dependencies = [ "runvil-types", "runvil-vfs", @@ -4805,7 +4805,7 @@ source = "git+https://github.com/cppalliance/runvil-plugin-api?rev=74f9e08ba9cc5 [[package]] name = "runvil-prompt" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=c581ba338e39fe84b98a7200bd56c2cf147c7d59#c581ba338e39fe84b98a7200bd56c2cf147c7d59" +source = "git+https://github.com/cppalliance/runvil-harness?rev=f87bfbf5155dae6b8b6ed2752b29fb91ac29c182#f87bfbf5155dae6b8b6ed2752b29fb91ac29c182" dependencies = [ "pulldown-cmark", "runvil-lua", @@ -4818,7 +4818,7 @@ dependencies = [ [[package]] name = "runvil-runtime" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=c581ba338e39fe84b98a7200bd56c2cf147c7d59#c581ba338e39fe84b98a7200bd56c2cf147c7d59" +source = "git+https://github.com/cppalliance/runvil-harness?rev=f87bfbf5155dae6b8b6ed2752b29fb91ac29c182#f87bfbf5155dae6b8b6ed2752b29fb91ac29c182" dependencies = [ "mlua", "regex", @@ -4836,7 +4836,7 @@ dependencies = [ [[package]] name = "runvil-types" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=c581ba338e39fe84b98a7200bd56c2cf147c7d59#c581ba338e39fe84b98a7200bd56c2cf147c7d59" +source = "git+https://github.com/cppalliance/runvil-harness?rev=f87bfbf5155dae6b8b6ed2752b29fb91ac29c182#f87bfbf5155dae6b8b6ed2752b29fb91ac29c182" dependencies = [ "serde", "serde_json", @@ -4846,7 +4846,7 @@ dependencies = [ [[package]] name = "runvil-vfs" version = "0.3.0" -source = "git+https://github.com/cppalliance/runvil-harness?rev=c581ba338e39fe84b98a7200bd56c2cf147c7d59#c581ba338e39fe84b98a7200bd56c2cf147c7d59" +source = "git+https://github.com/cppalliance/runvil-harness?rev=f87bfbf5155dae6b8b6ed2752b29fb91ac29c182#f87bfbf5155dae6b8b6ed2752b29fb91ac29c182" [[package]] name = "rust-embed" @@ -7971,6 +7971,7 @@ dependencies = [ name = "workshop-agents" version = "0.0.0" dependencies = [ + "harness-gateway-client", "rand 0.9.5", "runvil", "serde", diff --git a/Cargo.toml b/Cargo.toml index ca0ef9bf..ccafacc2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,9 +25,9 @@ repository = "https://github.com/cppalliance/runvil-workshop" # Workshop links in. All three name one commit, because two commits would # be two copies of every type the crates share. `version` beside `git` # keeps cargo-deny's wildcard check quiet. -runvil = { version = "0.3.0", git = "https://github.com/cppalliance/runvil-harness", rev = "c581ba338e39fe84b98a7200bd56c2cf147c7d59" } -harness-gateway-client = { version = "0.3.0", git = "https://github.com/cppalliance/runvil-harness", rev = "c581ba338e39fe84b98a7200bd56c2cf147c7d59" } -plugin-mcp = { version = "0.3.0", git = "https://github.com/cppalliance/runvil-harness", rev = "c581ba338e39fe84b98a7200bd56c2cf147c7d59" } +runvil = { version = "0.3.0", git = "https://github.com/cppalliance/runvil-harness", rev = "f87bfbf5155dae6b8b6ed2752b29fb91ac29c182" } +harness-gateway-client = { version = "0.3.0", git = "https://github.com/cppalliance/runvil-harness", rev = "f87bfbf5155dae6b8b6ed2752b29fb91ac29c182" } +plugin-mcp = { version = "0.3.0", git = "https://github.com/cppalliance/runvil-harness", rev = "f87bfbf5155dae6b8b6ed2752b29fb91ac29c182" } # The safe layer over the C Plugin contract, version 0.6, from its own # repository, pinned by commit. Only the library Plugin crates under # `crates/workshop/` name it, for `export_plugin!`. The commit is the one diff --git a/crates/workshop/agents/Cargo.toml b/crates/workshop/agents/Cargo.toml index eb3ae933..fe431184 100644 --- a/crates/workshop/agents/Cargo.toml +++ b/crates/workshop/agents/Cargo.toml @@ -18,16 +18,19 @@ rand.workspace = true serde.workspace = true serde_json.workspace = true thiserror.workspace = true -# `sync` for the conversation's broadcasts and state watch; `time` for the -# timer every run sleeps on; `rt` for the blocking pool a conversation -# parses its agent on. -tokio = { workspace = true, features = ["rt", "sync", "time"] } +# `sync` for the conversation's broadcasts and state watch; `rt` for the +# blocking pool a conversation parses its agent on. +tokio = { workspace = true, features = ["rt", "sync"] } tracing.workspace = true [dev-dependencies] +# The stock tokio timer that the fixture Host of the conversation suite +# sleeps on. +harness-gateway-client.workspace = true # The discovery suite seeds an agents directory on disk. tempfile.workspace = true -tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } +# `time` for the deadline the conversation suite sets on each wait. +tokio = { workspace = true, features = ["macros", "rt-multi-thread", "time"] } [lints] workspace = true diff --git a/crates/workshop/agents/src/lib.rs b/crates/workshop/agents/src/lib.rs index 07d95723..1ffcfffd 100644 --- a/crates/workshop/agents/src/lib.rs +++ b/crates/workshop/agents/src/lib.rs @@ -1,9 +1,8 @@ //! workshop-agents - Workshop's agent conversations: the conversation //! table keyed by a Workshop-minted id, each conversation's transcript, //! state, and failure reports, the operator's messages to its run, -//! discovery over the agents folder with the built-in `chat` agent, the -//! Host's timer, and the recorder tee every run of a conversation writes -//! through. +//! discovery over the agents folder with the built-in `chat` agent, and +//! the recorder tee every run of a conversation writes through. //! //! A conversation is one launched agent and its one run. The server //! builds that run's `RunSetup` around the recorder tee the @@ -23,7 +22,9 @@ //! service crates (`workshop-gateway`, `workshop-menu`, //! `workshop-status`), `runvil`, the one crate a Host depends on for //! the Harness and the Engine, and third-party crates; today it names -//! none of the Workshop crates. Never on `workshop-server`, another +//! none of the Workshop crates. Its tests also name +//! `harness-gateway-client`, the Harness's second public crate, for +//! the stock tokio timer. Never on `workshop-server`, another //! feature crate, an Engine crate, or a private Harness or Gateway //! crate. //! `cargo test -p build-xtask` enforces the product and container @@ -41,7 +42,6 @@ mod protocol; mod state; mod table; mod tee; -mod timer; mod transcript; pub use conversation::Conversation; @@ -49,4 +49,3 @@ pub use discovery::{BUILTIN_CHAT_SOURCE, LaunchError, discover_agents, load_agen pub use protocol::{ConversationId, Delta, DeltaKind, SessionEvent}; pub use state::{FailureKind, SessionFailure, SessionState}; pub use table::Conversations; -pub use timer::TokioTimer; diff --git a/crates/workshop/agents/src/timer.rs b/crates/workshop/agents/src/timer.rs deleted file mode 100644 index 54db7428..00000000 --- a/crates/workshop/agents/src/timer.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! The Host's timer: the clock every conversation's run sleeps on. - -use std::time::Duration; - -use runvil::BoxFuture; -use runvil::harness::Timer; - -/// Sleeps on tokio's timer wheel. -/// -/// The wheel multiplexes every pending sleep, so a `Timer` effect is one -/// `tokio::time::sleep`, and the Harness's drop of the effect tears the -/// sleep down. -#[derive(Clone, Copy, Debug, Default)] -pub struct TokioTimer; - -impl Timer for TokioTimer { - fn sleep(&self, duration: Duration) -> BoxFuture<'static, ()> { - Box::pin(tokio::time::sleep(duration)) - } -} diff --git a/crates/workshop/agents/tests/it/support.rs b/crates/workshop/agents/tests/it/support.rs index d48acaf3..1b078e36 100644 --- a/crates/workshop/agents/tests/it/support.rs +++ b/crates/workshop/agents/tests/it/support.rs @@ -3,10 +3,11 @@ use std::sync::Arc; -use runvil::harness::{MemoryRecorder, OfflineBroker, Packs}; +use harness_gateway_client::TokioTimer; +use runvil::harness::{FindTextPrompt, MemoryRecorder, OfflineBroker, Packs}; use runvil::plugin::PackRegistry; -use runvil::{Error, ErrorCode, Host, RunSetup}; -use workshop_agents::{Conversation, TokioTimer}; +use runvil::{Host, RunSetup}; +use workshop_agents::Conversation; /// The name the fixture Host finds its one agent by. pub(crate) const AGENT: &str = "fixture"; @@ -30,22 +31,10 @@ pub(crate) fn run_for( ) -> (Arc, RunSetup) { let host = Arc::new(Host { packs: Packs::new(PackRegistry::new()), - prompts: Arc::new(move |name: &str| { - if name == AGENT { - return Ok(source.clone()); - } - let code = ErrorCode::NotFound; - Err(Error::new( - code, - format!("no agent named {name}"), - code.prose(), - )) - }), + prompts: Arc::new(FindTextPrompt::new(AGENT, source)), timer: Arc::new(TokioTimer), }); - let setup = RunSetup { - has_user: true, - ..RunSetup::new(conversation.recorder(recorder), Arc::new(OfflineBroker)) - }; + let setup = + RunSetup::new(conversation.recorder(recorder), Arc::new(OfflineBroker)).has_user(true); (host, setup) } diff --git a/crates/workshop/server/src/agents.rs b/crates/workshop/server/src/agents.rs index 94b1dcdf..1c423bb2 100644 --- a/crates/workshop/server/src/agents.rs +++ b/crates/workshop/server/src/agents.rs @@ -11,7 +11,8 @@ //! with the file-tool Pack, the bashkit Plugin with the shell Pack, and //! the web Plugin with the web Pack among them, and the built-ins //! subagents and user; a finder that reads each agent from the agents -//! folder through `load_agent`; and the tokio timer. Every tool call of a +//! folder through `load_agent`; and the stock tokio timer of the Gateway +//! client. Every tool call of a //! library Plugin is lent the server's [`resources`]: the Gateway the //! registry holds as the call starts, which is where the web Pack sends a //! search. Each launch opens a conversation in `workshop-agents` and builds @@ -30,9 +31,9 @@ //! off. The filesystem has no policy of its own, so the default one, //! `AllowAll`, admits every operation: the file tools and the shell change //! the files of the in-memory root, which end with the run, and a -//! read-only mount refuses each change. The run's setup carries the Host -//! state ([`bindings`]): the menu's pick and the workspace's granted -//! roots, read once the menu's catalog holds a chat-capable model. +//! read-only mount refuses each change. The run's setup takes the Host +//! state ([`bindings`]): the menu's pick, read once the menu's catalog +//! holds a chat-capable model. //! Status-bar reporting stays in the server (`status`): a //! per-conversation reporter derives it from the conversation's events, //! deltas, and failure reports. @@ -59,14 +60,15 @@ use std::io; use std::path::{Path, PathBuf}; use std::sync::Arc; -use harness_gateway_client::{GatewayEndpoint, SecretString, provide_gateway_resources}; +use harness_gateway_client::{ + GatewayEndpoint, SecretString, TokioTimer, provide_gateway_resources, +}; use runvil::harness::{HostResources, Packs, PluginReport, RunId, insert_plugin_dir}; use runvil::plugin::PackRegistry; use runvil::{Error, ErrorCode, ErrorFact, Host, RunSetup}; use serde_json::Value; use workshop_agents::{ - Conversation, ConversationId, Conversations, LaunchError, TokioTimer, discover_agents, - load_agent, + Conversation, ConversationId, Conversations, LaunchError, discover_agents, load_agent, }; use workshop_gateway::GatewayHandles; use workshop_registry::Registry; @@ -369,7 +371,7 @@ struct Inner { broker: WorkshopBroker, /// What every run shares: the installed Packs each run makes its /// instances of, the finder that reads each agent from the agents - /// folder, and the tokio timer. + /// folder, and the stock tokio timer. host: Arc, /// What the Plugin directory loaded, held so that a library Plugin /// which inserted no Pack still stays loaded for as long as the @@ -406,11 +408,11 @@ impl AgentSessions { config.agents.plugins.as_deref(), ); let agents_path = config.agents.path.clone(); - let host = Host { + let host = Arc::new(Host { packs, prompts: Arc::new(agent_finder(agents_path.clone())), timer: Arc::new(TokioTimer), - }; + }); Self { inner: Arc::new(Inner { agents_path, @@ -418,7 +420,7 @@ impl AgentSessions { config.server.state_dir.join(HARNESS_STATE_DIR), )), broker: WorkshopBroker::new(registry.clone()), - host: Arc::new(host), + host, _plugins: plugins, conversations: Conversations::new(), registry, diff --git a/crates/workshop/server/src/agents/tests.rs b/crates/workshop/server/src/agents/tests.rs index ecdf02dd..767498c7 100644 --- a/crates/workshop/server/src/agents/tests.rs +++ b/crates/workshop/server/src/agents/tests.rs @@ -30,12 +30,13 @@ use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; use std::time::Duration; +use harness_gateway_client::TokioTimer; use runvil::harness::{HostResources, MemoryRecorder, OfflineBroker, Packs, PluginSource}; use runvil::plugin::PackRegistry; use runvil::vfs::{Origin, VfsRef}; use runvil::{Error, ErrorCode, ErrorFact, Host, RunSetup}; use serde_json::json; -use workshop_agents::{Conversations, SessionState, TokioTimer, load_agent}; +use workshop_agents::{Conversations, SessionState, load_agent}; use workshop_registry::Registry; use super::{