Upgrade workspace to edition 2024, add --local flag to agent run
Edition 2024 changes: - gen is reserved: rename variable in query/engine.rs - set_var is unsafe: wrap in unsafe block in cli/agent.rs - match ergonomics: add explicit & in spectral.rs filter closure New --local flag for `poc-memory agent run` bypasses the daemon and runs the agent directly in-process. Useful for testing agent prompt changes without waiting in the daemon queue. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c153daacd5
commit
0a62832fe3
7 changed files with 1515 additions and 56 deletions
1508
Cargo.lock
generated
1508
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,10 +1,10 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["poc-memory", "poc-daemon", "jobkit-daemon"]
|
members = ["poc-memory", "poc-daemon", "jobkit-daemon", "poc-agent"]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
opt-level = 2
|
opt-level = 2
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ peg = "0.8"
|
||||||
paste = "1"
|
paste = "1"
|
||||||
jobkit = { git = "https://evilpiepirate.org/git/jobkit.git/" }
|
jobkit = { git = "https://evilpiepirate.org/git/jobkit.git/" }
|
||||||
jobkit-daemon = { git = "https://evilpiepirate.org/git/jobkit-daemon.git/" }
|
jobkit-daemon = { git = "https://evilpiepirate.org/git/jobkit-daemon.git/" }
|
||||||
|
reqwest = { version = "0.12", features = ["blocking", "json"] }
|
||||||
|
poc-agent = { path = "../poc-agent" }
|
||||||
redb = "2"
|
redb = "2"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
ratatui = "0.29"
|
ratatui = "0.29"
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,10 @@
|
||||||
use crate::store;
|
use crate::store;
|
||||||
use crate::agents::llm;
|
use crate::agents::llm;
|
||||||
|
|
||||||
pub fn cmd_run_agent(agent: &str, count: usize, target: &[String], query: Option<&str>, dry_run: bool, debug: bool) -> Result<(), String> {
|
pub fn cmd_run_agent(agent: &str, count: usize, target: &[String], query: Option<&str>, dry_run: bool, debug: bool, local: bool) -> Result<(), String> {
|
||||||
if dry_run {
|
if dry_run {
|
||||||
std::env::set_var("POC_MEMORY_DRY_RUN", "1");
|
// SAFETY: single-threaded at this point (CLI startup, before any agent work)
|
||||||
|
unsafe { std::env::set_var("POC_MEMORY_DRY_RUN", "1"); }
|
||||||
}
|
}
|
||||||
let mut store = store::Store::load()?;
|
let mut store = store::Store::load()?;
|
||||||
let log = |msg: &str| eprintln!("[{}] {}", agent, msg);
|
let log = |msg: &str| eprintln!("[{}] {}", agent, msg);
|
||||||
|
|
@ -28,15 +29,11 @@ pub fn cmd_run_agent(agent: &str, count: usize, target: &[String], query: Option
|
||||||
};
|
};
|
||||||
|
|
||||||
if !resolved_targets.is_empty() {
|
if !resolved_targets.is_empty() {
|
||||||
// Queue one daemon task per target node
|
// --local or daemon unavailable: run directly
|
||||||
let mut queued = 0;
|
if local || crate::agents::daemon::send_rpc_pub("ping").is_none() {
|
||||||
for key in &resolved_targets {
|
if !local {
|
||||||
let cmd = format!("run-agent {} 1 target:{}", agent, key);
|
|
||||||
match crate::agents::daemon::send_rpc_pub(&cmd) {
|
|
||||||
Some(_) => queued += 1,
|
|
||||||
None => {
|
|
||||||
eprintln!("Daemon not running — falling back to local execution");
|
eprintln!("Daemon not running — falling back to local execution");
|
||||||
// Local fallback: run sequentially
|
}
|
||||||
for (i, key) in resolved_targets.iter().enumerate() {
|
for (i, key) in resolved_targets.iter().enumerate() {
|
||||||
eprintln!("[{}] [{}/{}] {}", agent, i + 1, resolved_targets.len(), key);
|
eprintln!("[{}] [{}/{}] {}", agent, i + 1, resolved_targets.len(), key);
|
||||||
if i > 0 { store = store::Store::load()?; }
|
if i > 0 { store = store::Store::load()?; }
|
||||||
|
|
@ -48,6 +45,13 @@ pub fn cmd_run_agent(agent: &str, count: usize, target: &[String], query: Option
|
||||||
}
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Queue to daemon
|
||||||
|
let mut queued = 0;
|
||||||
|
for key in &resolved_targets {
|
||||||
|
let cmd = format!("run-agent {} 1 target:{}", agent, key);
|
||||||
|
if crate::agents::daemon::send_rpc_pub(&cmd).is_some() {
|
||||||
|
queued += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
eprintln!("[{}] queued {} tasks to daemon", agent, queued);
|
eprintln!("[{}] queued {} tasks to daemon", agent, queued);
|
||||||
|
|
|
||||||
|
|
@ -587,6 +587,9 @@ enum AgentCmd {
|
||||||
/// Debug — print full prompt and response
|
/// Debug — print full prompt and response
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
debug: bool,
|
debug: bool,
|
||||||
|
/// Run locally instead of queuing to daemon
|
||||||
|
#[arg(long)]
|
||||||
|
local: bool,
|
||||||
},
|
},
|
||||||
/// Show spaced repetition replay queue
|
/// Show spaced repetition replay queue
|
||||||
#[command(name = "replay-queue")]
|
#[command(name = "replay-queue")]
|
||||||
|
|
@ -832,8 +835,8 @@ fn main() {
|
||||||
AgentCmd::FactMine { path, batch, dry_run, output, min_messages }
|
AgentCmd::FactMine { path, batch, dry_run, output, min_messages }
|
||||||
=> cli::agent::cmd_fact_mine(&path, batch, dry_run, output.as_deref(), min_messages),
|
=> cli::agent::cmd_fact_mine(&path, batch, dry_run, output.as_deref(), min_messages),
|
||||||
AgentCmd::FactMineStore { path } => cli::agent::cmd_fact_mine_store(&path),
|
AgentCmd::FactMineStore { path } => cli::agent::cmd_fact_mine_store(&path),
|
||||||
AgentCmd::Run { agent, count, target, query, dry_run, debug }
|
AgentCmd::Run { agent, count, target, query, dry_run, debug, local }
|
||||||
=> cli::agent::cmd_run_agent(&agent, count, &target, query.as_deref(), dry_run, debug),
|
=> cli::agent::cmd_run_agent(&agent, count, &target, query.as_deref(), dry_run, debug, local),
|
||||||
AgentCmd::ReplayQueue { count } => cli::agent::cmd_replay_queue(count),
|
AgentCmd::ReplayQueue { count } => cli::agent::cmd_replay_queue(count),
|
||||||
AgentCmd::Evaluate { matchups, model, dry_run }
|
AgentCmd::Evaluate { matchups, model, dry_run }
|
||||||
=> cli::agent::cmd_evaluate_agents(matchups, &model, dry_run),
|
=> cli::agent::cmd_evaluate_agents(matchups, &model, dry_run),
|
||||||
|
|
|
||||||
|
|
@ -434,7 +434,7 @@ pub fn run_query(
|
||||||
}
|
}
|
||||||
|
|
||||||
current = match stage {
|
current = match stage {
|
||||||
Stage::Generator(gen) => run_generator(gen, store),
|
Stage::Generator(g) => run_generator(g, store),
|
||||||
|
|
||||||
Stage::Filter(filt) => {
|
Stage::Filter(filt) => {
|
||||||
current.into_iter()
|
current.into_iter()
|
||||||
|
|
@ -470,8 +470,8 @@ pub fn run_query(
|
||||||
current
|
current
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_generator(gen: &Generator, store: &Store) -> Vec<(String, f64)> {
|
fn run_generator(g: &Generator, store: &Store) -> Vec<(String, f64)> {
|
||||||
match gen {
|
match g {
|
||||||
Generator::All => {
|
Generator::All => {
|
||||||
store.nodes.iter()
|
store.nodes.iter()
|
||||||
.filter(|(_, n)| !n.deleted)
|
.filter(|(_, n)| !n.deleted)
|
||||||
|
|
|
||||||
|
|
@ -474,7 +474,7 @@ pub fn analyze_positions(
|
||||||
let coords = &emb.coords[&key];
|
let coords = &emb.coords[&key];
|
||||||
|
|
||||||
let (nearest_community, dist_to_nearest) = centers.iter()
|
let (nearest_community, dist_to_nearest) = centers.iter()
|
||||||
.filter(|(&c, _)| c != comm)
|
.filter(|&(&c, _)| c != comm)
|
||||||
.map(|(&c, center)| (c, weighted_distance(coords, center, &weights)))
|
.map(|(&c, center)| (c, weighted_distance(coords, center, &weights)))
|
||||||
.min_by(|a, b| a.1.total_cmp(&b.1))
|
.min_by(|a, b| a.1.total_cmp(&b.1))
|
||||||
.unwrap_or((comm, f64::MAX));
|
.unwrap_or((comm, f64::MAX));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue