| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
use super::repo::Quickstart; |
| 6 |
use super::{Page, Shell}; |
| 7 |
use crate::auth::Viewer; |
| 8 |
use crate::Shared; |
| 9 |
use askama::Template; |
| 10 |
use axum::extract::State; |
| 11 |
|
| 12 |
#[derive(Template)] |
| 13 |
#[template(path = "help.html")] |
| 14 |
pub struct HelpPage { |
| 15 |
shell: Shell, |
| 16 |
q: Quickstart, |
| 17 |
base: String, |
| 18 |
|
| 19 |
who: String, |
| 20 |
} |
| 21 |
|
| 22 |
pub async fn help(State(app): State<Shared>, viewer: Viewer) -> Page<HelpPage> { |
| 23 |
let shell = Shell::new(&app, "/help", &viewer); |
| 24 |
let who = shell.user.clone().unwrap_or_else(|| "OWNER".into()); |
| 25 |
let base = app.config.base_url().trim_end_matches('/').to_string(); |
| 26 |
Page(HelpPage { shell, q: Quickstart::new(&app, true), base, who }) |
| 27 |
} |
| 28 |
|
| 29 |
impl HelpPage { |
| 30 |
|
| 31 |
pub fn ca_setup(&self) -> String { |
| 32 |
match &self.q.ca_url { |
| 33 |
Some(url) => format!("mkdir -p ~/.config/oxy\ncurl -fsSL {url} -o {}", self.q.ca_file), |
| 34 |
None => String::new(), |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
pub fn repo_url(&self) -> String { |
| 40 |
format!("{}/{}/REPOSITORY", self.base, self.who) |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
pub fn agent_home_cmd(&self) -> String { |
| 45 |
format!( |
| 46 |
"export OXY_HOME=~/.oxy-agents/claude\noxy config --user author.signer keyless\noxy config --user keyless.hub {base}\noxy config --user core.sign seal\noxy auth grant {base} # paste the token, then Ctrl-D", |
| 47 |
base = self.base |
| 48 |
) |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
pub fn subject_grant_cmd(&self) -> String { |
| 53 |
format!( |
| 54 |
"curl -fsSL {}/.well-known/oxyhub-key -o hub.identity\noxy policy grant-subject agent:claude@{} --issuer hub.identity --scope changes,refs", |
| 55 |
self.base, self.who |
| 56 |
) |
| 57 |
} |
| 58 |
|
| 59 |
pub fn delegate_cmd(&self) -> String { |
| 60 |
format!( |
| 61 |
"curl -fsSL {}/.well-known/oxyhub-key -o hub.identity\noxy identity delegate add hub.identity --scope changes,refs", |
| 62 |
self.base |
| 63 |
) |
| 64 |
} |
| 65 |
|
| 66 |
pub fn clone_cmd(&self) -> String { |
| 67 |
let url = self.repo_url(); |
| 68 |
match &self.q.ca_url { |
| 69 |
Some(_) => format!("OXY_CA={} oxy clone {url}", self.q.ca_file), |
| 70 |
None => format!("oxy clone {url}"), |
| 71 |
} |
| 72 |
} |
| 73 |
} |