forked from vhaudiquet/rhema-claw
feat(claw): run bash on an ssh login, no daemon on the far end
The framework ships rhema-sandbox-ssh; the claw's sandbox seam now wires it as a third kind beside local and http. The ssh choice carries a host (any destination the local ssh config resolves) and a workspace base, default /root, with one directory per claw workspace under it so two sessions never share a root. The seed probe makes the root first and quotes it for the remote bash. The settings screen gains the SSH host card, and /v1/sandbox carries host and workspace. The rhema family moves to 0.4.1 in lockstep to pick the crate up.
This commit is contained in:
1 parent
24d2323cd3
commit
473a7765e7
13 files changed
+544
-135
No files matched your search
@@ -1 +1,2 @@
|
||||
/target/
|
||||
.rhema/
|
||||
Generated
+70
-55
@@ -1906,9 +1906,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-autonomous-agent"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08fd6d5fe5f9551226d322491d03b14d5e42ac2ff73544c15a555fb97a04bbfd"
|
||||
checksum = "46677fb855ebb628da602111fa2595ad363401c7101c07f07a602dbc86a1dd8a"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"rhema-core",
|
||||
@@ -1922,9 +1922,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-bash"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf9ae34e5c556e0abdf279dd7d0aa08632bdcd68cff965bce2b81c226ada8f1e"
|
||||
checksum = "1e0aacc9aac461f674ec7f72dc321b11edc4c7868d3c635c2b1c58dbd9256c80"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.22.1",
|
||||
@@ -1982,6 +1982,7 @@ dependencies = [
|
||||
"rhema-rsd",
|
||||
"rhema-sandbox",
|
||||
"rhema-sandbox-http",
|
||||
"rhema-sandbox-ssh",
|
||||
"rhema-transcript",
|
||||
"rusqlite",
|
||||
"serde",
|
||||
@@ -2006,9 +2007,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-config"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0bbfb885f219272d24534c004819db377cf5370de0f82a851f9329466a5349c"
|
||||
checksum = "0a05d1d30472d7ea03685806b69e0e9984744b0349cc7c7ad53497916b6c2be1"
|
||||
dependencies = [
|
||||
"keyring",
|
||||
"rhema-core",
|
||||
@@ -2020,9 +2021,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-core"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3cd4c7a28b121243a2e26371e53750f28368e96c1a1629f021847c717e1cd55"
|
||||
checksum = "de9d3c12019209170cbf82fa75dcad4ec10c3c712f7235d9f9a60f165cab5d8c"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"serde",
|
||||
@@ -2046,9 +2047,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-host-agent"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c10a82a420f1ea5ad1e68cabf0da67e6d05f18ec9e6fa02993969c2dcc53a68"
|
||||
checksum = "973dc8ee54a24065c7996b23e0cfd2eba715687394a248583582faca3d7a5c4c"
|
||||
dependencies = [
|
||||
"minijinja",
|
||||
"rhema-bash",
|
||||
@@ -2066,9 +2067,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-identity"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1bb799ae7395c647577b9cf26208d81c2913d893db050adc82976e88436226c"
|
||||
checksum = "3188f0fec1338df315c76034909e8ff7c1314a84ff6dd0ac11793d605d655b5b"
|
||||
dependencies = [
|
||||
"rusqlite",
|
||||
"serde",
|
||||
@@ -2077,9 +2078,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-mcp"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ed674931827b5b5e3130b376bda837cf49bda6ca6c94392430b74e292b6f516"
|
||||
checksum = "0dd8f9ee0b0699c09efb303dfc17ed3049aabc8a7b3e01d211de283c43c8c19b"
|
||||
dependencies = [
|
||||
"async-stream",
|
||||
"axum",
|
||||
@@ -2104,9 +2105,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-memory"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34d3b6763b7c567849b6f1787bae7152ce92ec38bdbe2ec27691d4ef2596c259"
|
||||
checksum = "abdfee3e709305e86cedc3e60ca59776af512b2bf520ab87d7da1d184f01d560"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"rhema-core",
|
||||
@@ -2118,9 +2119,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-prompt"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b70bba0a045879067817db80fcaa7578dc32ef699786cc004b8fdb73bccc47e4"
|
||||
checksum = "2ecbf1ae5d134d110c8f3b4c47ad2331f703bd7bb1ad6d53b4108787d894c8bd"
|
||||
dependencies = [
|
||||
"minijinja",
|
||||
"rhema-core",
|
||||
@@ -2131,9 +2132,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-provider"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c400c1ac8430f78184ecc12024605686a988ada7a3ee30dd67a4ce12114ccb9e"
|
||||
checksum = "15855c3fa2d858622cd55bd6323d4a7533066e52a74e3dc440ffe69c12ed1263"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"futures-core",
|
||||
@@ -2147,9 +2148,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-provider-anthropic"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a57458493f5b1fb540fa47f558f7743094dc123d2c06815d2078f9303d9df22f"
|
||||
checksum = "223a60c52ce2e548f72a9f2cce6f7a48be954bd3e5b959ff70d308b3d42d6425"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"futures-util",
|
||||
@@ -2163,9 +2164,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-provider-chatgpt"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7642b1e0bc194cc81d7f347182eecd6702a04a85de41912bd2d34b2cdf41ca7b"
|
||||
checksum = "ec84f3f5601e8ca6e69f92a291480842058352bb580b985ec23db713505b8f5d"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.22.1",
|
||||
@@ -2182,15 +2183,16 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-provider-copilot"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb39fa7f059df415bdef2453e58ad5359fd74eeb39f7981179f03c78ffb5af7d"
|
||||
checksum = "c6685a56017c7de21d17384d25f941f2733526d581dfafc5cd7371d4f6e82096"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"futures-util",
|
||||
"reqwest",
|
||||
"rhema-core",
|
||||
"rhema-provider",
|
||||
"rhema-provider-anthropic",
|
||||
"rhema-provider-openai-compatible",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -2200,9 +2202,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-provider-google"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7dda76eea354cfbdfd4a2dfa1fc1ce8da823675699cf2bf4d3ace8560fec2cd7"
|
||||
checksum = "749f27fcf2ad1c7745cabc85e56d05e116bce30b6be317910f0c455ba4147ff9"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"futures-util",
|
||||
@@ -2216,9 +2218,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-provider-llama-cpp"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "953181611b909688db511f891e8c59e034b90bd798034f1afef36cac05409566"
|
||||
checksum = "bf5d26ec681baac6b8c6fc752470a78205acb11f763987bf571fa54be1195e2a"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"futures-util",
|
||||
@@ -2233,9 +2235,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-provider-mistral"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f657297d7d617a14b10bb6248e944d053d73a536d3b6ae4ee4cc8acabcb4a57"
|
||||
checksum = "4d8ae3c2c924202d3614987b6b7c4930d84a19ebb2264747bb5100f1f67db7ff"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.22.1",
|
||||
@@ -2252,9 +2254,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-provider-openai-compatible"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a90f1620882b2a3dbdb00065b29c329622c5596f582027b29130fbd40003b450"
|
||||
checksum = "aab0c24d2d558d66de1f002c250d05c25d9c52038e4fa1890f6c40644c4f9702"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"futures-util",
|
||||
@@ -2268,9 +2270,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-provider-opencode"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2068c980362fe3d4f7876e5e842f51c0719626449afac64192592865e11a0108"
|
||||
checksum = "3eb4c641b7997ba5cab41bede6c4b7331baa9a9b2298d5bb0ffbc8844df6dbf3"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"reqwest",
|
||||
@@ -2283,9 +2285,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-provider-openrouter"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2025f84d6a1fd1e513ffad4b374d280f0db600ffac635dfe08a58d04b03e91d"
|
||||
checksum = "7170cef8b456c8f1df1b565d16ad3c61c4b252e521fff16718eacca5d7d98605"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"futures-util",
|
||||
@@ -2299,9 +2301,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-provider-registry"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be5ed790e3dc4fc3a42bd9b1a633ef72204c519810ce03dafb2792a8ff0b6bf8"
|
||||
checksum = "c93ceacbe2332f122b23a11de11ddf4a502a96baaa8c95f33882c5c589581dce"
|
||||
dependencies = [
|
||||
"rhema-core",
|
||||
"rhema-provider",
|
||||
@@ -2319,9 +2321,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-rsd"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3a4bd0555ff3720c0501187f5e9c6ee19ebebb95c1ecdb296c509c2e2dd971ce"
|
||||
checksum = "8e97a9d363b432147220a0646a158ea7a08d6012efa1bedf169fd973721dd745"
|
||||
dependencies = [
|
||||
"rhema-core",
|
||||
"rusqlite",
|
||||
@@ -2332,9 +2334,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-sandbox"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7030dbd46aa8a2398452dcf86b6b39d13b82909b9fdc654c49e1374183594779"
|
||||
checksum = "3d5aaa76f2400989439f325754a29593669c1275485796150e19b04277ea54fb"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"rhema-bash",
|
||||
@@ -2342,13 +2344,14 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rhema-sandbox-http"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5171470a8a56246e036aa10fc63e641ae7907a3ce70ac8f4816f3c9499eb75b"
|
||||
checksum = "6f4cbb9f2238961082a8b406da460c84ced75f4d6bb9e52a79b41dc17065b601"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.22.1",
|
||||
@@ -2359,10 +2362,22 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rhema-session-store"
|
||||
version = "0.4.0"
|
||||
name = "rhema-sandbox-ssh"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef2dd4aca030a56e438c136099d3f07d6fd4649a3db1be6c9838a68a6530cbf6"
|
||||
checksum = "578252c65b6e8047b8f013d2d0a0bd867991b50ed31a530cdfa1304d158a6e65"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.22.1",
|
||||
"rhema-sandbox",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rhema-session-store"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00548f40bf2ec40381d4f9d60a1e136c66d7c4c334097a5eebafe21169915f5c"
|
||||
dependencies = [
|
||||
"rhema-core",
|
||||
"serde",
|
||||
@@ -2372,9 +2387,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-session-store-file"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5ff65f110123026ae79679572b084c517693f81e0d464897e580b64985a9507"
|
||||
checksum = "df75d21d1ad25b16cb72fc3747d435415e7423872b51fa3751094a5a6e380543"
|
||||
dependencies = [
|
||||
"rhema-config",
|
||||
"rhema-core",
|
||||
@@ -2384,9 +2399,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-submissions"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d054ba904c324ef057c8fb4b9c88a40703496c8b621768844af56a8893d3fb99"
|
||||
checksum = "dba11599010c7537800bee275dd9d414162dd57806b1d75c54ef98f126eb9f65"
|
||||
dependencies = [
|
||||
"rhema-core",
|
||||
"rhema-session-store",
|
||||
@@ -2397,9 +2412,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhema-transcript"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "800261e8c1f29e6ceee48769bba2aaea19ccd3496ff8c6c76c617aa7d53ec2db"
|
||||
checksum = "592b80da0bf1c84e4da814639383dc33c5d2eeee522db5bd93bb779bf0e34e10"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"rhema-core",
|
||||
|
||||
@@ -29,33 +29,34 @@ mock = ["rhema-core/mock"]
|
||||
# shell, the approval seam, and revive-on-resume (rhema-bash), the
|
||||
# system-prompt renderer (rhema-prompt), and the driver that turns a
|
||||
# provider into a host-operating agent (rhema-host-agent)
|
||||
rhema-bash = "0.4.0"
|
||||
rhema-prompt = "0.4.0"
|
||||
rhema-host-agent = "0.4.0"
|
||||
rhema-autonomous-agent = "0.4.0"
|
||||
rhema-config = "0.4.0"
|
||||
rhema-core = "0.4.0"
|
||||
rhema-bash = "0.4.1"
|
||||
rhema-prompt = "0.4.1"
|
||||
rhema-host-agent = "0.4.1"
|
||||
rhema-autonomous-agent = "0.4.1"
|
||||
rhema-config = "0.4.1"
|
||||
rhema-core = "0.4.1"
|
||||
# The bounded request view over the claw sessions, on by default here
|
||||
rhema-transcript = "0.4.0"
|
||||
rhema-transcript = "0.4.1"
|
||||
rhema-calendar-integration = { path = "../../integrations/rhema-calendar-integration" }
|
||||
rhema-forge-integration = { path = "../../integrations/rhema-forge-integration" }
|
||||
# The accounts layer: identities hold the forge tokens the watches poll
|
||||
# with, and the identity tools manage them over chat
|
||||
rhema-identity = "0.4.0"
|
||||
rhema-rsd = "0.4.0"
|
||||
# The sandbox seam: where `bash` runs, local process or a daemon speaking
|
||||
# the wire protocol over HTTP
|
||||
rhema-sandbox = "0.4.0"
|
||||
rhema-sandbox-http = "0.4.0"
|
||||
rhema-identity = "0.4.1"
|
||||
rhema-rsd = "0.4.1"
|
||||
# The sandbox seam: where `bash` runs, this host's processes, a daemon
|
||||
# speaking the wire protocol over HTTP, or an ssh login on a far box
|
||||
rhema-sandbox = "0.4.1"
|
||||
rhema-sandbox-http = "0.4.1"
|
||||
rhema-sandbox-ssh = "0.4.1"
|
||||
# The tool contract: the agent-token allowlist and version the auth
|
||||
# middleware enforces (rhema-tools spec). The arrow runs claw ->
|
||||
# contract only — never the reverse.
|
||||
rhema-claw-tools-contract = { path = "../../tools/contract" }
|
||||
# The resident tier's durable memory: its tools join the resolver chain
|
||||
rhema-memory = "0.4.0"
|
||||
rhema-memory = "0.4.1"
|
||||
# The shared ModelCard the backend registry's listings return
|
||||
rhema-provider = "0.4.0"
|
||||
rhema-provider-registry = "0.4.0"
|
||||
rhema-provider = "0.4.1"
|
||||
rhema-provider-registry = "0.4.1"
|
||||
# Args for the two-flag binary surface
|
||||
clap = { version = "4.5", features = ["derive"] }
|
||||
serde = { workspace = true }
|
||||
@@ -80,7 +81,7 @@ time = { version = "0.3", default-features = false, features = ["parsing"] }
|
||||
# Inbound chat images ride base64; the dispatch decodes them into the
|
||||
# attachment store
|
||||
base64 = "0.22"
|
||||
rhema-mcp = "0.4.0"
|
||||
rhema-mcp = "0.4.1"
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3"
|
||||
@@ -92,7 +93,7 @@ reqwest = { version = "0.12", features = ["json", "stream"] }
|
||||
bytes = "1"
|
||||
# The scripted provider for turn-level tests; mirrors rhema-code's mock
|
||||
# feature without a feature of our own — tests are the only consumer
|
||||
rhema-core = { version = "0.4.0", features = ["mock"] }
|
||||
rhema-core = { version = "0.4.1", features = ["mock"] }
|
||||
tokio = { workspace = true, features = ["rt-multi-thread", "macros", "sync", "time"] }
|
||||
|
||||
[lints]
|
||||
|
||||
@@ -70,9 +70,11 @@ token: change-me # optional; when set, /v1/* requires it
|
||||
agent_token: change-me-too # the client tools' scoped bearer (rhema-tools)
|
||||
tools_bin: ~/.local/share/rhema-tools/bin # put the client tools on PATH
|
||||
sandbox: # where bash runs; omit for this host
|
||||
kind: http # local (default) or http
|
||||
url: https://box.example:7600 # the sandboxd base URL
|
||||
token: sandbox-secret # the daemon's shared secret, if it has one
|
||||
kind: ssh # local (default), http, or ssh
|
||||
host: me@box.example # the ssh destination: an alias or user@host
|
||||
workspace: /srv/claw # ssh only: the workspace base, default /root
|
||||
# http instead speaks the sandbox protocol (rhema-sandboxd):
|
||||
# kind: http, url: https://box.example:7600, token: sandbox-secret
|
||||
poll_interval_secs: 120
|
||||
max_turn_steps: 2048 # tool rounds one chat turn may run
|
||||
watches: # a seed: imported while the table is empty
|
||||
@@ -103,10 +105,15 @@ conversation intact; a follow-up message keeps going.
|
||||
`sandbox` selects where the agent's `bash` runs. Unset or `kind: local`
|
||||
keeps the daemon's own processes. `kind: http` sends commands to a host
|
||||
speaking the sandbox protocol (`rhema-sandboxd`), with `url` and an
|
||||
optional `token`. The settings screen writes the same choice to the
|
||||
optional `token`. `kind: ssh` runs commands on a login the local `ssh`
|
||||
config resolves (`host`, any alias or `user@host`), nothing installed
|
||||
on the far end; `workspace` names the remote directory the claw's
|
||||
workspaces live under, `/root` by default, one directory per claw
|
||||
workspace under it. The settings screen writes the same choice to the
|
||||
settings table, and the next turn reads it; no restart is needed. On
|
||||
first use the claw copies the local workspace into the sandbox's
|
||||
`/workspace`. Later edits stay there; the claw does not copy them back.
|
||||
workspace root. Later edits stay there; the claw does not copy them
|
||||
back.
|
||||
|
||||
The surface refuses to start on a non-loopback `listen` with no
|
||||
`token`: anything beyond loopback can reach the port, and the bearer
|
||||
@@ -150,7 +157,7 @@ GET /v1/attachments/{id} an attached file's bytes
|
||||
GET /v1/phone/commands?device= the device's queued, unconfirmed commands
|
||||
POST /v1/phone/commands/{id}/result {"ok", "detail"?} — the device's report
|
||||
GET /v1/sandbox where the agent's bash runs
|
||||
PUT /v1/sandbox {"kind","url"?,"token"?}, switch and persist
|
||||
PUT /v1/sandbox {"kind","url"?,"token"?,"host"?,"workspace"?}, switch and persist
|
||||
GET /v1/providers the backend instances + the active pair
|
||||
PUT /v1/providers/active {"provider","model"?} — switch, persisted
|
||||
PUT /v1/providers/{id}/credentials add or replace an instance, persisted
|
||||
|
||||
@@ -464,6 +464,15 @@ sandbox:
|
||||
assert_eq!(sandbox.kind, crate::sandbox::SandboxKind::Http);
|
||||
assert_eq!(sandbox.url.as_deref(), Some("https://box.example:7600"));
|
||||
assert_eq!(sandbox.token.as_deref(), Some("sandbox-secret"));
|
||||
|
||||
let config: ClawConfig = serde_yaml::from_str(
|
||||
"sandbox:\n kind: ssh\n host: me@box.example\n workspace: /srv/claw\n",
|
||||
)
|
||||
.expect("the ssh sandbox parses");
|
||||
let sandbox = config.sandbox.expect("the sandbox parses");
|
||||
assert_eq!(sandbox.kind, crate::sandbox::SandboxKind::Ssh);
|
||||
assert_eq!(sandbox.host.as_deref(), Some("me@box.example"));
|
||||
assert_eq!(sandbox.workspace.as_deref(), Some("/srv/claw"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -472,7 +481,7 @@ sandbox:
|
||||
sandbox: Some(crate::sandbox::SandboxChoice {
|
||||
kind: crate::sandbox::SandboxKind::Http,
|
||||
url: None,
|
||||
token: None,
|
||||
..crate::sandbox::SandboxChoice::default()
|
||||
}),
|
||||
..ClawConfig::default()
|
||||
};
|
||||
@@ -484,13 +493,37 @@ sandbox:
|
||||
sandbox: Some(crate::sandbox::SandboxChoice {
|
||||
kind: crate::sandbox::SandboxKind::Http,
|
||||
url: Some("https://box.example:7600".to_owned()),
|
||||
token: None,
|
||||
..crate::sandbox::SandboxChoice::default()
|
||||
}),
|
||||
..ClawConfig::default()
|
||||
};
|
||||
assert!(valid.validate().is_ok(), "a complete remote choice passes");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_ssh_sandbox_needs_a_host_at_boot() {
|
||||
let missing = ClawConfig {
|
||||
sandbox: Some(crate::sandbox::SandboxChoice {
|
||||
kind: crate::sandbox::SandboxKind::Ssh,
|
||||
..crate::sandbox::SandboxChoice::default()
|
||||
}),
|
||||
..ClawConfig::default()
|
||||
};
|
||||
assert!(
|
||||
matches!(missing.validate(), Err(ConfigError::Sandbox(_))),
|
||||
"an ssh sandbox without a host is refused at boot"
|
||||
);
|
||||
let valid = ClawConfig {
|
||||
sandbox: Some(crate::sandbox::SandboxChoice {
|
||||
kind: crate::sandbox::SandboxKind::Ssh,
|
||||
host: Some("me@box.example".to_owned()),
|
||||
..crate::sandbox::SandboxChoice::default()
|
||||
}),
|
||||
..ClawConfig::default()
|
||||
};
|
||||
assert!(valid.validate().is_ok(), "a bare login is all ssh needs");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_unknown_key_is_rejected_and_named() {
|
||||
let err = serde_yaml::from_str::<ClawConfig>("listne: 127.0.0.1:7799\n")
|
||||
|
||||
@@ -2016,6 +2016,8 @@ fn sandbox_json(state: &ClawState) -> Value {
|
||||
"kind": choice.kind.as_str(),
|
||||
"url": choice.url,
|
||||
"token_set": choice.token.as_deref().is_some_and(|token| !token.is_empty()),
|
||||
"host": choice.host,
|
||||
"ssh_workspace": choice.workspace,
|
||||
"workspace": state.sandbox().workspace().display().to_string(),
|
||||
"local_workspace": state.sandbox().local_workspace().display().to_string(),
|
||||
"remote_workspace": crate::sandbox::REMOTE_WORKSPACE,
|
||||
@@ -2051,6 +2053,14 @@ async fn sandbox_put(
|
||||
.map(str::to_owned)
|
||||
.or_else(|| current.url.clone()),
|
||||
token,
|
||||
host: body["host"]
|
||||
.as_str()
|
||||
.map(str::to_owned)
|
||||
.or_else(|| current.host.clone()),
|
||||
workspace: body["workspace"]
|
||||
.as_str()
|
||||
.map(str::to_owned)
|
||||
.or_else(|| current.workspace.clone()),
|
||||
};
|
||||
state.sandbox().set(choice).map_err(|err| match err {
|
||||
crate::sandbox::SandboxError::Invalid(_) => bad_request(err),
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
//! Where the claw's `bash` runs: this host's processes, or a daemon
|
||||
//! speaking the sandbox protocol over HTTP.
|
||||
//! Where the claw's `bash` runs: this host's processes, a daemon
|
||||
//! speaking the sandbox protocol over HTTP, or an ssh login on a far
|
||||
//! box.
|
||||
//!
|
||||
//! The choice is deployment state, persisted in the settings table and
|
||||
//! changeable over `/v1/sandbox`. `local` keeps the shell the claw
|
||||
//! always had. `http` builds an `HttpSandbox` for a `rhema-sandboxd`
|
||||
//! and gives the handlers a `ShellSandbox` executor over it. The tool
|
||||
//! spec, approval gate, output caps, and error shaping stay in
|
||||
//! `ShellTools`; only the machine changes.
|
||||
//! always had. `http` builds an `HttpSandbox` for a `rhema-sandboxd`.
|
||||
//! `ssh` builds an `SshSandbox` on a destination the local ssh config
|
||||
//! resolves, no daemon on the far end. The tool spec, approval gate,
|
||||
//! output caps, and error shaping stay in `ShellTools`; only the
|
||||
//! machine changes.
|
||||
//!
|
||||
//! A remote sandbox starts empty. On the first command for a
|
||||
//! workspace, the executor probes `/workspace` and, when it is empty,
|
||||
//! sends the host workspace as a tarball through the protocol's seed
|
||||
//! workspace, the executor probes the workspace root and, when it is
|
||||
//! empty, sends the host workspace as a tarball through the seed
|
||||
//! route. Later edits stay in the sandbox; the claw does not copy them
|
||||
//! back.
|
||||
|
||||
@@ -25,6 +27,7 @@ use base64::Engine as _;
|
||||
use rhema_bash::exec::{Executed, ShellError, ShellExecutor, default_executor_with};
|
||||
use rhema_sandbox::{ExecRequest, Sandbox, ShellSandbox, WorkspaceSeed};
|
||||
use rhema_sandbox_http::HttpSandbox;
|
||||
use rhema_sandbox_ssh::SshSandbox;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::settings::SettingsStore;
|
||||
@@ -32,10 +35,15 @@ use crate::settings::SettingsStore;
|
||||
/// The settings key the chosen sandbox is persisted under.
|
||||
pub const SANDBOX_KEY: &str = "sandbox";
|
||||
|
||||
/// The workspace path a remote sandbox exposes: one root per session,
|
||||
/// The workspace path the http sandbox exposes: one root per session,
|
||||
/// fixed by the protocol.
|
||||
pub const REMOTE_WORKSPACE: &str = "/workspace";
|
||||
|
||||
/// The ssh sandbox's default workspace base: the remote login's own
|
||||
/// home, the ssh backend's documented default. One directory per claw
|
||||
/// workspace lands under it, named by the session hash.
|
||||
pub const SSH_WORKSPACE_ROOT: &str = "/root";
|
||||
|
||||
/// The per-command budget of the emptiness probe before a seed: long
|
||||
/// enough for a fresh sandbox, short enough that an unreachable daemon
|
||||
/// fails the turn rather than stalling it.
|
||||
@@ -50,6 +58,8 @@ pub enum SandboxKind {
|
||||
Local,
|
||||
/// A host speaking the sandbox protocol over HTTP.
|
||||
Http,
|
||||
/// A remote login reached with `ssh`, no daemon on the far end.
|
||||
Ssh,
|
||||
}
|
||||
|
||||
impl SandboxKind {
|
||||
@@ -58,6 +68,7 @@ impl SandboxKind {
|
||||
match self {
|
||||
Self::Local => "local",
|
||||
Self::Http => "http",
|
||||
Self::Ssh => "ssh",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +78,7 @@ impl SandboxKind {
|
||||
match value {
|
||||
"local" => Some(Self::Local),
|
||||
"http" => Some(Self::Http),
|
||||
"ssh" => Some(Self::Ssh),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -86,6 +98,14 @@ pub struct SandboxChoice {
|
||||
/// The shared secret the daemon checks, when it guards its routes.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub token: Option<String>,
|
||||
/// The `ssh` sandbox's destination, passed to `ssh` as-is: any
|
||||
/// alias or `user@host` the local config resolves.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub host: Option<String>,
|
||||
/// The `ssh` sandbox's workspace base, where the per-workspace
|
||||
/// directories land. Defaults to [`SSH_WORKSPACE_ROOT`].
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub workspace: Option<String>,
|
||||
}
|
||||
|
||||
impl SandboxChoice {
|
||||
@@ -101,6 +121,32 @@ impl SandboxChoice {
|
||||
.token
|
||||
.map(|token| token.trim().to_owned())
|
||||
.filter(|token| !token.is_empty());
|
||||
self.host = self
|
||||
.host
|
||||
.map(|host| host.trim().to_owned())
|
||||
.filter(|host| !host.is_empty());
|
||||
self.workspace = self
|
||||
.workspace
|
||||
.map(|workspace| workspace.trim().trim_end_matches('/').to_owned())
|
||||
.filter(|workspace| !workspace.is_empty());
|
||||
if self.kind == SandboxKind::Ssh {
|
||||
let host = self
|
||||
.host
|
||||
.as_deref()
|
||||
.ok_or_else(|| SandboxError::Invalid("the ssh sandbox needs a host".to_owned()))?;
|
||||
if host.contains(char::is_whitespace) {
|
||||
return Err(SandboxError::Invalid(
|
||||
"the ssh sandbox host is one destination, no spaces".to_owned(),
|
||||
));
|
||||
}
|
||||
if let Some(workspace) = self.workspace.as_deref()
|
||||
&& !workspace.starts_with('/')
|
||||
{
|
||||
return Err(SandboxError::Invalid(
|
||||
"the ssh sandbox workspace must be an absolute path".to_owned(),
|
||||
));
|
||||
}
|
||||
}
|
||||
if self.kind == SandboxKind::Http {
|
||||
let url = self
|
||||
.url
|
||||
@@ -117,7 +163,22 @@ impl SandboxChoice {
|
||||
|
||||
/// Whether commands leave this host.
|
||||
pub fn is_remote(&self) -> bool {
|
||||
self.kind == SandboxKind::Http
|
||||
self.kind != SandboxKind::Local
|
||||
}
|
||||
|
||||
/// The remote directory one workspace's commands run in: the
|
||||
/// protocol root for `http`, a directory per host workspace under
|
||||
/// the configured base for `ssh`.
|
||||
pub fn remote_root(&self, host: &Path) -> PathBuf {
|
||||
match self.kind {
|
||||
SandboxKind::Http => PathBuf::from(REMOTE_WORKSPACE),
|
||||
SandboxKind::Ssh => PathBuf::from(format!(
|
||||
"{}/{}",
|
||||
self.workspace.as_deref().unwrap_or(SSH_WORKSPACE_ROOT),
|
||||
session_name(host)
|
||||
)),
|
||||
SandboxKind::Local => host.to_path_buf(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +200,7 @@ pub struct SandboxState {
|
||||
settings: Arc<SettingsStore>,
|
||||
local_workspace: PathBuf,
|
||||
local: Arc<dyn ShellExecutor>,
|
||||
remote: Mutex<HashMap<String, Arc<HttpSandbox>>>,
|
||||
remote: Mutex<HashMap<String, Arc<dyn Sandbox>>>,
|
||||
}
|
||||
|
||||
impl SandboxState {
|
||||
@@ -204,13 +265,9 @@ impl SandboxState {
|
||||
}
|
||||
|
||||
/// The workspace a handler should name and start commands in: the
|
||||
/// host path locally, `/workspace` on a remote sandbox.
|
||||
/// host path locally, the choice's remote root otherwise.
|
||||
pub fn workspace_for(&self, host: &Path) -> PathBuf {
|
||||
if self.is_remote() {
|
||||
PathBuf::from(REMOTE_WORKSPACE)
|
||||
} else {
|
||||
host.to_path_buf()
|
||||
}
|
||||
self.choice().remote_root(host)
|
||||
}
|
||||
|
||||
/// The chat workspace under the current choice, for the settings
|
||||
@@ -239,18 +296,14 @@ impl SandboxState {
|
||||
})
|
||||
}
|
||||
|
||||
/// The cached HTTP client for one session. The map is cleared
|
||||
/// whenever the choice changes, so a new URL or token builds a new
|
||||
/// client.
|
||||
/// The cached sandbox for one session. The map is cleared whenever
|
||||
/// the choice changes, so a new URL, token, host, or base builds a
|
||||
/// new client.
|
||||
fn remote_sandbox(
|
||||
&self,
|
||||
choice: &SandboxChoice,
|
||||
host: &Path,
|
||||
) -> Result<Arc<HttpSandbox>, ShellError> {
|
||||
let url = choice
|
||||
.url
|
||||
.as_deref()
|
||||
.ok_or_else(|| ShellError::Failed("the http sandbox has no url".to_owned()))?;
|
||||
) -> Result<Arc<dyn Sandbox>, ShellError> {
|
||||
let session = session_name(host);
|
||||
{
|
||||
let remote = self.remote.lock().unwrap_or_else(PoisonError::into_inner);
|
||||
@@ -258,8 +311,31 @@ impl SandboxState {
|
||||
return Ok(sandbox.clone());
|
||||
}
|
||||
}
|
||||
let sandbox: Arc<dyn Sandbox> = match choice.kind {
|
||||
SandboxKind::Http => {
|
||||
let url = choice
|
||||
.url
|
||||
.as_deref()
|
||||
.ok_or_else(|| ShellError::Failed("the http sandbox has no url".to_owned()))?;
|
||||
let token = choice.token.as_deref().unwrap_or("");
|
||||
let sandbox = Arc::new(HttpSandbox::new(url.to_owned(), &session, token));
|
||||
Arc::new(HttpSandbox::new(url.to_owned(), &session, token))
|
||||
}
|
||||
SandboxKind::Ssh => {
|
||||
let dest = choice
|
||||
.host
|
||||
.as_deref()
|
||||
.ok_or_else(|| ShellError::Failed("the ssh sandbox has no host".to_owned()))?;
|
||||
let base = choice.workspace.as_deref().unwrap_or(SSH_WORKSPACE_ROOT);
|
||||
Arc::new(
|
||||
SshSandbox::new(dest.to_owned()).with_workspace(format!("{base}/{session}")),
|
||||
)
|
||||
}
|
||||
SandboxKind::Local => {
|
||||
return Err(ShellError::Failed(
|
||||
"the local sandbox needs no remote client".to_owned(),
|
||||
));
|
||||
}
|
||||
};
|
||||
self.remote
|
||||
.lock()
|
||||
.unwrap_or_else(PoisonError::into_inner)
|
||||
@@ -280,20 +356,32 @@ struct ClawShell {
|
||||
}
|
||||
|
||||
impl ClawShell {
|
||||
/// Seeds the sandbox once per choice. An empty `/workspace` gets
|
||||
/// Seeds the sandbox once per choice. An empty workspace root gets
|
||||
/// the host workspace as a tarball; a non-empty one is left alone
|
||||
/// so a restart never overwrites work done in the sandbox.
|
||||
/// so a restart never overwrites work done in the sandbox. The
|
||||
/// probe makes the root first: the http daemon keeps one, the ssh
|
||||
/// far end has none until something makes it, and the unpack's
|
||||
/// `tar -C` would fail on a missing directory.
|
||||
async fn seed(
|
||||
&self,
|
||||
sandbox: &Arc<HttpSandbox>,
|
||||
sandbox: &Arc<dyn Sandbox>,
|
||||
cancelled: &AtomicBool,
|
||||
) -> Result<(), ShellError> {
|
||||
let root = self
|
||||
.state
|
||||
.workspace_for(&self.host_workspace)
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
let mut sink = |_line: &str| {};
|
||||
let probe = sandbox
|
||||
.exec(
|
||||
ExecRequest {
|
||||
command: "ls -A /workspace 2>/dev/null | head -n 1".to_owned(),
|
||||
cwd: REMOTE_WORKSPACE.to_owned(),
|
||||
command: format!(
|
||||
"mkdir -p {}; ls -A {} 2>/dev/null | head -n 1",
|
||||
shquote(&root),
|
||||
shquote(&root)
|
||||
),
|
||||
cwd: root.clone(),
|
||||
timeout: PROBE_TIMEOUT,
|
||||
},
|
||||
cancelled,
|
||||
@@ -353,15 +441,9 @@ impl ShellExecutor for ClawShell {
|
||||
self.seed(&sandbox, cancelled).await?;
|
||||
self.seeded.store(true, Ordering::Relaxed);
|
||||
}
|
||||
let sandbox: Arc<dyn Sandbox> = sandbox;
|
||||
let root = choice.remote_root(&self.host_workspace);
|
||||
ShellSandbox::new(sandbox)
|
||||
.run(
|
||||
command,
|
||||
Path::new(REMOTE_WORKSPACE),
|
||||
timeout,
|
||||
cancelled,
|
||||
progress,
|
||||
)
|
||||
.run(command, &root, timeout, cancelled, progress)
|
||||
.await
|
||||
}
|
||||
}
|
||||
@@ -379,6 +461,13 @@ fn protocol_error(err: rhema_sandbox::SandboxError) -> ShellError {
|
||||
}
|
||||
}
|
||||
|
||||
/// One path quoted for the remote `bash -c`: single quotes, the
|
||||
/// closing quote spliced, good for every path a workspace root can
|
||||
/// have.
|
||||
fn shquote(path: &str) -> String {
|
||||
format!("'{}'", path.replace('\'', "'\\''"))
|
||||
}
|
||||
|
||||
/// The sandbox session name for one host workspace: a stable FNV-1a
|
||||
/// hash of the path, so the daemon can multiplex one root per session
|
||||
/// and a restart finds the same root.
|
||||
@@ -458,7 +547,7 @@ mod tests {
|
||||
let missing = SandboxChoice {
|
||||
kind: SandboxKind::Http,
|
||||
url: None,
|
||||
token: None,
|
||||
..SandboxChoice::default()
|
||||
}
|
||||
.normalized();
|
||||
assert!(missing.is_err(), "a URL is required");
|
||||
@@ -466,18 +555,63 @@ mod tests {
|
||||
let relative = SandboxChoice {
|
||||
kind: SandboxKind::Http,
|
||||
url: Some("box.example:7600".to_owned()),
|
||||
token: None,
|
||||
..SandboxChoice::default()
|
||||
}
|
||||
.normalized();
|
||||
assert!(relative.is_err(), "a bare host is not a URL");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_ssh_choice_needs_a_host_and_an_absolute_base() {
|
||||
let missing = SandboxChoice {
|
||||
kind: SandboxKind::Ssh,
|
||||
..SandboxChoice::default()
|
||||
}
|
||||
.normalized();
|
||||
assert!(missing.is_err(), "a host is required");
|
||||
|
||||
let spaced = SandboxChoice {
|
||||
kind: SandboxKind::Ssh,
|
||||
host: Some("me @box".to_owned()),
|
||||
..SandboxChoice::default()
|
||||
}
|
||||
.normalized();
|
||||
assert!(spaced.is_err(), "a destination is one word");
|
||||
|
||||
let relative = SandboxChoice {
|
||||
kind: SandboxKind::Ssh,
|
||||
host: Some("me@box".to_owned()),
|
||||
workspace: Some("srv/claw".to_owned()),
|
||||
..SandboxChoice::default()
|
||||
}
|
||||
.normalized();
|
||||
assert!(relative.is_err(), "the base is an absolute path");
|
||||
|
||||
let good = SandboxChoice {
|
||||
kind: SandboxKind::Ssh,
|
||||
host: Some(" me@box ".to_owned()),
|
||||
workspace: Some("/srv/claw/".to_owned()),
|
||||
..SandboxChoice::default()
|
||||
}
|
||||
.normalized()
|
||||
.expect("the choice normalizes");
|
||||
assert_eq!(good.host.as_deref(), Some("me@box"));
|
||||
assert_eq!(good.workspace.as_deref(), Some("/srv/claw"));
|
||||
assert!(good.is_remote());
|
||||
assert_eq!(good.kind.as_str(), "ssh");
|
||||
assert_eq!(
|
||||
SandboxKind::parse("ssh"),
|
||||
Some(SandboxKind::Ssh),
|
||||
"the stored spelling round-trips"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_remote_workspace_is_the_sandbox_root() {
|
||||
let state = state(SandboxChoice {
|
||||
kind: SandboxKind::Http,
|
||||
url: Some("http://box:7600/".to_owned()),
|
||||
token: None,
|
||||
..SandboxChoice::default()
|
||||
});
|
||||
assert_eq!(state.workspace(), PathBuf::from(REMOTE_WORKSPACE));
|
||||
assert_eq!(
|
||||
@@ -487,6 +621,36 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_ssh_workspace_is_one_directory_per_host_workspace() {
|
||||
let host = PathBuf::from("/state/claw/workspaces/interactive");
|
||||
let choice = SandboxChoice {
|
||||
kind: SandboxKind::Ssh,
|
||||
host: Some("me@box".to_owned()),
|
||||
workspace: Some("/srv/claw".to_owned()),
|
||||
..SandboxChoice::default()
|
||||
};
|
||||
let root = choice.remote_root(&host);
|
||||
let root = root.to_string_lossy().to_string();
|
||||
assert!(
|
||||
root.starts_with("/srv/claw/rhema-claw-"),
|
||||
"the root lives under the configured base: {root}"
|
||||
);
|
||||
assert_eq!(root.len(), "/srv/claw/rhema-claw-".len() + 16);
|
||||
|
||||
let default_root = SandboxChoice {
|
||||
kind: SandboxKind::Ssh,
|
||||
host: Some("me@box".to_owned()),
|
||||
..SandboxChoice::default()
|
||||
}
|
||||
.remote_root(&host);
|
||||
assert_eq!(
|
||||
default_root.to_string_lossy(),
|
||||
format!("/root/{}", session_name(&host)),
|
||||
"the base defaults to the login's home"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_choice_persists_and_reloads() {
|
||||
let settings = Arc::new(SettingsStore::in_memory().expect("the store opens"));
|
||||
@@ -504,6 +668,7 @@ mod tests {
|
||||
kind: SandboxKind::Http,
|
||||
url: Some("https://box:7600".to_owned()),
|
||||
token: Some("secret".to_owned()),
|
||||
..SandboxChoice::default()
|
||||
})
|
||||
.expect("the choice saves");
|
||||
|
||||
@@ -515,6 +680,38 @@ mod tests {
|
||||
assert_eq!(reloaded.choice().token.as_deref(), Some("secret"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_ssh_choice_persists_with_its_host_and_base() {
|
||||
let settings = Arc::new(SettingsStore::in_memory().expect("the store opens"));
|
||||
let state = SandboxState::load(
|
||||
settings.clone(),
|
||||
None,
|
||||
PathBuf::from("/tmp/ws"),
|
||||
&BTreeMap::new(),
|
||||
)
|
||||
.expect("the state loads");
|
||||
state
|
||||
.set(SandboxChoice {
|
||||
kind: SandboxKind::Ssh,
|
||||
host: Some("me@box".to_owned()),
|
||||
workspace: Some("/srv/claw".to_owned()),
|
||||
..SandboxChoice::default()
|
||||
})
|
||||
.expect("the choice saves");
|
||||
|
||||
let reloaded =
|
||||
SandboxState::load(settings, None, PathBuf::from("/tmp/ws"), &BTreeMap::new())
|
||||
.expect("the state reloads");
|
||||
assert_eq!(reloaded.choice().kind, SandboxKind::Ssh);
|
||||
assert_eq!(reloaded.choice().host.as_deref(), Some("me@box"));
|
||||
assert_eq!(reloaded.choice().workspace.as_deref(), Some("/srv/claw"));
|
||||
assert_eq!(
|
||||
reloaded.workspace().to_string_lossy(),
|
||||
format!("/srv/claw/{}", session_name(Path::new("/tmp/ws"))),
|
||||
"the settings surface reports the session root"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn a_remote_command_seeds_a_fresh_sandbox_and_runs() {
|
||||
let server = MockServer::start().await;
|
||||
@@ -556,7 +753,7 @@ mod tests {
|
||||
let state = state(SandboxChoice {
|
||||
kind: SandboxKind::Http,
|
||||
url: Some(server.uri()),
|
||||
token: None,
|
||||
..SandboxChoice::default()
|
||||
});
|
||||
let executor = state.executor(dir.path());
|
||||
let cancelled = AtomicBool::new(false);
|
||||
|
||||
@@ -2431,6 +2431,66 @@ async fn the_sandbox_choice_is_listed_and_switchable() {
|
||||
assert_eq!(cleared["url"], "https://box.example:7600");
|
||||
}
|
||||
|
||||
/// The ssh sandbox over the surface: a choice without a host is a 400,
|
||||
/// a complete one lists its host and reports the workspace under the
|
||||
/// configured base, and switching back to this host keeps the ssh
|
||||
/// fields staged for the next switch.
|
||||
#[tokio::test]
|
||||
async fn the_ssh_sandbox_is_switchable_over_the_surface() {
|
||||
let dir = tempfile::tempdir().expect("tempdir");
|
||||
let daemon = Daemon::build(
|
||||
&config(&dir, None),
|
||||
mock_registry(Arc::new(MockProvider::new([reply("on it")]))),
|
||||
rhema_rsd::DispatcherConfig::default(),
|
||||
)
|
||||
.expect("the daemon assembles");
|
||||
let base = serve(&daemon).await;
|
||||
let client = reqwest::Client::new();
|
||||
|
||||
let refused = client
|
||||
.put(format!("{base}/v1/sandbox"))
|
||||
.json(&json!({"kind": "ssh"}))
|
||||
.send()
|
||||
.await
|
||||
.expect("the refusal posts");
|
||||
assert_eq!(refused.status(), 400, "an ssh choice without a host");
|
||||
|
||||
let switched: Value = client
|
||||
.put(format!("{base}/v1/sandbox"))
|
||||
.json(&json!({"kind": "ssh", "host": "me@box.example", "workspace": "/srv/claw"}))
|
||||
.send()
|
||||
.await
|
||||
.expect("the switch posts")
|
||||
.json()
|
||||
.await
|
||||
.expect("the switch parses");
|
||||
assert_eq!(switched["kind"], "ssh");
|
||||
assert_eq!(switched["host"], "me@box.example");
|
||||
let workspace = switched["workspace"].as_str().expect("the workspace reads");
|
||||
assert!(
|
||||
workspace.starts_with("/srv/claw/rhema-claw-"),
|
||||
"the workspace sits under the configured base: {workspace}"
|
||||
);
|
||||
|
||||
// Back to this host: the workspace flips, the ssh fields stay
|
||||
// staged for the next switch.
|
||||
let local: Value = client
|
||||
.put(format!("{base}/v1/sandbox"))
|
||||
.json(&json!({"kind": "local"}))
|
||||
.send()
|
||||
.await
|
||||
.expect("the switch posts")
|
||||
.json()
|
||||
.await
|
||||
.expect("the switch parses");
|
||||
assert_eq!(local["kind"], "local");
|
||||
assert_eq!(local["host"], "me@box.example");
|
||||
assert!(
|
||||
local["workspace"].as_str().expect("the workspace reads") != workspace,
|
||||
"the workspace path follows the choice"
|
||||
);
|
||||
}
|
||||
|
||||
/// The agent identity surface: the text fields round-trip with
|
||||
/// partial-save semantics (an absent field is left alone, an empty one
|
||||
/// clears), the avatar uploads and serves back with its content type,
|
||||
|
||||
@@ -15,10 +15,10 @@ publish = false
|
||||
rusqlite = { version = "0.40", features = ["bundled"] }
|
||||
# The reminder source: one `Source` over the feeds, detect-pass shaped
|
||||
# like the task scheduler's
|
||||
rhema-autonomous-agent = "0.4.0"
|
||||
rhema-autonomous-agent = "0.4.1"
|
||||
# The reminder source ingests its slots into a `Dispatcher`; the event
|
||||
# and key-function shapes are the dispatcher's
|
||||
rhema-rsd = "0.4.0"
|
||||
rhema-rsd = "0.4.1"
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
|
||||
@@ -13,7 +13,7 @@ publish = false
|
||||
|
||||
[dependencies]
|
||||
# The dispatch seam: watches ingest into a Dispatcher
|
||||
rhema-rsd = "0.4.0"
|
||||
rhema-rsd = "0.4.1"
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
|
||||
@@ -523,7 +523,11 @@ async function saveSandbox(choice: SandboxSelection): Promise<void> {
|
||||
try {
|
||||
sandboxState.value = await claw.setSandbox(choice)
|
||||
pushNotice(
|
||||
choice.kind === 'http' ? 'sandbox: remote host' : 'sandbox: this machine',
|
||||
choice.kind === 'http'
|
||||
? 'sandbox: remote host'
|
||||
: choice.kind === 'ssh'
|
||||
? 'sandbox: ssh host'
|
||||
: 'sandbox: this machine',
|
||||
)
|
||||
apiError.value = null
|
||||
} catch (err) {
|
||||
|
||||
@@ -18,20 +18,36 @@ const kind = ref<SandboxKind>('local')
|
||||
const url = ref('')
|
||||
const token = ref('')
|
||||
const clearToken = ref(false)
|
||||
const host = ref('')
|
||||
const workspace = ref('')
|
||||
|
||||
const dirty = computed(() => {
|
||||
const state = props.state
|
||||
if (!state) return false
|
||||
if (kind.value !== state.kind) return true
|
||||
if (kind.value !== 'http') return false
|
||||
if (kind.value === 'http') {
|
||||
const normalized = url.value.trim().replace(/\/+$/, '')
|
||||
if (normalized !== (state.url ?? '')) return true
|
||||
return token.value.trim() !== '' || clearToken.value
|
||||
}
|
||||
if (kind.value === 'ssh') {
|
||||
if (host.value.trim() !== (state.host ?? '')) return true
|
||||
if (workspace.value.trim() !== (state.ssh_workspace ?? '')) return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
const urlValid = computed(() => /^https?:\/\/.+/.test(url.value.trim()))
|
||||
|
||||
const ready = computed(() => kind.value !== 'http' || urlValid.value)
|
||||
const hostValid = computed(
|
||||
() => host.value.trim() !== '' && !host.value.trim().includes(' '),
|
||||
)
|
||||
|
||||
const ready = computed(() => {
|
||||
if (kind.value === 'http') return urlValid.value
|
||||
if (kind.value === 'ssh') return hostValid.value
|
||||
return true
|
||||
})
|
||||
|
||||
const urlHint = computed(() =>
|
||||
url.value.trim() && !urlValid.value
|
||||
@@ -39,6 +55,12 @@ const urlHint = computed(() =>
|
||||
: 'The sandboxd base URL, for example https://box.example:7600.',
|
||||
)
|
||||
|
||||
const hostHint = computed(() =>
|
||||
host.value.trim() && !hostValid.value
|
||||
? 'One destination, no spaces: an alias or user@host your ssh config resolves.'
|
||||
: 'An alias or user@host your ssh config resolves.',
|
||||
)
|
||||
|
||||
function sync(): void {
|
||||
const state = props.state
|
||||
if (!state) return
|
||||
@@ -46,6 +68,8 @@ function sync(): void {
|
||||
url.value = state.url ?? ''
|
||||
token.value = ''
|
||||
clearToken.value = false
|
||||
host.value = state.host ?? ''
|
||||
workspace.value = state.ssh_workspace ?? ''
|
||||
}
|
||||
|
||||
watch(
|
||||
@@ -71,6 +95,10 @@ function save(): void {
|
||||
choice.clear_token = true
|
||||
}
|
||||
}
|
||||
if (kind.value === 'ssh') {
|
||||
choice.host = host.value.trim()
|
||||
choice.workspace = workspace.value.trim()
|
||||
}
|
||||
emit('save', choice)
|
||||
}
|
||||
|
||||
@@ -78,7 +106,9 @@ function save(): void {
|
||||
const workspacePath = computed(() => {
|
||||
const state = props.state
|
||||
if (!state) return ''
|
||||
return kind.value === 'http' ? state.remote_workspace : state.local_workspace
|
||||
if (kind.value === 'local') return state.local_workspace
|
||||
if (kind.value === 'http') return state.remote_workspace
|
||||
return state.workspace
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -123,6 +153,47 @@ const workspacePath = computed(() => {
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<label class="option" :class="{ selected: kind === 'ssh' }">
|
||||
<input v-model="kind" type="radio" value="ssh" :disabled="saving" />
|
||||
<span class="option-text">
|
||||
<span class="option-title">
|
||||
SSH host
|
||||
<span v-if="state.kind === 'ssh'" class="current">current</span>
|
||||
</span>
|
||||
<span class="option-detail">
|
||||
Commands run on a box the claw reaches with ssh, nothing installed on the far end.
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
</SettingCard>
|
||||
|
||||
<SettingCard v-if="kind === 'ssh'" title="SSH host">
|
||||
<SettingRow title="Destination" :description="hostHint">
|
||||
<input
|
||||
v-model="host"
|
||||
type="text"
|
||||
class="mono"
|
||||
placeholder="me@box.example"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
:disabled="saving"
|
||||
/>
|
||||
</SettingRow>
|
||||
<SettingRow
|
||||
title="Workspace base"
|
||||
description="The remote directory the claw's workspaces live under. Defaults to /root."
|
||||
>
|
||||
<input
|
||||
v-model="workspace"
|
||||
type="text"
|
||||
class="mono"
|
||||
placeholder="/root"
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
:disabled="saving"
|
||||
/>
|
||||
</SettingRow>
|
||||
</SettingCard>
|
||||
|
||||
<SettingCard v-if="kind === 'http'" title="Remote sandbox">
|
||||
@@ -167,7 +238,7 @@ const workspacePath = computed(() => {
|
||||
</SettingRow>
|
||||
</SettingCard>
|
||||
|
||||
<AppCallout v-if="kind === 'http'" variant="info" title="Remote commands start from a copy">
|
||||
<AppCallout v-if="kind !== 'local'" variant="info" title="Remote commands start from a copy">
|
||||
On first use the claw sends the local workspace to the sandbox as a tarball.
|
||||
Later edits stay in the sandbox; the claw does not copy them back.
|
||||
</AppCallout>
|
||||
|
||||
@@ -231,9 +231,9 @@ export interface ActiveBackend {
|
||||
active: { provider: string; model: string }
|
||||
}
|
||||
|
||||
/** Where the agent's `bash` runs: this host or a daemon speaking the
|
||||
* sandbox protocol over HTTP. */
|
||||
export type SandboxKind = 'local' | 'http'
|
||||
/** Where the agent's `bash` runs: this host, a daemon speaking the
|
||||
* sandbox protocol over HTTP, or an ssh login on a far box. */
|
||||
export type SandboxKind = 'local' | 'http' | 'ssh'
|
||||
|
||||
/** The sandbox state `GET /v1/sandbox` serves. The token never rides
|
||||
* the wire; `token_set` says whether one is stored. */
|
||||
@@ -241,6 +241,12 @@ export interface SandboxState {
|
||||
kind: SandboxKind
|
||||
url: string | null
|
||||
token_set: boolean
|
||||
/** The ssh destination, an alias or `user@host` the local ssh
|
||||
* config resolves. */
|
||||
host: string | null
|
||||
/** The ssh workspace base the workspaces sit under, `null` for the
|
||||
* default. */
|
||||
ssh_workspace: string | null
|
||||
/** Where `bash` starts under the current choice. */
|
||||
workspace: string
|
||||
/** The daemon's chat workspace, whatever the choice. */
|
||||
@@ -257,6 +263,10 @@ export interface SandboxSelection {
|
||||
url?: string
|
||||
token?: string
|
||||
clear_token?: boolean
|
||||
host?: string
|
||||
/** The ssh workspace base; the per-workspace directories land under
|
||||
* it. An omitted value keeps the current one. */
|
||||
workspace?: string
|
||||
}
|
||||
|
||||
/** A failed API call: the status plus the claw's `error` string when it sent one. */
|
||||
|
||||
Reference in new issue
Block a user