Skip to content

armgit / kwant

Public Imported from GitHub
0

Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.

Clippy: struct literal for the continuation's options, a name for owner event batches

Lin (kwant bot)6d8fab9fd7df
diff --git a/src/server/loose_ends_owner.rs b/src/server/loose_ends_owner.rs
index aae3c570..3fd38bc8 100644
--- a/src/server/loose_ends_owner.rs
+++ b/src/server/loose_ends_owner.rs
@@ -103,6 +103,9 @@ async fn take_slot(db: &Database, space: &SpaceId, cap: i64, now: DateTime<Utc>)
db.set_setting(&runs_key(space), &value).await.is_ok()
}
+/// Cases by the event that brought them up.
+type Batch = Vec<(Event, Vec<CaseRow>)>;
+
/// What started the owner's turn.
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Event {
@@ -179,8 +182,8 @@ pub async fn on_event(state: &AppState, event: Event, cases: Vec<CaseRow>) -> Ve
/// [`on_event`] for several events at once (one reminder tick can fire "today" and "in 7 days"):
/// still one turn per space.
-pub async fn on_events(state: &AppState, events: Vec<(Event, Vec<CaseRow>)>) -> Vec<String> {
- let mut by_space: Vec<(SpaceId, Vec<(Event, Vec<CaseRow>)>)> = Vec::new();
+pub async fn on_events(state: &AppState, events: Batch) -> Vec<String> {
+ let mut by_space: Vec<(SpaceId, Batch)> = Vec::new();
for (event, cases) in events {
for c in cases {
let space = c.space_id.clone().filter(|s| !s.is_empty()).map(SpaceId::new).unwrap_or_else(SpaceId::default_space);
diff --git a/src/server/routes.rs b/src/server/routes.rs
index f7efb08f..c51c9ba9 100644
--- a/src/server/routes.rs
+++ b/src/server/routes.rs
@@ -857,8 +857,7 @@ pub(super) async fn continue_once_if_capped(scope: &TurnScope, kwant: &Kwant, fi
return first;
}
tracing::info!(kwant = %kwant.id, "turn hit the model-call cap: one automatic continuation");
- let mut opts = TurnOpts::default();
- opts.label = Some("Automatic continuation (once): the last turn ran out of model calls".into());
+ let opts = TurnOpts { label: Some("Automatic continuation (once): the last turn ran out of model calls".into()), ..Default::default() };
match try_kwant_turn(scope, kwant, CONTINUE_PROMPT.to_string(), opts).await {
Ok(more) => Ok(format!("{}\n\n{more}", text.trim_end())),
Err(_) => first,