Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/hive-runtime/src/claude.rs
atlas f189724a4c hive-runtime, hive-agent: model/effort picker for ACP agents from configOptions
An ACP agent's model and effort pickers now list what its session offers
(its `model` and `thought_level` config options) instead of the claude
model list and EFFORT_LEVELS. A pick goes through the same Bus::set_model /
Bus::set_effort -> Config.model / Config.effort path as on claude; before
each prompt the ACP runtime sets it with `session/set_config_option`, model
first, and only when the session offers that value. Options are re-read
from the set response and from `config_option_update`, so the effort picker
disappears when the chosen model offers no effort levels, and is hidden
while a newly picked model waits for the next turn.

The session's options reach the web UI through a `Choices` handle from a
new `Runtime::choices`, registered on the bus the way `canceller` is.
/api/model and /api/effort accept only offered values on ACP. The claude
path is unchanged.

Refs #4391
2026-09-30 10:53:53 +02:00

50 lines
1.5 KiB
Rust

//! The claude backend: a pass-through to `hive_claude`.
use std::path::PathBuf;
use hive_claude::{CompactionPolicy, Config, InfiniteSession, Progress, SessionStore, Sink};
use crate::{Canceller, Choices, Result, Runtime};
/// `claude --print` turns on a titled [`InfiniteSession`], which owns
/// resume-or-create and compaction.
pub struct ClaudeRuntime<P: CompactionPolicy> {
session: InfiniteSession<P>,
store: SessionStore,
title: String,
}
impl<P: CompactionPolicy> ClaudeRuntime<P> {
/// A runtime for the session titled `title`, found through `store` and
/// compacted per `policy`.
pub fn new(title: impl Into<String>, store: SessionStore, policy: P) -> Self {
let title = title.into();
Self {
session: InfiniteSession::new(title.clone(), store.clone(), policy),
store,
title,
}
}
}
impl<P: CompactionPolicy> Runtime for ClaudeRuntime<P> {
async fn run(&self, config: &Config, prompt: &str, sink: &impl Sink) -> Result<Progress> {
Ok(self.session.run(config, prompt, sink).await?)
}
async fn compact(&self, config: &Config, sink: &impl Sink) -> Result<()> {
Ok(self.session.compact(config, sink).await?)
}
fn archive(&self) -> Result<Option<PathBuf>> {
Ok(self.store.archive_by_title(&self.title)?)
}
fn canceller(&self) -> Option<Canceller> {
None
}
fn choices(&self) -> Option<Choices> {
None
}
}