WIP: Fix mind/, dmn, UI layer — 35 errors remaining
mind/mod.rs and mind/dmn.rs fully migrated to AST types. user/context.rs, user/widgets.rs, user/chat.rs partially migrated. Killed working_stack tool, tokenize_conv_entry, context_old.rs. Remaining: learn.rs (22), oneshot.rs (5), subconscious.rs (3), chat.rs (3), widgets.rs (1), context.rs (1). Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
bf3e2a9b73
commit
d0d876e067
5 changed files with 99 additions and 141 deletions
|
|
@ -273,7 +273,7 @@ impl State {
|
|||
|
||||
use std::sync::Arc;
|
||||
use crate::agent::{Agent, oneshot::{AutoAgent, AutoStep}};
|
||||
use crate::agent::context::ConversationEntry;
|
||||
use crate::agent::context::{Ast, AstNode, NodeBody};
|
||||
use crate::subconscious::defs;
|
||||
|
||||
/// Names and byte-interval triggers for the built-in subconscious agents.
|
||||
|
|
@ -472,22 +472,18 @@ impl Subconscious {
|
|||
let rendered = store_guard.as_ref()
|
||||
.and_then(|s| crate::cli::node::render_node(s, key));
|
||||
if let Some(rendered) = rendered {
|
||||
let mut msg = crate::agent::api::Message::user(format!(
|
||||
"<system-reminder>\n--- {} (surfaced) ---\n{}\n</system-reminder>",
|
||||
key, rendered,
|
||||
ag.push_node(AstNode::memory(
|
||||
key,
|
||||
format!("--- {} (surfaced) ---\n{}", key, rendered),
|
||||
));
|
||||
msg.stamp();
|
||||
ag.push_entry(ConversationEntry::Memory {
|
||||
key: key.to_string(), message: msg, score: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(reflection) = outputs.get("reflection") {
|
||||
if !reflection.trim().is_empty() {
|
||||
ag.push_message(crate::agent::api::Message::user(format!(
|
||||
"<system-reminder>\n--- subconscious reflection ---\n{}\n</system-reminder>",
|
||||
ag.push_node(AstNode::dmn(format!(
|
||||
"--- subconscious reflection ---\n{}",
|
||||
reflection.trim(),
|
||||
)));
|
||||
}
|
||||
|
|
@ -496,8 +492,8 @@ impl Subconscious {
|
|||
if let Some(nudge) = outputs.get("thalamus") {
|
||||
let nudge = nudge.trim();
|
||||
if !nudge.is_empty() && nudge != "ok" {
|
||||
ag.push_message(crate::agent::api::Message::user(format!(
|
||||
"<system-reminder>\n--- thalamus ---\n{}\n</system-reminder>",
|
||||
ag.push_node(AstNode::dmn(format!(
|
||||
"--- thalamus ---\n{}",
|
||||
nudge,
|
||||
)));
|
||||
}
|
||||
|
|
@ -518,12 +514,13 @@ impl Subconscious {
|
|||
pub async fn trigger(&mut self, agent: &Arc<tokio::sync::Mutex<Agent>>) {
|
||||
let (conversation_bytes, memory_keys) = {
|
||||
let ag = agent.lock().await;
|
||||
let bytes = ag.context.conversation.entries().iter()
|
||||
.filter(|ce| !ce.entry.is_log() && !ce.entry.is_memory())
|
||||
.map(|ce| ce.entry.message().content_text().len() as u64)
|
||||
let bytes = ag.context.conversation().iter()
|
||||
.filter(|node| !matches!(node.leaf().map(|l| l.body()),
|
||||
Some(NodeBody::Log(_)) | Some(NodeBody::Memory { .. })))
|
||||
.map(|node| node.render().len() as u64)
|
||||
.sum::<u64>();
|
||||
let keys: Vec<String> = ag.context.conversation.entries().iter().filter_map(|ce| {
|
||||
if let ConversationEntry::Memory { key, .. } = &ce.entry {
|
||||
let keys: Vec<String> = ag.context.conversation().iter().filter_map(|node| {
|
||||
if let Some(NodeBody::Memory { key, .. }) = node.leaf().map(|l| l.body()) {
|
||||
Some(key.clone())
|
||||
} else { None }
|
||||
}).collect();
|
||||
|
|
@ -550,7 +547,7 @@ impl Subconscious {
|
|||
|
||||
let mut forked = conscious.fork(auto.tools.clone());
|
||||
forked.provenance = format!("agent:{}", auto.name);
|
||||
let fork_point = forked.context.conversation.len();
|
||||
let fork_point = forked.context.conversation().len();
|
||||
let shared_forked = Arc::new(tokio::sync::Mutex::new(forked));
|
||||
|
||||
self.agents[idx].forked_agent = Some(shared_forked.clone());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue