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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ zeroize = "1.8"
winit = "0.30"

[target."cfg(windows)".dependencies]
windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_UI_WindowsAndMessaging", "Win32_Graphics_Gdi", "Win32_UI_Input_KeyboardAndMouse", "Win32_System_Console", "Win32_Security_Credentials"] }
windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_UI_WindowsAndMessaging", "Win32_Graphics_Gdi", "Win32_UI_Input_KeyboardAndMouse", "Win32_System_Console", "Win32_Security_Credentials", "Win32_Storage_Xps"] }

[build-dependencies]
embed-resource = "3.0.12"
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,15 @@ MCP client configuration (Claude Desktop, Claude Code, Cursor …):

Tools: `list_connections`, `open_connection`, `scan_network`, `port_scan`, `dns_lookup`, `subnet`,
`check_certificate`, and for the open window `window_status`, `window_list_tabs`, `window_read_tab`,
`window_type`, `window_switch_tab`, `window_close_tab`, `window_open_tool`, `window_notify`.
`window_screenshot`, `window_type`, `window_switch_tab`, `window_close_tab`, `window_open_tool`, `window_notify`.
A fully encrypted connection list is read with the master password in `AC_MASTER`, a list kept in
KeePass with `AC_KEEPASS`.

**Control the open window** (Settings » AI agents): `admincraft cli window tabs | read [n] | type <n> <text> |
**Control the open window** (Settings » AI agents): `admincraft cli window tabs | read [n] | screenshot [n] [file.png] | type <n> <text> |
switch <n> | close <n> | tool <tool> [target]`. The window listens on 127.0.0.1 only, with a token in
the data folder; typing into terminals has to be allowed separately.
the data folder; typing has to be allowed separately. `read` gives a tab's text; where there is
none — a PuTTY, Remote Desktop or VNC window embedded in the tab — `screenshot` gives a picture
(MCP: an image). Typing works in terminal tabs and in embedded PuTTY windows.

## Keyboard

Expand Down
9 changes: 8 additions & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@ first, run `cargo fmt --check`, `cargo clippy --all-targets --locked -- -D warni
requests, tests green after each. This is the precondition for the next item.
9. **Shared CI.** Replace the jobs in `ci.yml` and `release.yml` by calls to the shared gate and
release workflows in `storytold/craft-common-actions` (they expect `cargo xtask ci`).
10. **Releases:** add an Intel macOS build; sign the Windows and macOS programs once
10. **Agents in Remote Desktop and VNC windows.** Agents can look at every tab
(`window screenshot`) and type into terminal tabs and embedded PuTTY windows. Remote Desktop
and VNC viewers don't take posted characters: they need real key and mouse input
(`SendInput`, which needs the keyboard focus and so interrupts the person at the computer).
If this is built: its own switch in the settings (it hands the whole remote desktop to the
agent), mouse clicks at a position of the screenshot, and special keys (Ctrl+C, arrows,
Tab) for PuTTY too. `src/embed.rs` and `src/app_control.rs`.
11. **Releases:** add an Intel macOS build; sign the Windows and macOS programs once
certificates exist.

Done and to be tried against real servers: the Remote Desktop login through the Credential
Expand Down
2 changes: 1 addition & 1 deletion docs/README.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Portabler Verbindungs-Manager für Windows, Linux und macOS – ähnlich mRemote
## Für Skripte und KI-Agenten

admincraft cli list | scan <bereich> | ports <host> | dns <name> | subnet <cidr> | cert <host>
admincraft cli window tabs | read [n] | type <n> <text> | switch <n> | tool <werkzeug> [ziel]
admincraft cli window tabs | read [n] | screenshot [n] [datei.png] | type <n> <text> | switch <n> | tool <werkzeug> [ziel]
admincraft mcp MCP-Server für KI-Assistenten (stdin/stdout)

`cli window …` steuert das **offene Fenster** (Einstellungen » KI-Agenten): Tabs lesen, Verbindungen und
Expand Down
3 changes: 2 additions & 1 deletion docs/help/de.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ admincraft cli window tabs die offenen Tabs
admincraft cli window read 2 was Tab 2 zeigt (Terminal, Ergebnisse)
admincraft cli window tool ping web01 einen Werkzeug-Tab öffnen
admincraft cli window switch 2 einen Tab nach vorn holen
admincraft cli window type 2 uptime in einen Terminal-Tab tippen + Enter
admincraft cli window screenshot 2 t.png Bild von Tab 2 (auch eingebettetes PuTTY / Remotedesktop)
admincraft cli window type 2 uptime in Terminal-Tab oder eingebettetes PuTTY tippen + Enter
```

Der MCP-Server bietet dasselbe als `window_…`-Werkzeuge. In Terminals tippen geht erst, wenn Sie es in den
Expand Down
3 changes: 2 additions & 1 deletion docs/help/en.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ admincraft cli window tabs the open tabs
admincraft cli window read 2 what tab 2 shows (terminal screen, results)
admincraft cli window tool ping web01 open a tool tab
admincraft cli window switch 2 bring a tab to the front
admincraft cli window type 2 uptime type into a terminal tab and press Enter
admincraft cli window screenshot 2 t.png picture of tab 2 (embedded PuTTY / Remote Desktop too)
admincraft cli window type 2 uptime type into a terminal tab or embedded PuTTY and press Enter
```

The MCP server offers the same as `window_…` tools. Typing into terminals is only possible after you
Expand Down
3 changes: 2 additions & 1 deletion docs/help/fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ admincraft cli window tabs les onglets ouverts
admincraft cli window read 2 ce que montre l'onglet 2
admincraft cli window tool ping web01 ouvrir un onglet d'outil
admincraft cli window switch 2 mettre un onglet au premier plan
admincraft cli window type 2 uptime taper dans un terminal + Entrée
admincraft cli window screenshot 2 t.png image de l'onglet 2 (PuTTY / Bureau à distance intégrés aussi)
admincraft cli window type 2 uptime taper dans un terminal ou un PuTTY intégré + Entrée
```

Le serveur MCP offre la même chose sous forme d'outils `window_…`. Taper dans les terminaux n'est possible
Expand Down
3 changes: 2 additions & 1 deletion docs/help/it.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ admincraft cli window tabs le schede aperte
admincraft cli window read 2 cosa mostra la scheda 2
admincraft cli window tool ping web01 apre una scheda strumento
admincraft cli window switch 2 porta una scheda in primo piano
admincraft cli window type 2 uptime scrive in un terminale + Invio
admincraft cli window screenshot 2 t.png immagine della scheda 2 (anche PuTTY / Desktop remoto incorporati)
admincraft cli window type 2 uptime scrive in un terminale o in un PuTTY incorporato + Invio
```

Il server MCP offre lo stesso come strumenti `window_…`. Scrivere nei terminali è possibile solo dopo averlo
Expand Down
3 changes: 2 additions & 1 deletion docs/help/uk.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ admincraft cli window tabs відкриті вкладки
admincraft cli window read 2 що показує вкладка 2
admincraft cli window tool ping web01 відкрити вкладку інструмента
admincraft cli window switch 2 вивести вкладку наперед
admincraft cli window type 2 uptime ввести в термінал + Enter
admincraft cli window screenshot 2 t.png зображення вкладки 2 (також вбудовані PuTTY / віддалений робочий стіл)
admincraft cli window type 2 uptime ввести в термінал або вбудований PuTTY + Enter
```

MCP-сервер пропонує те саме як інструменти `window_…`. Вводити текст у термінали можна лише після дозволу в
Expand Down
2 changes: 1 addition & 1 deletion lang/de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ Open download page = Download-Seite öffnen
AI agents = KI-Agenten
AI agents and scripts on this computer may control this window = KI-Agenten und Skripte auf diesem Computer dürfen dieses Fenster steuern
Only programs on this computer that can read the data folder. Passwords are never given out. = Nur Programme auf diesem Computer, die den Datenordner lesen können. Passwörter werden nie herausgegeben.
… and may type into terminal tabs = … und dürfen in Terminal-Tabs tippen
… and may type into terminal tabs and embedded PuTTY windows = … und dürfen in Terminal-Tabs und eingebettete PuTTY-Fenster tippen
Careful: an agent can then run commands on your servers. Every typing is shown in the window. = Vorsicht: Ein Agent kann dann Befehle auf Ihren Servern ausführen. Jedes Tippen wird im Fenster angezeigt.
Connect an agent: = Agent anbinden:
or = oder
Expand Down
2 changes: 1 addition & 1 deletion lang/fr.lang
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ Open download page = Ouvrir la page de téléchargement
AI agents = Agents IA
AI agents and scripts on this computer may control this window = Les agents IA et scripts de cet ordinateur peuvent piloter cette fenêtre
Only programs on this computer that can read the data folder. Passwords are never given out. = Seuls les programmes de cet ordinateur pouvant lire le dossier de données. Les mots de passe ne sont jamais transmis.
… and may type into terminal tabs = … et peuvent taper dans les onglets terminal
… and may type into terminal tabs and embedded PuTTY windows = … et peuvent taper dans les onglets terminal et les fenêtres PuTTY intégrées
Careful: an agent can then run commands on your servers. Every typing is shown in the window. = Attention : un agent peut alors exécuter des commandes sur vos serveurs. Chaque saisie est affichée dans la fenêtre.
Connect an agent: = Connecter un agent :
or = ou
Expand Down
2 changes: 1 addition & 1 deletion lang/it.lang
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ Open download page = Apri la pagina di download
AI agents = Agenti IA
AI agents and scripts on this computer may control this window = Agenti IA e script su questo computer possono controllare questa finestra
Only programs on this computer that can read the data folder. Passwords are never given out. = Solo programmi su questo computer che possono leggere la cartella dati. Le password non vengono mai fornite.
… and may type into terminal tabs = … e possono scrivere nelle schede terminale
… and may type into terminal tabs and embedded PuTTY windows = … e possono scrivere nelle schede terminale e nelle finestre PuTTY incorporate
Careful: an agent can then run commands on your servers. Every typing is shown in the window. = Attenzione: un agente può allora eseguire comandi sui tuoi server. Ogni digitazione viene mostrata nella finestra.
Connect an agent: = Collega un agente:
or = oppure
Expand Down
2 changes: 1 addition & 1 deletion lang/uk.lang
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ Open download page = Відкрити сторінку завантаження
AI agents = ШІ-агенти
AI agents and scripts on this computer may control this window = ШІ-агенти та скрипти на цьому комп'ютері можуть керувати цим вікном
Only programs on this computer that can read the data folder. Passwords are never given out. = Лише програми на цьому комп'ютері, що можуть читати папку даних. Паролі ніколи не видаються.
… and may type into terminal tabs = … і можуть вводити текст у вкладки термінала
… and may type into terminal tabs and embedded PuTTY windows = … і можуть вводити текст у вкладки термінала та вбудовані вікна PuTTY
Careful: an agent can then run commands on your servers. Every typing is shown in the window. = Обережно: агент тоді може виконувати команди на ваших серверах. Кожне введення показується у вікні.
Connect an agent: = Підключити агента:
or = або
Expand Down
28 changes: 23 additions & 5 deletions src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::net::{SocketAddr, TcpStream, ToSocketAddrs};
use std::time::Duration;

/// Tool name, description, JSON schema of its arguments.
fn tool_list() -> Vec<(&'static str, &'static str, Value)> {
pub(crate) fn tool_list() -> Vec<(&'static str, &'static str, Value)> {
vec![
(
"list_connections",
Expand Down Expand Up @@ -69,9 +69,14 @@ fn tool_list() -> Vec<(&'static str, &'static str, Value)> {
"What a tab of the open window shows as text: a terminal's screen, ping/DNS output, port or network scan results, a certificate check. Default: the active tab.",
json!({"type": "object", "properties": {"index": {"type": "integer"}}}),
),
(
"window_screenshot",
"A picture (PNG) of what a tab of the open window shows, including a PuTTY, Remote Desktop or VNC window embedded in it, where window_read_tab has no text. The tab is brought to the front. Default: the active tab.",
json!({"type": "object", "properties": {"index": {"type": "integer"}}}),
),
(
"window_type",
"Type text into a terminal tab of the open window (SSH, Telnet, PowerShell, shell). Only works when the person allowed it in Settings » AI agents. Set enter=true to press Enter after the text.",
"Type text into a terminal tab of the open window (SSH, Telnet, PowerShell, shell) or into an embedded PuTTY window (look at the result with window_screenshot). Only works when the person allowed it in Settings » AI agents. Set enter=true to press Enter after the text.",
json!({"type": "object", "properties": {"index": {"type": "integer"}, "text": {"type": "string"}, "enter": {"type": "boolean"}}, "required": ["text"]}),
),
(
Expand Down Expand Up @@ -254,7 +259,8 @@ const HELP: &str = "AdminCraft command line (JSON output)
admincraft cli cert <host> [port] TLS certificate check
admincraft cli window tabs tabs of the open window
admincraft cli window read [index] text a tab shows (terminal screen, results)
admincraft cli window type <index> <text> type into a terminal tab (+ Enter), if allowed
admincraft cli window screenshot [index] [file.png] picture of a tab (embedded PuTTY/RDP too)
admincraft cli window type <index> <text> type into a terminal tab or embedded PuTTY (+ Enter), if allowed
admincraft cli window switch|close <index> bring a tab to the front / close it
admincraft cli window tool <tool> [target] open a tool: ping, portscan, dns, netscan, cert, whois, http, snmp …
admincraft cli window <command> [json] any command, e.g. status, notify {\"text\":\"hi\"}
Expand All @@ -278,6 +284,7 @@ pub fn cli(args: &[String]) -> i32 {
let (cmd, params) = match a(1).as_str() {
"tabs" | "" => ("list_tabs".to_string(), json!({})),
"read" => ("read_tab".to_string(), json!({"index": idx(a(2))})),
"screenshot" => ("screenshot".to_string(), json!({"index": idx(a(2)), "path": a(3)})),
"type" => (
"type_text".to_string(),
json!({"index": idx(a(2)), "text": args.get(3..).map(|x| x.join(" ")).unwrap_or_default(), "enter": true}),
Expand Down Expand Up @@ -359,11 +366,22 @@ pub fn handle(line: &str, out: &mut impl Write) {
"tools/call" => {
let name = req.pointer("/params/name").and_then(|v| v.as_str()).unwrap_or("");
let args = req.pointer("/params/arguments").cloned().unwrap_or(json!({}));
let (text, is_error) = match call(name, &args) {
let result = call(name, &args);
// a screenshot goes back as a picture, not as the name of a file
let picture = match (&result, name) {
(Ok(v), "window_screenshot") => v["file"].as_str().and_then(|f| std::fs::read(f).ok()),
_ => None,
};
let (text, is_error) = match result {
Ok(v) => (serde_json::to_string_pretty(&v).unwrap_or_default(), false),
Err(e) => (e, true),
};
reply(out, &id, json!({"content": [{"type": "text", "text": text}], "isError": is_error}));
let mut content = vec![json!({"type": "text", "text": text})];
if let Some(png) = picture {
use base64::Engine as _;
content.insert(0, json!({"type": "image", "data": base64::engine::general_purpose::STANDARD.encode(png), "mimeType": "image/png"}));
}
reply(out, &id, json!({"content": content, "isError": is_error}));
}
_ => error(out, &id, -32601, "method not found"),
}
Expand Down
13 changes: 10 additions & 3 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ pub struct AdminApp {
help_request: Option<crate::help::Topic>,
/// The channel agents use to control this window (None when switched off).
control: Option<crate::control::Server>,
/// A picture of a tab an agent asked for; answered a few frames later, once the tab is drawn.
agent_shot: Option<app_control::AgentShot>,
/// Result of "Check for updates" (None inside while it runs).
update_result: Option<UpdateSlot>,
releases_url: String,
Expand Down Expand Up @@ -362,6 +364,7 @@ impl AdminApp {
show_keys: false,
help_request: None,
control: None,
agent_shot: None,
update_result: None,
releases_url: crate::update::releases_page(),
focus_search: false,
Expand Down Expand Up @@ -499,8 +502,10 @@ impl AdminApp {
"embedtest" => {
// check of the window embedding with a harmless program (Character Map)
let e = Entry { name: tr("Embedding (test)").into(), protocol: Protocol::Vnc, ..Default::default() };
let prog = if host.is_empty() { "charmap.exe".to_string() } else { host.clone() };
match std::process::Command::new(&prog).spawn() {
// a program with arguments works too: embedtest:"C:\Tools\putty.exe" -raw -P 5599 127.0.0.1
let mut words = launch::split_words(&host).into_iter();
let prog = words.next().unwrap_or_else(|| "charmap.exe".to_string());
match std::process::Command::new(&prog).args(words).spawn() {
Ok(child) => {
let pid = child.id();
app.add_tab(
Expand Down Expand Up @@ -3662,7 +3667,8 @@ impl AdminApp {
.on_hover_text(tr("Only programs on this computer that can read the data folder. Passwords are never given out."))
.changed();
ui.add_enabled_ui(self.store.data.settings.agent_control, |ui| {
changed |= ui.checkbox(&mut self.store.data.settings.agent_typing, tr("… and may type into terminal tabs")).changed();
changed |=
ui.checkbox(&mut self.store.data.settings.agent_typing, tr("… and may type into terminal tabs and embedded PuTTY windows")).changed();
if self.store.data.settings.agent_typing {
ui.colored_label(
Color32::from_rgb(255, 183, 77),
Expand Down Expand Up @@ -4294,6 +4300,7 @@ impl eframe::App for AdminApp {
}
embed::set_active(active_embed);
self.tab_screenshot(&ctx, now);
self.agent_shot_step(&ctx);

// background jobs: tunnels, monitoring, changes by colleagues, dialogs
extra::poll_tunnels(&mut self.tunnels);
Expand Down
Loading
Loading