Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[workspace]
members = [
"crates/ein",
"crates/ein-server",
"crates/ein-tui",
"crates/ein-proto",
Expand All @@ -9,7 +8,6 @@ members = [
"packages/*",
]
default-members = [
"crates/ein",
"crates/ein-server",
"crates/ein-tui",
"crates/ein-proto",
Expand Down Expand Up @@ -37,8 +35,7 @@ targets = [
"x86_64-unknown-linux-gnu",
]
pr-run-mode = "plan"
# Only distribute the meta-package; individual crates are excluded from releases.
members = ["crates/ein"]
members = ["crates/ein-tui", "crates/ein-server"]
# Allow manual edits to the generated workflow (we add a protoc install step).
allow-dirty = ["ci"]

Expand Down
56 changes: 46 additions & 10 deletions crates/ein-agent/src/agents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,11 +768,19 @@ mod tests {

let msgs = agent.messages();
assert!(
msgs[0].content.as_deref().unwrap_or("").starts_with("[Tool result truncated:"),
msgs[0]
.content
.as_deref()
.unwrap_or("")
.starts_with("[Tool result truncated:"),
"old large tool result must be truncated"
);
assert!(
msgs[1].content.as_deref().unwrap_or("").starts_with("[Tool result truncated:"),
msgs[1]
.content
.as_deref()
.unwrap_or("")
.starts_with("[Tool result truncated:"),
"old large tool result must be truncated"
);
assert_eq!(msgs[2].content.as_deref(), Some("recent 1"));
Expand All @@ -799,7 +807,10 @@ mod tests {

for msg in agent.messages() {
assert!(
!msg.content.as_deref().unwrap_or("").starts_with("[Tool result truncated:"),
!msg.content
.as_deref()
.unwrap_or("")
.starts_with("[Tool result truncated:"),
"recent messages must not be truncated"
);
}
Expand All @@ -823,8 +834,16 @@ mod tests {
agent.truncate_old_tool_results();

let msgs = agent.messages();
assert_eq!(msgs[0].content.as_deref(), Some(large.as_str()), "User must not be truncated");
assert_eq!(msgs[1].content.as_deref(), Some(large.as_str()), "System must not be truncated");
assert_eq!(
msgs[0].content.as_deref(),
Some(large.as_str()),
"User must not be truncated"
);
assert_eq!(
msgs[1].content.as_deref(),
Some(large.as_str()),
"System must not be truncated"
);
}

#[test]
Expand Down Expand Up @@ -899,7 +918,9 @@ mod tests {
})
.with_event_handler(move |event| {
let cap = cap.clone();
async move { cap.lock().unwrap().push(event); }
async move {
cap.lock().unwrap().push(event);
}
})
.with_message_history(vec![user_msg("do stuff")])
.build();
Expand All @@ -910,7 +931,11 @@ mod tests {
let deltas: Vec<&str> = events
.iter()
.filter_map(|e| {
if let AgentEvent::ContentDelta(t) = e { Some(t.as_str()) } else { None }
if let AgentEvent::ContentDelta(t) = e {
Some(t.as_str())
} else {
None
}
})
.collect();
assert_eq!(deltas, vec![summary]);
Expand Down Expand Up @@ -993,21 +1018,32 @@ mod tests {
})
.with_event_handler(move |event| {
let cap = cap.clone();
async move { cap.lock().unwrap().push(event); }
async move {
cap.lock().unwrap().push(event);
}
})
.build();

agent.chat("hello").await.unwrap();

let events = captured.lock().unwrap();
let usage = events.iter().find_map(|e| {
if let AgentEvent::TokenUsage { prompt_tokens, completion_tokens, total_tokens } = e {
if let AgentEvent::TokenUsage {
prompt_tokens,
completion_tokens,
total_tokens,
} = e
{
Some((*prompt_tokens, *completion_tokens, *total_tokens))
} else {
None
}
});
assert_eq!(usage, Some((10, 5, 15)), "TokenUsage event must carry correct totals");
assert_eq!(
usage,
Some((10, 5, 15)),
"TokenUsage event must carry correct totals"
);
}

#[tokio::test]
Expand Down
5 changes: 1 addition & 4 deletions crates/ein-core/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,6 @@ mod tests {
};
let json = serde_json::to_string(&resp).unwrap();
let decoded: CompletionResponse = serde_json::from_str(&json).unwrap();
assert_eq!(
decoded.error.unwrap()["message"],
"insufficient credits"
);
assert_eq!(decoded.error.unwrap()["message"], "insufficient credits");
}
}
4 changes: 4 additions & 0 deletions crates/ein-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ homepage.workspace = true
name = "ein_server"
path = "src/lib.rs"

[[bin]]
name = "ein-server"
path = "src/main.rs"


[dependencies]
anyhow = { workspace = true }
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions crates/ein-tui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ homepage.workspace = true
name = "ein_tui"
path = "src/lib.rs"

[[bin]]
name = "ein"
path = "src/main.rs"


[dependencies]
anyhow = { workspace = true }
Expand All @@ -30,3 +34,6 @@ tonic = { workspace = true }
tracing = { workspace = true }
tracing-appender = "0.2"
tracing-subscriber = { workspace = true }
reqwest = { version = "0.13.3", default-features = false, features = ["rustls"] }
flate2 = "1.1.9"
tar = "0.4.45"
19 changes: 19 additions & 0 deletions crates/ein-tui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ pub(crate) enum AppEvent {
PluginStatusLoaded(Vec<PluginSourceStatus>),
/// A plugin install RPC completed; carries success flag and a status message.
PluginInstallResult { success: bool, message: String },
/// Background uninstall task finished; carry the step log and outcome.
UninstallComplete { success: bool, steps: Vec<String> },
}

/// Whether the TUI currently has a live server connection.
Expand Down Expand Up @@ -198,6 +200,8 @@ pub(crate) enum Modal {
SessionPicker(SessionPickerState),
/// CWD access prompt, shown after choosing "New Session".
CwdPrompt(CwdState),
/// Uninstall confirmation / progress / result, opened via `/uninstall`.
UninstallConfirm(UninstallModalState),
}

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -229,6 +233,21 @@ pub(crate) struct SessionPickerState {
pub(crate) session_tx: oneshot::Sender<SessionConfig>,
}

// ---------------------------------------------------------------------------
// Uninstall modal state
// ---------------------------------------------------------------------------

pub(crate) enum UninstallPhase {
Confirm,
Running,
Done { success: bool },
}

pub(crate) struct UninstallModalState {
pub(crate) phase: UninstallPhase,
pub(crate) log: Vec<String>,
}

/// State for the CWD access modal, shown only when "New Session" is chosen.
pub(crate) struct CwdState {
pub(crate) cwd: String,
Expand Down
Loading
Loading