secrets: polish key manager and docs
This commit is contained in:
parent
cc2c9a2973
commit
7ddf74570a
|
|
@ -239,16 +239,44 @@ pub async fn launch() -> ExitCode {
|
||||||
|
|
||||||
type UiResult<T> = Result<T, Box<dyn std::error::Error>>;
|
type UiResult<T> = Result<T, Box<dyn std::error::Error>>;
|
||||||
|
|
||||||
|
struct TerminalRestoreGuard {
|
||||||
|
active: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TerminalRestoreGuard {
|
||||||
|
fn new() -> Self {
|
||||||
|
Self { active: true }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn restore(mut self) {
|
||||||
|
self.cleanup();
|
||||||
|
self.active = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn cleanup(&mut self) {
|
||||||
|
let _ = execute!(io::stdout(), crossterm::cursor::Show, LeaveAlternateScreen);
|
||||||
|
let _ = disable_raw_mode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Drop for TerminalRestoreGuard {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
if self.active {
|
||||||
|
self.cleanup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn run(store: SecretStore) -> UiResult<()> {
|
fn run(store: SecretStore) -> UiResult<()> {
|
||||||
enable_raw_mode()?;
|
enable_raw_mode()?;
|
||||||
|
let guard = TerminalRestoreGuard::new();
|
||||||
let mut stdout = io::stdout();
|
let mut stdout = io::stdout();
|
||||||
execute!(stdout, EnterAlternateScreen, crossterm::cursor::Hide)?;
|
execute!(stdout, EnterAlternateScreen, crossterm::cursor::Hide)?;
|
||||||
let backend = CrosstermBackend::new(stdout);
|
let backend = CrosstermBackend::new(stdout);
|
||||||
let mut terminal = Terminal::new(backend)?;
|
let mut terminal = Terminal::new(backend)?;
|
||||||
let result = run_loop(&mut terminal, store);
|
let result = run_loop(&mut terminal, store);
|
||||||
let mut stdout = io::stdout();
|
drop(terminal);
|
||||||
let _ = execute!(stdout, crossterm::cursor::Show, LeaveAlternateScreen);
|
guard.restore();
|
||||||
let _ = disable_raw_mode();
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,8 @@ Builtin profiles and catalogs are embedded in the binary at build time. User/pro
|
||||||
Provider API key と WebSearch credential は、通常の runtime では環境変数から読まない。`insomnia keys` で local secret store に論理 id を追加し、profile / manifest / provider catalog / web config がその id を明示的に参照する。
|
Provider API key と WebSearch credential は、通常の runtime では環境変数から読まない。`insomnia keys` で local secret store に論理 id を追加し、profile / manifest / provider catalog / web config がその id を明示的に参照する。
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[[models]]
|
[model]
|
||||||
id = "anthropic/claude-sonnet-4"
|
ref = "anthropic/claude-sonnet-4-6"
|
||||||
scheme = "anthropic"
|
|
||||||
model = "claude-sonnet-4-20250514"
|
|
||||||
auth = { kind = "secret_ref", ref = "providers/anthropic/default" }
|
auth = { kind = "secret_ref", ref = "providers/anthropic/default" }
|
||||||
|
|
||||||
[web]
|
[web]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user