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: 10 additions & 8 deletions crates/goat-agent/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,17 @@ pub(crate) async fn handle_login(
return;
}
let resolved = match credential {
LoginCredential::ApiKey(secret) => Credential::ApiKey(SecretString::from(secret)),
LoginCredential::OAuth => match run_self_oauth(&provider, ctx.events, ctx.registry).await {
Ok(tokens) => Credential::OAuth(tokens),
Err(message) => {
login_failed(&provider, ctx.events, message).await;
emit_accounts_changed(ctx.events, ctx.registry, ctx.credentials).await;
return;
LoginCredential::ApiKey { key: secret } => Credential::ApiKey(SecretString::from(secret)),
LoginCredential::OAuth {} => {
match run_self_oauth(&provider, ctx.events, ctx.registry).await {
Ok(tokens) => Credential::OAuth(tokens),
Err(message) => {
login_failed(&provider, ctx.events, message).await;
emit_accounts_changed(ctx.events, ctx.registry, ctx.credentials).await;
return;
}
}
},
}
};
finalize_login(ctx, provider, name, key, resolved).await;
}
Expand Down
20 changes: 10 additions & 10 deletions crates/goat-agent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ async fn run(agent: GoatAgent, mut ops: mpsc::Receiver<Op>, events: mpsc::Sender
break;
}
}
Op::Clear => {
Op::Clear {} => {
state.conversation.clear();
state.tracker.invalidate();
state.thread_id = None;
Expand Down Expand Up @@ -421,7 +421,7 @@ async fn run(agent: GoatAgent, mut ops: mpsc::Receiver<Op>, events: mpsc::Sender
.await;
accounts::clear_account_registries(&account_registries);
}
Op::ListThreads => {
Op::ListThreads {} => {
threads::handle_list_threads(&store, &cwd, &events).await;
}
Op::Resume { thread_id: tid } => {
Expand All @@ -436,7 +436,7 @@ async fn run(agent: GoatAgent, mut ops: mpsc::Receiver<Op>, events: mpsc::Sender
)
.await;
}
Op::ResumeLatest => {
Op::ResumeLatest {} => {
threads::handle_resume_latest(
&store,
&skills,
Expand All @@ -451,7 +451,7 @@ async fn run(agent: GoatAgent, mut ops: mpsc::Receiver<Op>, events: mpsc::Sender
Op::RenameThread { title } => {
threads::handle_rename(&store, state.thread_id, title, &events).await;
}
Op::Shutdown => break,
Op::Shutdown {} => break,
}
}
mcp.shutdown().await;
Expand Down Expand Up @@ -937,7 +937,7 @@ mod tests {
break;
}
}
ops.send(Op::Shutdown).await.unwrap();
ops.send(Op::Shutdown {}).await.unwrap();

let provider2 = MockProvider {
id: "mock".to_owned(),
Expand Down Expand Up @@ -1474,12 +1474,12 @@ mod tests {
.unwrap();
drain_until_task_done(&mut events).await;

ops.send(Op::ResumeLatest).await.unwrap();
ops.send(Op::ResumeLatest {}).await.unwrap();
while let Some(event) = events.recv().await {
if let Event::ConversationRestored { entries, .. } = event {
assert!(entries.iter().any(|entry| matches!(
entry,
goat_protocol::TranscriptEntry::User(text) if text == "hello there"
goat_protocol::TranscriptEntry::User { text } if text == "hello there"
)));
return;
}
Expand Down Expand Up @@ -1509,8 +1509,8 @@ mod tests {
let session = Session::spawn(agent);
let (ops, mut events, _handle) = session.into_parts();

ops.send(Op::ResumeLatest).await.unwrap();
ops.send(Op::Shutdown).await.unwrap();
ops.send(Op::ResumeLatest {}).await.unwrap();
ops.send(Op::Shutdown {}).await.unwrap();

let mut saw_notify = false;
while let Some(event) = events.recv().await {
Expand Down Expand Up @@ -1565,7 +1565,7 @@ mod tests {
.unwrap();
drain_until_task_done(&mut events).await;

ops.send(Op::Clear).await.unwrap();
ops.send(Op::Clear {}).await.unwrap();

ops.send(Op::SubmitMessage {
id: TaskId(2),
Expand Down
2 changes: 1 addition & 1 deletion crates/goat-agent/src/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub(crate) async fn run_propose_plan(
res = rx => res,
};
match decision {
Ok(PlanDecision::Approve) => {
Ok(PlanDecision::Approve {}) => {
if let Some(cell) = env.transition {
let inject = approved_plan_inject(&path);
*cell
Expand Down
6 changes: 3 additions & 3 deletions crates/goat-agent/src/threads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ pub(crate) async fn handle_resume(
Some((command, output)) => {
entries.push(TranscriptEntry::Shell { command, output });
}
None => entries.push(TranscriptEntry::User(text.clone())),
None => entries.push(TranscriptEntry::User { text: text.clone() }),
}
}
parsed.push((stored.id, MessageRole::User, content));
Expand All @@ -215,9 +215,9 @@ pub(crate) async fn handle_resume(
for block in &content {
match block {
ContentBlock::Text { text } => match role {
MessageRole::User => entries.push(TranscriptEntry::User(text.clone())),
MessageRole::User => entries.push(TranscriptEntry::User { text: text.clone() }),
MessageRole::Assistant => {
entries.push(TranscriptEntry::Assistant(text.clone()));
entries.push(TranscriptEntry::Assistant { text: text.clone() });
}
MessageRole::System => {}
},
Expand Down
8 changes: 4 additions & 4 deletions crates/goat-agent/src/turn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ pub(crate) async fn handle_idle_op(
Op::RenameThread { title } => {
crate::threads::handle_rename(store, thread_id, title, events).await;
}
Op::ListThreads => {
Op::ListThreads {} => {
crate::threads::handle_list_threads(store, cwd, events).await;
}
_ => {}
Expand Down Expand Up @@ -318,7 +318,7 @@ pub(crate) async fn handle_shell(
Some(Op::Interrupt { id: target_id }) if target_id == id => {
break ShellEnd::Interrupted;
}
Some(Op::Shutdown) | None => break ShellEnd::Shutdown,
Some(Op::Shutdown {}) | None => break ShellEnd::Shutdown,
Some(op) => deferred.push(op),
},
}
Expand Down Expand Up @@ -489,7 +489,7 @@ pub(crate) async fn handle_compact(
}
}
Some(Op::Interrupt { id: target_id }) if target_id == id => token.cancel(),
Some(Op::Shutdown) | None => {
Some(Op::Shutdown {}) | None => {
shutdown = true;
token.cancel();
}
Expand Down Expand Up @@ -700,7 +700,7 @@ async fn run_one_turn(
}
}
Some(Op::Interrupt { id: target_id }) if target_id == id => token.cancel(),
Some(Op::Shutdown) | None => {
Some(Op::Shutdown {}) | None => {
shutdown = true;
token.cancel();
}
Expand Down
8 changes: 4 additions & 4 deletions crates/goat-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn spawn_pumps(conn: ClientConn<Stream>, session: SessionId, client_id: u64) ->
maybe_op = ops_rx.recv() => {
let Some(op) = maybe_op else { break };
let frame = match op {
Op::Shutdown => ClientFrame::Goodbye,
Op::Shutdown {} => ClientFrame::Goodbye {},
Op::Interrupt { .. }
| Op::Answer { .. }
| Op::DequeueMessage { .. }
Expand Down Expand Up @@ -217,7 +217,7 @@ pub async fn status(socket_path: &Path) -> Result<Vec<goat_wire::SessionInfo>, C
})
.await?;
expect_welcome(&mut conn).await?;
conn.send(&ClientFrame::ListSessions).await?;
conn.send(&ClientFrame::ListSessions {}).await?;
match conn.recv().await? {
ServerFrame::Sessions { sessions } => Ok(sessions),
_ => Err(ClientError::Handshake),
Expand All @@ -232,7 +232,7 @@ pub async fn stop(socket_path: &Path) -> Result<(), ClientError> {
})
.await?;
expect_welcome(&mut conn).await?;
conn.send(&ClientFrame::StopDaemon).await?;
conn.send(&ClientFrame::StopDaemon {}).await?;
Ok(())
}

Expand Down Expand Up @@ -289,7 +289,7 @@ pub async fn list_devices(socket_path: &Path) -> Result<Vec<goat_wire::DeviceInf
})
.await?;
expect_welcome(&mut conn).await?;
conn.send(&ClientFrame::ListDevices).await?;
conn.send(&ClientFrame::ListDevices {}).await?;
match conn.recv().await? {
ServerFrame::Devices { devices } => Ok(devices),
ServerFrame::Error { message } => Err(ClientError::OpenFailed(message)),
Expand Down
6 changes: 3 additions & 3 deletions crates/goat-code/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ async fn run_tui(worktree_label: Option<String>, r#continue: bool) -> color_eyre
.ok_or_else(|| color_eyre::eyre::eyre!(goat_config::HOME_NOT_FOUND))?;
let daemon_exe = std::env::current_exe()?;
let resume = if r#continue {
goat_wire::ResumeMode::Latest
goat_wire::ResumeMode::Latest {}
} else {
goat_wire::ResumeMode::New
goat_wire::ResumeMode::New {}
};

let attachment = goat_client::connect(&socket_path, &daemon_exe, cwd, resume).await?;
Expand Down Expand Up @@ -135,7 +135,7 @@ async fn run_daemon_command(command: DaemonCommand) -> color_eyre::Result<()> {
} else {
for s in sessions {
let flag = match s.state {
goat_wire::SessionLiveState::WaitingOnAsk => " (waiting on ask)",
goat_wire::SessionLiveState::WaitingOnAsk {} => " (waiting on ask)",
_ => "",
};
println!(
Expand Down
3 changes: 2 additions & 1 deletion crates/goat-code/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ async fn drain_daemon(force: bool) -> color_eyre::Result<()> {
.filter(|s| {
matches!(
s.state,
goat_wire::SessionLiveState::Active | goat_wire::SessionLiveState::WaitingOnAsk
goat_wire::SessionLiveState::Active {}
| goat_wire::SessionLiveState::WaitingOnAsk {}
)
})
.count();
Expand Down
58 changes: 32 additions & 26 deletions crates/goat-commands/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ fn default_skill_shape() -> CommandShape {

fn skill_shape(command: &SkillCommandShape) -> CommandShape {
match command {
SkillCommandShape::Arguments(arguments) => {
SkillCommandShape::Arguments { items: arguments } => {
CommandShape::Parameters(arguments.iter().map(skill_parameter).collect())
}
SkillCommandShape::Subcommands(subcommands) => {
SkillCommandShape::Subcommands { items: subcommands } => {
CommandShape::Branches(subcommands.iter().map(skill_branch).collect())
}
}
Expand All @@ -169,9 +169,9 @@ fn skill_parameter(parameter: &SkillParameterInfo) -> ParameterSpec {

fn skill_value(value: &SkillParameterValue) -> ParameterValue {
match value {
SkillParameterValue::Word => ParameterValue::Word,
SkillParameterValue::Integer => ParameterValue::Integer,
SkillParameterValue::Choice(choices) => ParameterValue::Choice(
SkillParameterValue::Word {} => ParameterValue::Word,
SkillParameterValue::Integer {} => ParameterValue::Integer,
SkillParameterValue::Choice { options: choices } => ParameterValue::Choice(
choices
.iter()
.map(|choice| ChoiceSpec {
Expand All @@ -180,7 +180,7 @@ fn skill_value(value: &SkillParameterValue) -> ParameterValue {
})
.collect(),
),
SkillParameterValue::TextTail => ParameterValue::TextTail,
SkillParameterValue::TextTail {} => ParameterValue::TextTail,
}
}

Expand Down Expand Up @@ -361,12 +361,14 @@ mod tests {
registry.set_skills(&[SkillInfo {
name: "review".to_owned(),
description: "review".to_owned(),
command: Some(SkillCommandShape::Arguments(vec![SkillParameterInfo {
name: "target".to_owned(),
description: "target".to_owned(),
required: true,
value: SkillParameterValue::Word,
}])),
command: Some(SkillCommandShape::Arguments {
items: vec![SkillParameterInfo {
name: "target".to_owned(),
description: "target".to_owned(),
required: true,
value: SkillParameterValue::Word {},
}],
}),
}]);
let CommandEffect::Submit(text) = registry.resolve_line("/review src/lib.rs") else {
panic!("expected submit");
Expand All @@ -381,16 +383,18 @@ mod tests {
registry.set_skills(&[SkillInfo {
name: "review".to_owned(),
description: "review".to_owned(),
command: Some(SkillCommandShape::Subcommands(vec![SkillBranchInfo {
name: "security".to_owned(),
description: "security".to_owned(),
arguments: vec![SkillParameterInfo {
name: "focus".to_owned(),
description: "focus".to_owned(),
required: false,
value: SkillParameterValue::TextTail,
command: Some(SkillCommandShape::Subcommands {
items: vec![SkillBranchInfo {
name: "security".to_owned(),
description: "security".to_owned(),
arguments: vec![SkillParameterInfo {
name: "focus".to_owned(),
description: "focus".to_owned(),
required: false,
value: SkillParameterValue::TextTail {},
}],
}],
}])),
}),
}]);
let CommandEffect::Submit(text) = registry.resolve_line("/review security auth flow")
else {
Expand All @@ -406,11 +410,13 @@ mod tests {
registry.set_skills(&[SkillInfo {
name: "review".to_owned(),
description: "review".to_owned(),
command: Some(SkillCommandShape::Subcommands(vec![SkillBranchInfo {
name: "security".to_owned(),
description: "security".to_owned(),
arguments: Vec::new(),
}])),
command: Some(SkillCommandShape::Subcommands {
items: vec![SkillBranchInfo {
name: "security".to_owned(),
description: "security".to_owned(),
arguments: Vec::new(),
}],
}),
}]);
assert!(matches!(
registry.resolve_line("/review nope"),
Expand Down
2 changes: 1 addition & 1 deletion crates/goat-core/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl Session {
}

pub async fn shutdown(self) {
let _ = self.ops.send(Op::Shutdown).await;
let _ = self.ops.send(Op::Shutdown {}).await;
let _ = self.handle.await;
}
}
2 changes: 1 addition & 1 deletion crates/goat-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mod tests {
})
.await;
}
Op::Shutdown => break,
Op::Shutdown {} => break,
_ => {}
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/goat-daemon/src/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ async fn dispatch(
}
Disposition::Continue
}
ClientFrame::ListSessions => {
ClientFrame::ListSessions {} => {
let sessions = manager.list_sessions().await;
let _ = out_tx.send(ServerFrame::Sessions { sessions }).await;
Disposition::Continue
Expand Down Expand Up @@ -220,7 +220,7 @@ async fn dispatch(
}
Disposition::Continue
}
ClientFrame::ListDevices => {
ClientFrame::ListDevices {} => {
match manager.list_devices().await {
Ok(devices) => {
let _ = out_tx.send(ServerFrame::Devices { devices }).await;
Expand All @@ -242,7 +242,7 @@ async fn dispatch(
}
Disposition::Continue
}
ClientFrame::StopDaemon => {
ClientFrame::StopDaemon {} => {
if origin.is_local() {
shutdown.cancel();
Disposition::Closed
Expand All @@ -255,7 +255,7 @@ async fn dispatch(
Disposition::Continue
}
}
ClientFrame::Goodbye => Disposition::Closed,
ClientFrame::Goodbye {} => Disposition::Closed,
}
}

Expand Down
Loading
Loading