forked from vhaudiquet/rhema-claw
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae198c6f26 | ||
|
|
2ff791ed89 | ||
|
|
b69bf543e7 | ||
|
|
b8c44502cb | ||
|
|
cdeb5c3994 | ||
|
|
f779415b2b |
No files matched your search
@@ -1 +1,2 @@
|
|||||||
/target/
|
/target/
|
||||||
|
.rhema/
|
||||||
Generated
+70
-55
@@ -1906,9 +1906,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-autonomous-agent"
|
name = "rhema-autonomous-agent"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "08fd6d5fe5f9551226d322491d03b14d5e42ac2ff73544c15a555fb97a04bbfd"
|
checksum = "46677fb855ebb628da602111fa2595ad363401c7101c07f07a602dbc86a1dd8a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"rhema-core",
|
"rhema-core",
|
||||||
@@ -1922,9 +1922,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-bash"
|
name = "rhema-bash"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf9ae34e5c556e0abdf279dd7d0aa08632bdcd68cff965bce2b81c226ada8f1e"
|
checksum = "1e0aacc9aac461f674ec7f72dc321b11edc4c7868d3c635c2b1c58dbd9256c80"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
@@ -1982,6 +1982,7 @@ dependencies = [
|
|||||||
"rhema-rsd",
|
"rhema-rsd",
|
||||||
"rhema-sandbox",
|
"rhema-sandbox",
|
||||||
"rhema-sandbox-http",
|
"rhema-sandbox-http",
|
||||||
|
"rhema-sandbox-ssh",
|
||||||
"rhema-transcript",
|
"rhema-transcript",
|
||||||
"rusqlite",
|
"rusqlite",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -2006,9 +2007,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-config"
|
name = "rhema-config"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a0bbfb885f219272d24534c004819db377cf5370de0f82a851f9329466a5349c"
|
checksum = "0a05d1d30472d7ea03685806b69e0e9984744b0349cc7c7ad53497916b6c2be1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"keyring",
|
"keyring",
|
||||||
"rhema-core",
|
"rhema-core",
|
||||||
@@ -2020,9 +2021,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-core"
|
name = "rhema-core"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c3cd4c7a28b121243a2e26371e53750f28368e96c1a1629f021847c717e1cd55"
|
checksum = "de9d3c12019209170cbf82fa75dcad4ec10c3c712f7235d9f9a60f165cab5d8c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -2046,9 +2047,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-host-agent"
|
name = "rhema-host-agent"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3c10a82a420f1ea5ad1e68cabf0da67e6d05f18ec9e6fa02993969c2dcc53a68"
|
checksum = "973dc8ee54a24065c7996b23e0cfd2eba715687394a248583582faca3d7a5c4c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"minijinja",
|
"minijinja",
|
||||||
"rhema-bash",
|
"rhema-bash",
|
||||||
@@ -2066,9 +2067,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-identity"
|
name = "rhema-identity"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f1bb799ae7395c647577b9cf26208d81c2913d893db050adc82976e88436226c"
|
checksum = "3188f0fec1338df315c76034909e8ff7c1314a84ff6dd0ac11793d605d655b5b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rusqlite",
|
"rusqlite",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -2077,9 +2078,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-mcp"
|
name = "rhema-mcp"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6ed674931827b5b5e3130b376bda837cf49bda6ca6c94392430b74e292b6f516"
|
checksum = "0dd8f9ee0b0699c09efb303dfc17ed3049aabc8a7b3e01d211de283c43c8c19b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-stream",
|
"async-stream",
|
||||||
"axum",
|
"axum",
|
||||||
@@ -2104,9 +2105,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-memory"
|
name = "rhema-memory"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "34d3b6763b7c567849b6f1787bae7152ce92ec38bdbe2ec27691d4ef2596c259"
|
checksum = "abdfee3e709305e86cedc3e60ca59776af512b2bf520ab87d7da1d184f01d560"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"rhema-core",
|
"rhema-core",
|
||||||
@@ -2118,9 +2119,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-prompt"
|
name = "rhema-prompt"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b70bba0a045879067817db80fcaa7578dc32ef699786cc004b8fdb73bccc47e4"
|
checksum = "2ecbf1ae5d134d110c8f3b4c47ad2331f703bd7bb1ad6d53b4108787d894c8bd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"minijinja",
|
"minijinja",
|
||||||
"rhema-core",
|
"rhema-core",
|
||||||
@@ -2131,9 +2132,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-provider"
|
name = "rhema-provider"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c400c1ac8430f78184ecc12024605686a988ada7a3ee30dd67a4ce12114ccb9e"
|
checksum = "15855c3fa2d858622cd55bd6323d4a7533066e52a74e3dc440ffe69c12ed1263"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
@@ -2147,9 +2148,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-provider-anthropic"
|
name = "rhema-provider-anthropic"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a57458493f5b1fb540fa47f558f7743094dc123d2c06815d2078f9303d9df22f"
|
checksum = "223a60c52ce2e548f72a9f2cce6f7a48be954bd3e5b959ff70d308b3d42d6425"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
@@ -2163,9 +2164,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-provider-chatgpt"
|
name = "rhema-provider-chatgpt"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7642b1e0bc194cc81d7f347182eecd6702a04a85de41912bd2d34b2cdf41ca7b"
|
checksum = "ec84f3f5601e8ca6e69f92a291480842058352bb580b985ec23db713505b8f5d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
@@ -2182,15 +2183,16 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-provider-copilot"
|
name = "rhema-provider-copilot"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "eb39fa7f059df415bdef2453e58ad5359fd74eeb39f7981179f03c78ffb5af7d"
|
checksum = "c6685a56017c7de21d17384d25f941f2733526d581dfafc5cd7371d4f6e82096"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"rhema-core",
|
"rhema-core",
|
||||||
"rhema-provider",
|
"rhema-provider",
|
||||||
|
"rhema-provider-anthropic",
|
||||||
"rhema-provider-openai-compatible",
|
"rhema-provider-openai-compatible",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@@ -2200,9 +2202,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-provider-google"
|
name = "rhema-provider-google"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7dda76eea354cfbdfd4a2dfa1fc1ce8da823675699cf2bf4d3ace8560fec2cd7"
|
checksum = "749f27fcf2ad1c7745cabc85e56d05e116bce30b6be317910f0c455ba4147ff9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
@@ -2216,9 +2218,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-provider-llama-cpp"
|
name = "rhema-provider-llama-cpp"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "953181611b909688db511f891e8c59e034b90bd798034f1afef36cac05409566"
|
checksum = "bf5d26ec681baac6b8c6fc752470a78205acb11f763987bf571fa54be1195e2a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
@@ -2233,9 +2235,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-provider-mistral"
|
name = "rhema-provider-mistral"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1f657297d7d617a14b10bb6248e944d053d73a536d3b6ae4ee4cc8acabcb4a57"
|
checksum = "4d8ae3c2c924202d3614987b6b7c4930d84a19ebb2264747bb5100f1f67db7ff"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
@@ -2252,9 +2254,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-provider-openai-compatible"
|
name = "rhema-provider-openai-compatible"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a90f1620882b2a3dbdb00065b29c329622c5596f582027b29130fbd40003b450"
|
checksum = "aab0c24d2d558d66de1f002c250d05c25d9c52038e4fa1890f6c40644c4f9702"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
@@ -2268,9 +2270,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-provider-opencode"
|
name = "rhema-provider-opencode"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2068c980362fe3d4f7876e5e842f51c0719626449afac64192592865e11a0108"
|
checksum = "3eb4c641b7997ba5cab41bede6c4b7331baa9a9b2298d5bb0ffbc8844df6dbf3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
@@ -2283,9 +2285,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-provider-openrouter"
|
name = "rhema-provider-openrouter"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c2025f84d6a1fd1e513ffad4b374d280f0db600ffac635dfe08a58d04b03e91d"
|
checksum = "7170cef8b456c8f1df1b565d16ad3c61c4b252e521fff16718eacca5d7d98605"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
@@ -2299,9 +2301,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-provider-registry"
|
name = "rhema-provider-registry"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "be5ed790e3dc4fc3a42bd9b1a633ef72204c519810ce03dafb2792a8ff0b6bf8"
|
checksum = "c93ceacbe2332f122b23a11de11ddf4a502a96baaa8c95f33882c5c589581dce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rhema-core",
|
"rhema-core",
|
||||||
"rhema-provider",
|
"rhema-provider",
|
||||||
@@ -2319,9 +2321,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-rsd"
|
name = "rhema-rsd"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3a4bd0555ff3720c0501187f5e9c6ee19ebebb95c1ecdb296c509c2e2dd971ce"
|
checksum = "8e97a9d363b432147220a0646a158ea7a08d6012efa1bedf169fd973721dd745"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rhema-core",
|
"rhema-core",
|
||||||
"rusqlite",
|
"rusqlite",
|
||||||
@@ -2332,9 +2334,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-sandbox"
|
name = "rhema-sandbox"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7030dbd46aa8a2398452dcf86b6b39d13b82909b9fdc654c49e1374183594779"
|
checksum = "3d5aaa76f2400989439f325754a29593669c1275485796150e19b04277ea54fb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"rhema-bash",
|
"rhema-bash",
|
||||||
@@ -2342,13 +2344,14 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-sandbox-http"
|
name = "rhema-sandbox-http"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b5171470a8a56246e036aa10fc63e641ae7907a3ce70ac8f4816f3c9499eb75b"
|
checksum = "6f4cbb9f2238961082a8b406da460c84ced75f4d6bb9e52a79b41dc17065b601"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
@@ -2359,10 +2362,22 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-session-store"
|
name = "rhema-sandbox-ssh"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
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 = [
|
dependencies = [
|
||||||
"rhema-core",
|
"rhema-core",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -2372,9 +2387,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-session-store-file"
|
name = "rhema-session-store-file"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e5ff65f110123026ae79679572b084c517693f81e0d464897e580b64985a9507"
|
checksum = "df75d21d1ad25b16cb72fc3747d435415e7423872b51fa3751094a5a6e380543"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rhema-config",
|
"rhema-config",
|
||||||
"rhema-core",
|
"rhema-core",
|
||||||
@@ -2384,9 +2399,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-submissions"
|
name = "rhema-submissions"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d054ba904c324ef057c8fb4b9c88a40703496c8b621768844af56a8893d3fb99"
|
checksum = "dba11599010c7537800bee275dd9d414162dd57806b1d75c54ef98f126eb9f65"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rhema-core",
|
"rhema-core",
|
||||||
"rhema-session-store",
|
"rhema-session-store",
|
||||||
@@ -2397,9 +2412,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rhema-transcript"
|
name = "rhema-transcript"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "800261e8c1f29e6ceee48769bba2aaea19ccd3496ff8c6c76c617aa7d53ec2db"
|
checksum = "592b80da0bf1c84e4da814639383dc33c5d2eeee522db5bd93bb779bf0e34e10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"rhema-core",
|
"rhema-core",
|
||||||
|
|||||||
@@ -29,33 +29,34 @@ mock = ["rhema-core/mock"]
|
|||||||
# shell, the approval seam, and revive-on-resume (rhema-bash), the
|
# shell, the approval seam, and revive-on-resume (rhema-bash), the
|
||||||
# system-prompt renderer (rhema-prompt), and the driver that turns a
|
# system-prompt renderer (rhema-prompt), and the driver that turns a
|
||||||
# provider into a host-operating agent (rhema-host-agent)
|
# provider into a host-operating agent (rhema-host-agent)
|
||||||
rhema-bash = "0.4.0"
|
rhema-bash = "0.4.1"
|
||||||
rhema-prompt = "0.4.0"
|
rhema-prompt = "0.4.1"
|
||||||
rhema-host-agent = "0.4.0"
|
rhema-host-agent = "0.4.1"
|
||||||
rhema-autonomous-agent = "0.4.0"
|
rhema-autonomous-agent = "0.4.1"
|
||||||
rhema-config = "0.4.0"
|
rhema-config = "0.4.1"
|
||||||
rhema-core = "0.4.0"
|
rhema-core = "0.4.1"
|
||||||
# The bounded request view over the claw sessions, on by default here
|
# 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-calendar-integration = { path = "../../integrations/rhema-calendar-integration" }
|
||||||
rhema-forge-integration = { path = "../../integrations/rhema-forge-integration" }
|
rhema-forge-integration = { path = "../../integrations/rhema-forge-integration" }
|
||||||
# The accounts layer: identities hold the forge tokens the watches poll
|
# The accounts layer: identities hold the forge tokens the watches poll
|
||||||
# with, and the identity tools manage them over chat
|
# with, and the identity tools manage them over chat
|
||||||
rhema-identity = "0.4.0"
|
rhema-identity = "0.4.1"
|
||||||
rhema-rsd = "0.4.0"
|
rhema-rsd = "0.4.1"
|
||||||
# The sandbox seam: where `bash` runs, local process or a daemon speaking
|
# The sandbox seam: where `bash` runs, this host's processes, a daemon
|
||||||
# the wire protocol over HTTP
|
# speaking the wire protocol over HTTP, or an ssh login on a far box
|
||||||
rhema-sandbox = "0.4.0"
|
rhema-sandbox = "0.4.1"
|
||||||
rhema-sandbox-http = "0.4.0"
|
rhema-sandbox-http = "0.4.1"
|
||||||
|
rhema-sandbox-ssh = "0.4.1"
|
||||||
# The tool contract: the agent-token allowlist and version the auth
|
# The tool contract: the agent-token allowlist and version the auth
|
||||||
# middleware enforces (rhema-tools spec). The arrow runs claw ->
|
# middleware enforces (rhema-tools spec). The arrow runs claw ->
|
||||||
# contract only — never the reverse.
|
# contract only — never the reverse.
|
||||||
rhema-claw-tools-contract = { path = "../../tools/contract" }
|
rhema-claw-tools-contract = { path = "../../tools/contract" }
|
||||||
# The resident tier's durable memory: its tools join the resolver chain
|
# 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
|
# The shared ModelCard the backend registry's listings return
|
||||||
rhema-provider = "0.4.0"
|
rhema-provider = "0.4.1"
|
||||||
rhema-provider-registry = "0.4.0"
|
rhema-provider-registry = "0.4.1"
|
||||||
# Args for the two-flag binary surface
|
# Args for the two-flag binary surface
|
||||||
clap = { version = "4.5", features = ["derive"] }
|
clap = { version = "4.5", features = ["derive"] }
|
||||||
serde = { workspace = true }
|
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
|
# Inbound chat images ride base64; the dispatch decodes them into the
|
||||||
# attachment store
|
# attachment store
|
||||||
base64 = "0.22"
|
base64 = "0.22"
|
||||||
rhema-mcp = "0.4.0"
|
rhema-mcp = "0.4.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = "3"
|
tempfile = "3"
|
||||||
@@ -92,7 +93,7 @@ reqwest = { version = "0.12", features = ["json", "stream"] }
|
|||||||
bytes = "1"
|
bytes = "1"
|
||||||
# The scripted provider for turn-level tests; mirrors rhema-code's mock
|
# The scripted provider for turn-level tests; mirrors rhema-code's mock
|
||||||
# feature without a feature of our own — tests are the only consumer
|
# 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"] }
|
tokio = { workspace = true, features = ["rt-multi-thread", "macros", "sync", "time"] }
|
||||||
|
|
||||||
[lints]
|
[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)
|
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
|
tools_bin: ~/.local/share/rhema-tools/bin # put the client tools on PATH
|
||||||
sandbox: # where bash runs; omit for this host
|
sandbox: # where bash runs; omit for this host
|
||||||
kind: http # local (default) or http
|
kind: ssh # local (default), http, or ssh
|
||||||
url: https://box.example:7600 # the sandboxd base URL
|
host: me@box.example # the ssh destination: an alias or user@host
|
||||||
token: sandbox-secret # the daemon's shared secret, if it has one
|
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
|
poll_interval_secs: 120
|
||||||
max_turn_steps: 2048 # tool rounds one chat turn may run
|
max_turn_steps: 2048 # tool rounds one chat turn may run
|
||||||
watches: # a seed: imported while the table is empty
|
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`
|
`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
|
keeps the daemon's own processes. `kind: http` sends commands to a host
|
||||||
speaking the sandbox protocol (`rhema-sandboxd`), with `url` and an
|
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
|
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
|
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
|
The surface refuses to start on a non-loopback `listen` with no
|
||||||
`token`: anything beyond loopback can reach the port, and the bearer
|
`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
|
GET /v1/phone/commands?device= the device's queued, unconfirmed commands
|
||||||
POST /v1/phone/commands/{id}/result {"ok", "detail"?} — the device's report
|
POST /v1/phone/commands/{id}/result {"ok", "detail"?} — the device's report
|
||||||
GET /v1/sandbox where the agent's bash runs
|
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
|
GET /v1/providers the backend instances + the active pair
|
||||||
PUT /v1/providers/active {"provider","model"?} — switch, persisted
|
PUT /v1/providers/active {"provider","model"?} — switch, persisted
|
||||||
PUT /v1/providers/{id}/credentials add or replace an instance, 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.kind, crate::sandbox::SandboxKind::Http);
|
||||||
assert_eq!(sandbox.url.as_deref(), Some("https://box.example:7600"));
|
assert_eq!(sandbox.url.as_deref(), Some("https://box.example:7600"));
|
||||||
assert_eq!(sandbox.token.as_deref(), Some("sandbox-secret"));
|
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]
|
#[test]
|
||||||
@@ -472,7 +481,7 @@ sandbox:
|
|||||||
sandbox: Some(crate::sandbox::SandboxChoice {
|
sandbox: Some(crate::sandbox::SandboxChoice {
|
||||||
kind: crate::sandbox::SandboxKind::Http,
|
kind: crate::sandbox::SandboxKind::Http,
|
||||||
url: None,
|
url: None,
|
||||||
token: None,
|
..crate::sandbox::SandboxChoice::default()
|
||||||
}),
|
}),
|
||||||
..ClawConfig::default()
|
..ClawConfig::default()
|
||||||
};
|
};
|
||||||
@@ -484,13 +493,37 @@ sandbox:
|
|||||||
sandbox: Some(crate::sandbox::SandboxChoice {
|
sandbox: Some(crate::sandbox::SandboxChoice {
|
||||||
kind: crate::sandbox::SandboxKind::Http,
|
kind: crate::sandbox::SandboxKind::Http,
|
||||||
url: Some("https://box.example:7600".to_owned()),
|
url: Some("https://box.example:7600".to_owned()),
|
||||||
token: None,
|
..crate::sandbox::SandboxChoice::default()
|
||||||
}),
|
}),
|
||||||
..ClawConfig::default()
|
..ClawConfig::default()
|
||||||
};
|
};
|
||||||
assert!(valid.validate().is_ok(), "a complete remote choice passes");
|
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]
|
#[test]
|
||||||
fn an_unknown_key_is_rejected_and_named() {
|
fn an_unknown_key_is_rejected_and_named() {
|
||||||
let err = serde_yaml::from_str::<ClawConfig>("listne: 127.0.0.1:7799\n")
|
let err = serde_yaml::from_str::<ClawConfig>("listne: 127.0.0.1:7799\n")
|
||||||
|
|||||||
+200
-17
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use rhema_autonomous_agent::{Driver, Source, SourceError};
|
use rhema_autonomous_agent::{Driver, Source, SourceError};
|
||||||
@@ -150,6 +151,59 @@ pub fn forge_dispatch() -> DispatcherConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Hands one driver pass to its own task, so a turn does not stop the
|
||||||
|
/// clock.
|
||||||
|
///
|
||||||
|
/// [`Driver::run_once`] awaits every run it admits, which is exactly right
|
||||||
|
/// for a cron pass and wrong for a resident: a forge turn clones a repo
|
||||||
|
/// and may build a slicer, a coding job runs a session — tens of minutes
|
||||||
|
/// either way — and everything else the loop does (detecting, and so
|
||||||
|
/// polling the forges, recording watch health, firing due tasks, reading
|
||||||
|
/// the calendar, delivering to the phone) waits behind it. With a 60s
|
||||||
|
/// tick and a ten-minute turn, the daemon polls once per turn.
|
||||||
|
///
|
||||||
|
/// One pass per lane at a time. `busy` is held for the pass's whole
|
||||||
|
/// duration, and a tick that finds it held leaves its events where they
|
||||||
|
/// are: the dispatcher's inbox is the queue, so nothing is dropped — the
|
||||||
|
/// next tick admits them. Starting a second pass anyway would only lose
|
||||||
|
/// lease acquisitions to the first and log the loss.
|
||||||
|
fn spawn_pass(driver: Arc<Driver>, label: &'static str, busy: Arc<AtomicBool>) {
|
||||||
|
if busy.swap(true, Ordering::AcqRel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let held = BusyFlag(busy);
|
||||||
|
tokio::spawn(async move {
|
||||||
|
// Dropped however this task ends, a panic included: a lane whose
|
||||||
|
// flag never cleared would never run again.
|
||||||
|
let _held = held;
|
||||||
|
match driver.run_once().await {
|
||||||
|
Ok(outcomes) => {
|
||||||
|
let handled = outcomes
|
||||||
|
.iter()
|
||||||
|
.filter(|outcome| matches!(outcome, Outcome::Handled))
|
||||||
|
.count();
|
||||||
|
let failed = outcomes
|
||||||
|
.iter()
|
||||||
|
.filter(|outcome| matches!(outcome, Outcome::Failed(_)))
|
||||||
|
.count();
|
||||||
|
if handled + failed > 0 {
|
||||||
|
eprintln!("[claw] {label} pass: {handled} handled, {failed} failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => eprintln!("[claw] warning: {label} pass failed: {err}"),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Clears a lane's in-flight flag when its spawned pass ends.
|
||||||
|
struct BusyFlag(Arc<AtomicBool>);
|
||||||
|
|
||||||
|
impl Drop for BusyFlag {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
self.0.store(false, Ordering::Release);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The resident daemon: the extension set's sources (the forge watches,
|
/// The resident daemon: the extension set's sources (the forge watches,
|
||||||
/// the task scheduler, the coding jobs, the calendar reminders), the
|
/// the task scheduler, the coding jobs, the calendar reminders), the
|
||||||
/// three drivers, and the HTTP surface.
|
/// three drivers, and the HTTP surface.
|
||||||
@@ -166,6 +220,10 @@ pub struct Daemon {
|
|||||||
forge_driver: Arc<Driver>,
|
forge_driver: Arc<Driver>,
|
||||||
interactive_driver: Arc<Driver>,
|
interactive_driver: Arc<Driver>,
|
||||||
jobs_driver: Arc<Driver>,
|
jobs_driver: Arc<Driver>,
|
||||||
|
/// Whether a forge pass is running off the tick (see [`spawn_pass`]).
|
||||||
|
forge_pass_busy: Arc<AtomicBool>,
|
||||||
|
/// Whether a jobs pass is running off the tick.
|
||||||
|
jobs_pass_busy: Arc<AtomicBool>,
|
||||||
poll_interval: Duration,
|
poll_interval: Duration,
|
||||||
listen: String,
|
listen: String,
|
||||||
http: ClawState,
|
http: ClawState,
|
||||||
@@ -477,6 +535,8 @@ impl Daemon {
|
|||||||
forge_driver,
|
forge_driver,
|
||||||
interactive_driver,
|
interactive_driver,
|
||||||
jobs_driver,
|
jobs_driver,
|
||||||
|
forge_pass_busy: Arc::new(AtomicBool::new(false)),
|
||||||
|
jobs_pass_busy: Arc::new(AtomicBool::new(false)),
|
||||||
// A zero poll interval would spin detect passes against the
|
// A zero poll interval would spin detect passes against the
|
||||||
// forge API; one second is the floor.
|
// forge API; one second is the floor.
|
||||||
poll_interval: Duration::from_secs(config.poll_interval_secs.max(1)),
|
poll_interval: Duration::from_secs(config.poll_interval_secs.max(1)),
|
||||||
@@ -522,19 +582,16 @@ impl Daemon {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// One pass: every source detects (due tasks first — a reminder is
|
/// One pass, awaited to the end: every source detects (due tasks
|
||||||
/// the user-facing clock), the forge driver runs every key the
|
/// first — a reminder is the user-facing clock), the forge driver
|
||||||
/// debounce released, and the interactive driver drains as a
|
/// runs every key the debounce released, and the interactive driver
|
||||||
/// backstop — a message delivered live into a running turn waits at
|
/// drains as a backstop. The shape a `--once` run and the tests
|
||||||
/// the key for a pass like this one.
|
/// drive, where "the pass is over" has to mean the work is over.
|
||||||
|
///
|
||||||
|
/// The resident loop uses [`Daemon::resident_tick`] instead: same
|
||||||
|
/// detection, but the long lanes are not awaited.
|
||||||
pub async fn tick(&self) -> Result<TickReport, ClawError> {
|
pub async fn tick(&self) -> Result<TickReport, ClawError> {
|
||||||
// The tick only detects — every timer here drives
|
let detected = self.detect().await?;
|
||||||
// deterministic detection, and the set's order is the contract:
|
|
||||||
// due tasks before the calendar reminders that fire for them.
|
|
||||||
let mut detected = 0usize;
|
|
||||||
for source in &self.sources {
|
|
||||||
detected += source.detect().await?;
|
|
||||||
}
|
|
||||||
// A queued coding job starts before the forge pass: it is the
|
// A queued coding job starts before the forge pass: it is the
|
||||||
// thing someone just asked for.
|
// thing someone just asked for.
|
||||||
if let Err(err) = self.jobs_driver.run_once().await {
|
if let Err(err) = self.jobs_driver.run_once().await {
|
||||||
@@ -554,6 +611,50 @@ impl Daemon {
|
|||||||
"[claw] pass: {detected} event(s) detected, {handled} handled, {failed} failed"
|
"[claw] pass: {detected} event(s) detected, {handled} handled, {failed} failed"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
self.drain_interactive().await;
|
||||||
|
Ok(TickReport { detected, outcomes })
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The resident loop's pass: the same detection, with the two lanes
|
||||||
|
/// whose runs last minutes or hours handed to their own tasks.
|
||||||
|
///
|
||||||
|
/// Detection is the part that must keep its cadence — the forge polls
|
||||||
|
/// and the health rows they write, the due tasks, the calendar
|
||||||
|
/// reminders, the phone delivery all ride it — and detection alone is
|
||||||
|
/// quick. Awaiting a turn inside it means every one of those timers
|
||||||
|
/// stops for as long as the turn runs. See [`spawn_pass`].
|
||||||
|
pub async fn resident_tick(&self) -> Result<(), ClawError> {
|
||||||
|
self.detect().await?;
|
||||||
|
// A queued coding job starts before the forge pass: it is the
|
||||||
|
// thing someone just asked for.
|
||||||
|
spawn_pass(
|
||||||
|
self.jobs_driver.clone(),
|
||||||
|
"jobs",
|
||||||
|
self.jobs_pass_busy.clone(),
|
||||||
|
);
|
||||||
|
spawn_pass(
|
||||||
|
self.forge_driver.clone(),
|
||||||
|
"forge",
|
||||||
|
self.forge_pass_busy.clone(),
|
||||||
|
);
|
||||||
|
self.drain_interactive().await;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Detection only: every source, in set order. The tick's order is
|
||||||
|
/// the contract — due tasks before the calendar reminders that fire
|
||||||
|
/// for them — and the sources carry it.
|
||||||
|
async fn detect(&self) -> Result<usize, ClawError> {
|
||||||
|
let mut detected = 0usize;
|
||||||
|
for source in &self.sources {
|
||||||
|
detected += source.detect().await?;
|
||||||
|
}
|
||||||
|
Ok(detected)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The interactive driver, drained as a backstop: a message delivered
|
||||||
|
/// live into a running turn waits at the key for a pass like this one.
|
||||||
|
async fn drain_interactive(&self) {
|
||||||
match self.interactive_driver.run_once().await {
|
match self.interactive_driver.run_once().await {
|
||||||
Ok(runs) if !runs.is_empty() => {
|
Ok(runs) if !runs.is_empty() => {
|
||||||
eprintln!("[claw] interactive: {} queued run(s) drained", runs.len());
|
eprintln!("[claw] interactive: {} queued run(s) drained", runs.len());
|
||||||
@@ -561,13 +662,13 @@ impl Daemon {
|
|||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(err) => eprintln!("[claw] warning: interactive pass failed: {err}"),
|
Err(err) => eprintln!("[claw] warning: interactive pass failed: {err}"),
|
||||||
}
|
}
|
||||||
Ok(TickReport { detected, outcomes })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The resident loop: the HTTP surface comes up first (a resident is
|
/// The resident loop: the HTTP surface comes up first (a resident is
|
||||||
/// talked to), then detect, run, sleep, until ctrl-c. A failed pass
|
/// talked to), then detect, hand the long lanes to their own tasks,
|
||||||
/// is logged, not fatal — a forge outage or a dead backend must not
|
/// sleep, until ctrl-c. A failed pass is logged, not fatal — a forge
|
||||||
/// end a daemon whose next pass may simply succeed.
|
/// outage or a dead backend must not end a daemon whose next pass may
|
||||||
|
/// simply succeed.
|
||||||
pub async fn run(&self) -> Result<(), ClawError> {
|
pub async fn run(&self) -> Result<(), ClawError> {
|
||||||
self.bootstrap().await?;
|
self.bootstrap().await?;
|
||||||
let listener = tokio::net::TcpListener::bind(&self.listen).await?;
|
let listener = tokio::net::TcpListener::bind(&self.listen).await?;
|
||||||
@@ -580,7 +681,7 @@ impl Daemon {
|
|||||||
});
|
});
|
||||||
eprintln!("[claw] http listening on {addr}");
|
eprintln!("[claw] http listening on {addr}");
|
||||||
loop {
|
loop {
|
||||||
if let Err(err) = self.tick().await {
|
if let Err(err) = self.resident_tick().await {
|
||||||
eprintln!("[claw] warning: pass failed: {err}");
|
eprintln!("[claw] warning: pass failed: {err}");
|
||||||
}
|
}
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
@@ -615,6 +716,88 @@ pub async fn run_once(
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
/// A handler that holds its key until the test lets it go, and counts
|
||||||
|
/// the runs it served.
|
||||||
|
struct GatedHandler {
|
||||||
|
runs: std::sync::atomic::AtomicUsize,
|
||||||
|
started: tokio::sync::Semaphore,
|
||||||
|
release: tokio::sync::Semaphore,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[rhema_autonomous_agent::async_trait]
|
||||||
|
impl rhema_autonomous_agent::Handler for GatedHandler {
|
||||||
|
async fn handle(&self, _ctx: &mut rhema_autonomous_agent::SessionContext) -> Outcome {
|
||||||
|
self.runs.fetch_add(1, Ordering::SeqCst);
|
||||||
|
self.started.add_permits(1);
|
||||||
|
let _ = self.release.acquire().await;
|
||||||
|
Outcome::Handled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A pass handed to its own task keeps the tick free, holds its lane
|
||||||
|
/// while it runs, and does not stack: a tick that fires mid-pass
|
||||||
|
/// leaves its events in the dispatcher's inbox for the next one.
|
||||||
|
#[tokio::test]
|
||||||
|
async fn a_spawned_pass_holds_its_lane_instead_of_stacking() {
|
||||||
|
let dispatcher = Arc::new(Dispatcher::new(
|
||||||
|
DispatcherConfig {
|
||||||
|
debounce_window_millis: 0,
|
||||||
|
..DispatcherConfig::default()
|
||||||
|
},
|
||||||
|
Arc::new(SystemClock),
|
||||||
|
Arc::new(rhema_rsd::VolatileStore::new()),
|
||||||
|
));
|
||||||
|
let handler = Arc::new(GatedHandler {
|
||||||
|
runs: std::sync::atomic::AtomicUsize::new(0),
|
||||||
|
started: tokio::sync::Semaphore::new(0),
|
||||||
|
release: tokio::sync::Semaphore::new(0),
|
||||||
|
});
|
||||||
|
// The dispatcher resolves an event's key through its source's key
|
||||||
|
// function; nothing ingests before its source is registered.
|
||||||
|
dispatcher.register_source(
|
||||||
|
"test",
|
||||||
|
Arc::new(|event: &rhema_rsd::Event| {
|
||||||
|
rhema_rsd::ResourceKey::from(format!("test:{}", event.id))
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
let driver = Arc::new(Driver::new(dispatcher.clone(), handler.clone()));
|
||||||
|
dispatcher
|
||||||
|
.ingest(rhema_rsd::Event {
|
||||||
|
id: "e1".to_owned(),
|
||||||
|
source: "test".to_owned(),
|
||||||
|
payload: serde_json::json!({}),
|
||||||
|
received_at: 0,
|
||||||
|
})
|
||||||
|
.expect("event lands");
|
||||||
|
|
||||||
|
let busy = Arc::new(AtomicBool::new(false));
|
||||||
|
spawn_pass(driver.clone(), "test", busy.clone());
|
||||||
|
// The pass runs on its own task: the caller is already back, and
|
||||||
|
// the lane reads as held while the turn is under way.
|
||||||
|
tokio::time::timeout(Duration::from_secs(5), handler.started.acquire())
|
||||||
|
.await
|
||||||
|
.expect("the pass starts within five seconds")
|
||||||
|
.expect("the pass starts")
|
||||||
|
.forget();
|
||||||
|
assert!(
|
||||||
|
busy.load(Ordering::SeqCst),
|
||||||
|
"the lane is held for the whole pass"
|
||||||
|
);
|
||||||
|
|
||||||
|
spawn_pass(driver.clone(), "test", busy.clone());
|
||||||
|
handler.release.add_permits(1);
|
||||||
|
|
||||||
|
let deadline = tokio::time::Instant::now() + Duration::from_secs(5);
|
||||||
|
while busy.load(Ordering::SeqCst) {
|
||||||
|
assert!(
|
||||||
|
tokio::time::Instant::now() < deadline,
|
||||||
|
"the flag clears when the pass ends"
|
||||||
|
);
|
||||||
|
tokio::time::sleep(Duration::from_millis(5)).await;
|
||||||
|
}
|
||||||
|
assert_eq!(handler.runs.load(Ordering::SeqCst), 1, "one pass, not two");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn the_forge_dispatcher_leases_for_a_turn_not_a_step() {
|
fn the_forge_dispatcher_leases_for_a_turn_not_a_step() {
|
||||||
let dispatch = forge_dispatch();
|
let dispatch = forge_dispatch();
|
||||||
|
|||||||
@@ -565,6 +565,22 @@ impl ForgeSource {
|
|||||||
fed += 1;
|
fed += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// The row is decided — dispatched, surfaced, or ignored — so
|
||||||
|
// consume it: `mark_read` is what stops the feed returning
|
||||||
|
// it. Deciding without consuming is a loop: the poll's cursor
|
||||||
|
// never passes a row the forge still considers unread, so
|
||||||
|
// every pass re-decides it and re-dispatches a turn for a
|
||||||
|
// thread that already has one, and a restart (the cursor is
|
||||||
|
// in memory) replays the whole unread feed.
|
||||||
|
//
|
||||||
|
// Best-effort: an unread row costs a repeat, never a lost
|
||||||
|
// event, so a failed call is logged and the poll carries on.
|
||||||
|
if let Err(err) = client.mark_read(notification).await {
|
||||||
|
eprintln!(
|
||||||
|
"[claw] warning: mark-read of {} failed: {err}",
|
||||||
|
notification.id
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if let Some(cursor) = page.cursor {
|
if let Some(cursor) = page.cursor {
|
||||||
self.account_cursors
|
self.account_cursors
|
||||||
@@ -689,6 +705,65 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The account poll consumes what it decides. The feed is
|
||||||
|
/// at-least-once — the cursor never passes a row the forge still
|
||||||
|
/// considers unread, and a restart asks for the whole unread feed
|
||||||
|
/// again — so a row that is triaged but not marked read comes back
|
||||||
|
/// with the same dedup id on the next pass, and every pass dispatches
|
||||||
|
/// a fresh turn for a thread that already has one.
|
||||||
|
#[tokio::test]
|
||||||
|
async fn a_triaged_account_notification_is_marked_read() {
|
||||||
|
let server = MockServer::start().await;
|
||||||
|
Mock::given(method("GET"))
|
||||||
|
.and(path("/notifications"))
|
||||||
|
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!([
|
||||||
|
{
|
||||||
|
"id": 42188,
|
||||||
|
"unread": true,
|
||||||
|
"reason": "mention",
|
||||||
|
"updated_at": "2026-10-05T12:00:00Z",
|
||||||
|
"subject": {
|
||||||
|
"title": "Add the widget flange",
|
||||||
|
"url": "https://api.github.com/repos/acme/widgets/pulls/142",
|
||||||
|
"type": "PullRequest"
|
||||||
|
},
|
||||||
|
"repository": { "full_name": "acme/widgets" }
|
||||||
|
}
|
||||||
|
])))
|
||||||
|
.mount(&server)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
let store = Arc::new(ClawStore::in_memory().expect("store opens"));
|
||||||
|
let (dispatcher, accounts, notifications) = test_parts(store.clone());
|
||||||
|
// The store mints the id; the watch row is what names it.
|
||||||
|
let account = accounts
|
||||||
|
.put(rhema_identity::AccountDraft::new(
|
||||||
|
"forge bot",
|
||||||
|
"github",
|
||||||
|
rhema_identity::Secret::new(rhema_identity::SecretKind::Token, "acct-tok"),
|
||||||
|
))
|
||||||
|
.expect("account lands");
|
||||||
|
store
|
||||||
|
.add_account_watch("github", Some(&server.uri()), &account.id)
|
||||||
|
.expect("account watch lands");
|
||||||
|
let source = ForgeSource::new(&dispatcher, "github", store, accounts, notifications);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
source.detect().await.expect("the pass runs"),
|
||||||
|
1,
|
||||||
|
"a mention dispatches a turn"
|
||||||
|
);
|
||||||
|
|
||||||
|
// The read route keys on the notification, not the thread.
|
||||||
|
let requests = server.received_requests().await.expect("recording is on");
|
||||||
|
let reads: Vec<_> = requests
|
||||||
|
.iter()
|
||||||
|
.filter(|request| request.method.as_str() == "PUT")
|
||||||
|
.collect();
|
||||||
|
assert_eq!(reads.len(), 1, "one mark-read per triaged row");
|
||||||
|
assert_eq!(reads[0].url.path(), "/notifications/threads/42188");
|
||||||
|
}
|
||||||
|
|
||||||
/// The parts a test source polls through, all in memory.
|
/// The parts a test source polls through, all in memory.
|
||||||
fn test_parts(
|
fn test_parts(
|
||||||
store: Arc<ClawStore>,
|
store: Arc<ClawStore>,
|
||||||
@@ -972,6 +1047,7 @@ mod tests {
|
|||||||
title: Some("Add the flange".to_owned()),
|
title: Some("Add the flange".to_owned()),
|
||||||
url: None,
|
url: None,
|
||||||
timestamp: Timestamp::parse("2026-10-08T00:00:00Z").expect("parses"),
|
timestamp: Timestamp::parse("2026-10-08T00:00:00Z").expect("parses"),
|
||||||
|
read_key: Some("1".to_owned()),
|
||||||
raw: serde_json::json!({}),
|
raw: serde_json::json!({}),
|
||||||
};
|
};
|
||||||
let payload = |notification: &Notification| {
|
let payload = |notification: &Notification| {
|
||||||
@@ -1016,6 +1092,7 @@ mod tests {
|
|||||||
title: Some("a title".to_owned()),
|
title: Some("a title".to_owned()),
|
||||||
url: None,
|
url: None,
|
||||||
timestamp: Timestamp::parse("2026-11-21T00:00:00Z").expect("parses"),
|
timestamp: Timestamp::parse("2026-11-21T00:00:00Z").expect("parses"),
|
||||||
|
read_key: Some("1".to_owned()),
|
||||||
raw: serde_json::json!({}),
|
raw: serde_json::json!({}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -977,6 +977,7 @@ mod tests {
|
|||||||
"title": "Add the widget flange",
|
"title": "Add the widget flange",
|
||||||
"url": null,
|
"url": null,
|
||||||
"timestamp": "2026-10-03T09:00:00Z",
|
"timestamp": "2026-10-03T09:00:00Z",
|
||||||
|
"read_key": "42188",
|
||||||
"raw": {},
|
"raw": {},
|
||||||
}))
|
}))
|
||||||
.expect("notification fixture parses")
|
.expect("notification fixture parses")
|
||||||
|
|||||||
@@ -2016,6 +2016,8 @@ fn sandbox_json(state: &ClawState) -> Value {
|
|||||||
"kind": choice.kind.as_str(),
|
"kind": choice.kind.as_str(),
|
||||||
"url": choice.url,
|
"url": choice.url,
|
||||||
"token_set": choice.token.as_deref().is_some_and(|token| !token.is_empty()),
|
"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(),
|
"workspace": state.sandbox().workspace().display().to_string(),
|
||||||
"local_workspace": state.sandbox().local_workspace().display().to_string(),
|
"local_workspace": state.sandbox().local_workspace().display().to_string(),
|
||||||
"remote_workspace": crate::sandbox::REMOTE_WORKSPACE,
|
"remote_workspace": crate::sandbox::REMOTE_WORKSPACE,
|
||||||
@@ -2051,6 +2053,14 @@ async fn sandbox_put(
|
|||||||
.map(str::to_owned)
|
.map(str::to_owned)
|
||||||
.or_else(|| current.url.clone()),
|
.or_else(|| current.url.clone()),
|
||||||
token,
|
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 {
|
state.sandbox().set(choice).map_err(|err| match err {
|
||||||
crate::sandbox::SandboxError::Invalid(_) => bad_request(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
|
//! Where the claw's `bash` runs: this host's processes, a daemon
|
||||||
//! speaking the sandbox protocol over HTTP.
|
//! 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
|
//! The choice is deployment state, persisted in the settings table and
|
||||||
//! changeable over `/v1/sandbox`. `local` keeps the shell the claw
|
//! changeable over `/v1/sandbox`. `local` keeps the shell the claw
|
||||||
//! always had. `http` builds an `HttpSandbox` for a `rhema-sandboxd`
|
//! always had. `http` builds an `HttpSandbox` for a `rhema-sandboxd`.
|
||||||
//! and gives the handlers a `ShellSandbox` executor over it. The tool
|
//! `ssh` builds an `SshSandbox` on a destination the local ssh config
|
||||||
//! spec, approval gate, output caps, and error shaping stay in
|
//! resolves, no daemon on the far end. The tool spec, approval gate,
|
||||||
//! `ShellTools`; only the machine changes.
|
//! output caps, and error shaping stay in `ShellTools`; only the
|
||||||
|
//! machine changes.
|
||||||
//!
|
//!
|
||||||
//! A remote sandbox starts empty. On the first command for a
|
//! A remote sandbox starts empty. On the first command for a
|
||||||
//! workspace, the executor probes `/workspace` and, when it is empty,
|
//! workspace, the executor probes the workspace root and, when it is
|
||||||
//! sends the host workspace as a tarball through the protocol's seed
|
//! empty, sends the host workspace as a tarball through the seed
|
||||||
//! route. Later edits stay in the sandbox; the claw does not copy them
|
//! route. Later edits stay in the sandbox; the claw does not copy them
|
||||||
//! back.
|
//! back.
|
||||||
|
|
||||||
@@ -25,6 +27,7 @@ use base64::Engine as _;
|
|||||||
use rhema_bash::exec::{Executed, ShellError, ShellExecutor, default_executor_with};
|
use rhema_bash::exec::{Executed, ShellError, ShellExecutor, default_executor_with};
|
||||||
use rhema_sandbox::{ExecRequest, Sandbox, ShellSandbox, WorkspaceSeed};
|
use rhema_sandbox::{ExecRequest, Sandbox, ShellSandbox, WorkspaceSeed};
|
||||||
use rhema_sandbox_http::HttpSandbox;
|
use rhema_sandbox_http::HttpSandbox;
|
||||||
|
use rhema_sandbox_ssh::SshSandbox;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::settings::SettingsStore;
|
use crate::settings::SettingsStore;
|
||||||
@@ -32,10 +35,15 @@ use crate::settings::SettingsStore;
|
|||||||
/// The settings key the chosen sandbox is persisted under.
|
/// The settings key the chosen sandbox is persisted under.
|
||||||
pub const SANDBOX_KEY: &str = "sandbox";
|
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.
|
/// fixed by the protocol.
|
||||||
pub const REMOTE_WORKSPACE: &str = "/workspace";
|
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
|
/// The per-command budget of the emptiness probe before a seed: long
|
||||||
/// enough for a fresh sandbox, short enough that an unreachable daemon
|
/// enough for a fresh sandbox, short enough that an unreachable daemon
|
||||||
/// fails the turn rather than stalling it.
|
/// fails the turn rather than stalling it.
|
||||||
@@ -50,6 +58,8 @@ pub enum SandboxKind {
|
|||||||
Local,
|
Local,
|
||||||
/// A host speaking the sandbox protocol over HTTP.
|
/// A host speaking the sandbox protocol over HTTP.
|
||||||
Http,
|
Http,
|
||||||
|
/// A remote login reached with `ssh`, no daemon on the far end.
|
||||||
|
Ssh,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SandboxKind {
|
impl SandboxKind {
|
||||||
@@ -58,6 +68,7 @@ impl SandboxKind {
|
|||||||
match self {
|
match self {
|
||||||
Self::Local => "local",
|
Self::Local => "local",
|
||||||
Self::Http => "http",
|
Self::Http => "http",
|
||||||
|
Self::Ssh => "ssh",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,6 +78,7 @@ impl SandboxKind {
|
|||||||
match value {
|
match value {
|
||||||
"local" => Some(Self::Local),
|
"local" => Some(Self::Local),
|
||||||
"http" => Some(Self::Http),
|
"http" => Some(Self::Http),
|
||||||
|
"ssh" => Some(Self::Ssh),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,6 +98,14 @@ pub struct SandboxChoice {
|
|||||||
/// The shared secret the daemon checks, when it guards its routes.
|
/// The shared secret the daemon checks, when it guards its routes.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub token: Option<String>,
|
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 {
|
impl SandboxChoice {
|
||||||
@@ -101,6 +121,32 @@ impl SandboxChoice {
|
|||||||
.token
|
.token
|
||||||
.map(|token| token.trim().to_owned())
|
.map(|token| token.trim().to_owned())
|
||||||
.filter(|token| !token.is_empty());
|
.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 {
|
if self.kind == SandboxKind::Http {
|
||||||
let url = self
|
let url = self
|
||||||
.url
|
.url
|
||||||
@@ -117,7 +163,22 @@ impl SandboxChoice {
|
|||||||
|
|
||||||
/// Whether commands leave this host.
|
/// Whether commands leave this host.
|
||||||
pub fn is_remote(&self) -> bool {
|
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>,
|
settings: Arc<SettingsStore>,
|
||||||
local_workspace: PathBuf,
|
local_workspace: PathBuf,
|
||||||
local: Arc<dyn ShellExecutor>,
|
local: Arc<dyn ShellExecutor>,
|
||||||
remote: Mutex<HashMap<String, Arc<HttpSandbox>>>,
|
remote: Mutex<HashMap<String, Arc<dyn Sandbox>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SandboxState {
|
impl SandboxState {
|
||||||
@@ -204,13 +265,9 @@ impl SandboxState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The workspace a handler should name and start commands in: the
|
/// 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 {
|
pub fn workspace_for(&self, host: &Path) -> PathBuf {
|
||||||
if self.is_remote() {
|
self.choice().remote_root(host)
|
||||||
PathBuf::from(REMOTE_WORKSPACE)
|
|
||||||
} else {
|
|
||||||
host.to_path_buf()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The chat workspace under the current choice, for the settings
|
/// 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
|
/// The cached sandbox for one session. The map is cleared whenever
|
||||||
/// whenever the choice changes, so a new URL or token builds a new
|
/// the choice changes, so a new URL, token, host, or base builds a
|
||||||
/// client.
|
/// new client.
|
||||||
fn remote_sandbox(
|
fn remote_sandbox(
|
||||||
&self,
|
&self,
|
||||||
choice: &SandboxChoice,
|
choice: &SandboxChoice,
|
||||||
host: &Path,
|
host: &Path,
|
||||||
) -> Result<Arc<HttpSandbox>, ShellError> {
|
) -> Result<Arc<dyn Sandbox>, ShellError> {
|
||||||
let url = choice
|
|
||||||
.url
|
|
||||||
.as_deref()
|
|
||||||
.ok_or_else(|| ShellError::Failed("the http sandbox has no url".to_owned()))?;
|
|
||||||
let session = session_name(host);
|
let session = session_name(host);
|
||||||
{
|
{
|
||||||
let remote = self.remote.lock().unwrap_or_else(PoisonError::into_inner);
|
let remote = self.remote.lock().unwrap_or_else(PoisonError::into_inner);
|
||||||
@@ -258,8 +311,31 @@ impl SandboxState {
|
|||||||
return Ok(sandbox.clone());
|
return Ok(sandbox.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let token = choice.token.as_deref().unwrap_or("");
|
let sandbox: Arc<dyn Sandbox> = match choice.kind {
|
||||||
let sandbox = Arc::new(HttpSandbox::new(url.to_owned(), &session, token));
|
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("");
|
||||||
|
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
|
self.remote
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap_or_else(PoisonError::into_inner)
|
.unwrap_or_else(PoisonError::into_inner)
|
||||||
@@ -280,20 +356,32 @@ struct ClawShell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl 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
|
/// 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(
|
async fn seed(
|
||||||
&self,
|
&self,
|
||||||
sandbox: &Arc<HttpSandbox>,
|
sandbox: &Arc<dyn Sandbox>,
|
||||||
cancelled: &AtomicBool,
|
cancelled: &AtomicBool,
|
||||||
) -> Result<(), ShellError> {
|
) -> Result<(), ShellError> {
|
||||||
|
let root = self
|
||||||
|
.state
|
||||||
|
.workspace_for(&self.host_workspace)
|
||||||
|
.to_string_lossy()
|
||||||
|
.to_string();
|
||||||
let mut sink = |_line: &str| {};
|
let mut sink = |_line: &str| {};
|
||||||
let probe = sandbox
|
let probe = sandbox
|
||||||
.exec(
|
.exec(
|
||||||
ExecRequest {
|
ExecRequest {
|
||||||
command: "ls -A /workspace 2>/dev/null | head -n 1".to_owned(),
|
command: format!(
|
||||||
cwd: REMOTE_WORKSPACE.to_owned(),
|
"mkdir -p {}; ls -A {} 2>/dev/null | head -n 1",
|
||||||
|
shquote(&root),
|
||||||
|
shquote(&root)
|
||||||
|
),
|
||||||
|
cwd: root.clone(),
|
||||||
timeout: PROBE_TIMEOUT,
|
timeout: PROBE_TIMEOUT,
|
||||||
},
|
},
|
||||||
cancelled,
|
cancelled,
|
||||||
@@ -353,15 +441,9 @@ impl ShellExecutor for ClawShell {
|
|||||||
self.seed(&sandbox, cancelled).await?;
|
self.seed(&sandbox, cancelled).await?;
|
||||||
self.seeded.store(true, Ordering::Relaxed);
|
self.seeded.store(true, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
let sandbox: Arc<dyn Sandbox> = sandbox;
|
let root = choice.remote_root(&self.host_workspace);
|
||||||
ShellSandbox::new(sandbox)
|
ShellSandbox::new(sandbox)
|
||||||
.run(
|
.run(command, &root, timeout, cancelled, progress)
|
||||||
command,
|
|
||||||
Path::new(REMOTE_WORKSPACE),
|
|
||||||
timeout,
|
|
||||||
cancelled,
|
|
||||||
progress,
|
|
||||||
)
|
|
||||||
.await
|
.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
|
/// 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
|
/// hash of the path, so the daemon can multiplex one root per session
|
||||||
/// and a restart finds the same root.
|
/// and a restart finds the same root.
|
||||||
@@ -458,7 +547,7 @@ mod tests {
|
|||||||
let missing = SandboxChoice {
|
let missing = SandboxChoice {
|
||||||
kind: SandboxKind::Http,
|
kind: SandboxKind::Http,
|
||||||
url: None,
|
url: None,
|
||||||
token: None,
|
..SandboxChoice::default()
|
||||||
}
|
}
|
||||||
.normalized();
|
.normalized();
|
||||||
assert!(missing.is_err(), "a URL is required");
|
assert!(missing.is_err(), "a URL is required");
|
||||||
@@ -466,18 +555,63 @@ mod tests {
|
|||||||
let relative = SandboxChoice {
|
let relative = SandboxChoice {
|
||||||
kind: SandboxKind::Http,
|
kind: SandboxKind::Http,
|
||||||
url: Some("box.example:7600".to_owned()),
|
url: Some("box.example:7600".to_owned()),
|
||||||
token: None,
|
..SandboxChoice::default()
|
||||||
}
|
}
|
||||||
.normalized();
|
.normalized();
|
||||||
assert!(relative.is_err(), "a bare host is not a URL");
|
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]
|
#[test]
|
||||||
fn the_remote_workspace_is_the_sandbox_root() {
|
fn the_remote_workspace_is_the_sandbox_root() {
|
||||||
let state = state(SandboxChoice {
|
let state = state(SandboxChoice {
|
||||||
kind: SandboxKind::Http,
|
kind: SandboxKind::Http,
|
||||||
url: Some("http://box:7600/".to_owned()),
|
url: Some("http://box:7600/".to_owned()),
|
||||||
token: None,
|
..SandboxChoice::default()
|
||||||
});
|
});
|
||||||
assert_eq!(state.workspace(), PathBuf::from(REMOTE_WORKSPACE));
|
assert_eq!(state.workspace(), PathBuf::from(REMOTE_WORKSPACE));
|
||||||
assert_eq!(
|
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]
|
#[test]
|
||||||
fn a_choice_persists_and_reloads() {
|
fn a_choice_persists_and_reloads() {
|
||||||
let settings = Arc::new(SettingsStore::in_memory().expect("the store opens"));
|
let settings = Arc::new(SettingsStore::in_memory().expect("the store opens"));
|
||||||
@@ -504,6 +668,7 @@ mod tests {
|
|||||||
kind: SandboxKind::Http,
|
kind: SandboxKind::Http,
|
||||||
url: Some("https://box:7600".to_owned()),
|
url: Some("https://box:7600".to_owned()),
|
||||||
token: Some("secret".to_owned()),
|
token: Some("secret".to_owned()),
|
||||||
|
..SandboxChoice::default()
|
||||||
})
|
})
|
||||||
.expect("the choice saves");
|
.expect("the choice saves");
|
||||||
|
|
||||||
@@ -515,6 +680,38 @@ mod tests {
|
|||||||
assert_eq!(reloaded.choice().token.as_deref(), Some("secret"));
|
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]
|
#[tokio::test]
|
||||||
async fn a_remote_command_seeds_a_fresh_sandbox_and_runs() {
|
async fn a_remote_command_seeds_a_fresh_sandbox_and_runs() {
|
||||||
let server = MockServer::start().await;
|
let server = MockServer::start().await;
|
||||||
@@ -556,7 +753,7 @@ mod tests {
|
|||||||
let state = state(SandboxChoice {
|
let state = state(SandboxChoice {
|
||||||
kind: SandboxKind::Http,
|
kind: SandboxKind::Http,
|
||||||
url: Some(server.uri()),
|
url: Some(server.uri()),
|
||||||
token: None,
|
..SandboxChoice::default()
|
||||||
});
|
});
|
||||||
let executor = state.executor(dir.path());
|
let executor = state.executor(dir.path());
|
||||||
let cancelled = AtomicBool::new(false);
|
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");
|
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
|
/// The agent identity surface: the text fields round-trip with
|
||||||
/// partial-save semantics (an absent field is left alone, an empty one
|
/// partial-save semantics (an absent field is left alone, an empty one
|
||||||
/// clears), the avatar uploads and serves back with its content type,
|
/// clears), the avatar uploads and serves back with its content type,
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ FROM debian:stable-slim
|
|||||||
# bash and git are load-bearing, not conveniences: the coding agent shells
|
# bash and git are load-bearing, not conveniences: the coding agent shells
|
||||||
# out via `bash -c` and clones/fetches in its per-thread workspaces.
|
# out via `bash -c` and clones/fetches in its per-thread workspaces.
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y --no-install-recommends bash git tar ca-certificates \
|
&& apt-get install -y --no-install-recommends bash curl git tar ca-certificates \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Numeric USER: Kubernetes cannot verify runAsNonRoot against a name.
|
# Numeric USER: Kubernetes cannot verify runAsNonRoot against a name.
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ FROM debian:stable-slim
|
|||||||
# load-bearing too: a `{git}` seed is a `git clone` (tarball seeds need
|
# load-bearing too: a `{git}` seed is a `git clone` (tarball seeds need
|
||||||
# neither).
|
# neither).
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y --no-install-recommends bash git tar ca-certificates \
|
&& apt-get install -y --no-install-recommends bash curl git tar ca-certificates \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Numeric USER: Kubernetes cannot verify runAsNonRoot against a name.
|
# Numeric USER: Kubernetes cannot verify runAsNonRoot against a name.
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ publish = false
|
|||||||
rusqlite = { version = "0.40", features = ["bundled"] }
|
rusqlite = { version = "0.40", features = ["bundled"] }
|
||||||
# The reminder source: one `Source` over the feeds, detect-pass shaped
|
# The reminder source: one `Source` over the feeds, detect-pass shaped
|
||||||
# like the task scheduler's
|
# 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
|
# The reminder source ingests its slots into a `Dispatcher`; the event
|
||||||
# and key-function shapes are the dispatcher's
|
# and key-function shapes are the dispatcher's
|
||||||
rhema-rsd = "0.4.0"
|
rhema-rsd = "0.4.1"
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ publish = false
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# The dispatch seam: watches ingest into a Dispatcher
|
# The dispatch seam: watches ingest into a Dispatcher
|
||||||
rhema-rsd = "0.4.0"
|
rhema-rsd = "0.4.1"
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
|
|||||||
@@ -230,6 +230,17 @@ pub struct Notification {
|
|||||||
/// When the notification row was last touched. The poll cursor
|
/// When the notification row was last touched. The poll cursor
|
||||||
/// advances to the newest of these.
|
/// advances to the newest of these.
|
||||||
pub timestamp: Timestamp,
|
pub timestamp: Timestamp,
|
||||||
|
/// What the backend's read-marking route keys on, when it has one —
|
||||||
|
/// GitHub's `PUT /notifications/threads/{id}` takes the numeric
|
||||||
|
/// notification id, which [`Notification::id`] embeds only as text
|
||||||
|
/// (its suffix is the dedup timestamp, not the row's identity).
|
||||||
|
/// `None` on a backend with no read route.
|
||||||
|
///
|
||||||
|
/// Defaulted on deserialize: rows already in a dispatcher inbox were
|
||||||
|
/// written before this field existed, and a replay must not fail on
|
||||||
|
/// one.
|
||||||
|
#[serde(default)]
|
||||||
|
pub read_key: Option<String>,
|
||||||
/// The untouched wire row, minus the keys the notification lifts.
|
/// The untouched wire row, minus the keys the notification lifts.
|
||||||
pub raw: serde_json::Value,
|
pub raw: serde_json::Value,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,9 @@
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
|
||||||
use crate::error::ForgeError;
|
use crate::error::ForgeError;
|
||||||
use crate::event::{ForgeEvent, ForgeThreadKind, NotificationPage, RepoRef, Snapshot, Timestamp};
|
use crate::event::{
|
||||||
|
ForgeEvent, ForgeThreadKind, Notification, NotificationPage, RepoRef, Snapshot, Timestamp,
|
||||||
|
};
|
||||||
|
|
||||||
/// One poll's worth of activity, with the cursor to continue from.
|
/// One poll's worth of activity, with the cursor to continue from.
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
@@ -100,6 +102,25 @@ pub trait Forge: Send + Sync {
|
|||||||
since: Option<&Timestamp>,
|
since: Option<&Timestamp>,
|
||||||
) -> Result<NotificationPage, ForgeError>;
|
) -> Result<NotificationPage, ForgeError>;
|
||||||
|
|
||||||
|
/// Marks `notification` read on the forge, so the account's feed
|
||||||
|
/// stops returning it.
|
||||||
|
///
|
||||||
|
/// The feed is at-least-once: `since` is inclusive at the boundary
|
||||||
|
/// and the cursor only ever advances to the newest row seen, so a row
|
||||||
|
/// that the poll cannot get past — anything at or before the cursor,
|
||||||
|
/// every poll — comes back for as long as the forge considers it
|
||||||
|
/// unread. Dedup ids absorb a repeat *within* one pass, but a row
|
||||||
|
/// re-read on the next pass is a fresh event with the same id, and a
|
||||||
|
/// restart drops the in-memory cursor entirely and asks for the whole
|
||||||
|
/// unread feed again. Deciding a row is therefore not the same as
|
||||||
|
/// consuming it; this is the call that consumes it.
|
||||||
|
///
|
||||||
|
/// The default is a no-op: a backend with no read route repeats its
|
||||||
|
/// rows, which its dedup ids absorb — noisier, never wrong.
|
||||||
|
async fn mark_read(&self, _notification: &Notification) -> Result<(), ForgeError> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// The login this client authenticates as — the backend's own answer
|
/// The login this client authenticates as — the backend's own answer
|
||||||
/// to "who am I".
|
/// to "who am I".
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -585,6 +585,9 @@ fn notification_event(row: &WireNotification) -> Result<Option<Notification>, Fo
|
|||||||
title: subject.title.clone(),
|
title: subject.title.clone(),
|
||||||
url: None,
|
url: None,
|
||||||
timestamp: updated,
|
timestamp: updated,
|
||||||
|
// No read-marking route in this backend yet; the feed's repeat is
|
||||||
|
// absorbed by the dedup id.
|
||||||
|
read_key: None,
|
||||||
raw: Value::Object(row.raw.clone()),
|
raw: Value::Object(row.raw.clone()),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,6 +120,17 @@ impl GitHubForge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A PUT builder for `path` with auth applied.
|
||||||
|
fn put(&self, path: &str) -> reqwest::RequestBuilder {
|
||||||
|
let base = &self.base_url;
|
||||||
|
let request = self.http.put(format!("{base}{path}"));
|
||||||
|
if self.token.is_empty() {
|
||||||
|
request
|
||||||
|
} else {
|
||||||
|
request.bearer_auth(&self.token)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Follows `per_page`/`page` pagination until a short page.
|
/// Follows `per_page`/`page` pagination until a short page.
|
||||||
async fn paged<T: DeserializeOwned>(
|
async fn paged<T: DeserializeOwned>(
|
||||||
&self,
|
&self,
|
||||||
@@ -509,6 +520,9 @@ fn notification_event(row: &WireNotification) -> Result<Option<Notification>, Fo
|
|||||||
title: subject.title.clone(),
|
title: subject.title.clone(),
|
||||||
url: None,
|
url: None,
|
||||||
timestamp: updated,
|
timestamp: updated,
|
||||||
|
// `PUT /notifications/threads/{id}` is keyed on this same id:
|
||||||
|
// the notification, not the thread's number.
|
||||||
|
read_key: Some(id.to_string()),
|
||||||
raw: Value::Object(row.raw.clone()),
|
raw: Value::Object(row.raw.clone()),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@@ -736,6 +750,22 @@ impl Forge for GitHubForge {
|
|||||||
}
|
}
|
||||||
Ok(NotificationPage::finish(notifications, since))
|
Ok(NotificationPage::finish(notifications, since))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn mark_read(&self, notification: &Notification) -> Result<(), ForgeError> {
|
||||||
|
let Some(read_key) = notification.read_key.as_deref() else {
|
||||||
|
// A row built without one is a shape break, not a forge
|
||||||
|
// outage: say so instead of silently re-reading it forever.
|
||||||
|
return Err(ForgeError::Parse(format!(
|
||||||
|
"notification {} carries no read key",
|
||||||
|
notification.id
|
||||||
|
)));
|
||||||
|
};
|
||||||
|
let path = format!("/notifications/threads/{read_key}");
|
||||||
|
let response = self.put(&path).send().await.map_err(ForgeError::network)?;
|
||||||
|
// 205 Reset Content: marked, nothing to decode.
|
||||||
|
ensure_success(response).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@@ -927,6 +957,7 @@ mod tests {
|
|||||||
notification.id,
|
notification.id,
|
||||||
"github:notification:27210544329@2026-11-21T22:33:00Z"
|
"github:notification:27210544329@2026-11-21T22:33:00Z"
|
||||||
);
|
);
|
||||||
|
assert_eq!(notification.read_key.as_deref(), Some("27210544329"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -947,6 +978,7 @@ mod tests {
|
|||||||
notification.id,
|
notification.id,
|
||||||
"github:notification:42188@2026-10-08T12:00:00Z"
|
"github:notification:42188@2026-10-08T12:00:00Z"
|
||||||
);
|
);
|
||||||
|
assert_eq!(notification.read_key.as_deref(), Some("42188"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -331,6 +331,9 @@ fn todo_notification(row: &WireTodo) -> Result<Option<Notification>, ForgeError>
|
|||||||
title: target.title.clone(),
|
title: target.title.clone(),
|
||||||
url: row.target_url.clone(),
|
url: row.target_url.clone(),
|
||||||
timestamp: updated,
|
timestamp: updated,
|
||||||
|
// No read-marking route in this backend yet; the feed's repeat is
|
||||||
|
// absorbed by the dedup id.
|
||||||
|
read_key: None,
|
||||||
raw: Value::Object(row.raw.clone()),
|
raw: Value::Object(row.raw.clone()),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ mod tests {
|
|||||||
title: None,
|
title: None,
|
||||||
url: None,
|
url: None,
|
||||||
timestamp: Timestamp::parse("2026-10-08T00:00:00Z").expect("parses"),
|
timestamp: Timestamp::parse("2026-10-08T00:00:00Z").expect("parses"),
|
||||||
|
read_key: Some("1".to_owned()),
|
||||||
raw: serde_json::json!({}),
|
raw: serde_json::json!({}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
//! wiremock server. Zero network.
|
//! wiremock server. Zero network.
|
||||||
|
|
||||||
use rhema_forge_integration::{
|
use rhema_forge_integration::{
|
||||||
EventKind, Forge, ForgeError, ForgeThreadKind, GitHubForge, NotificationReason, RepoRef,
|
EventKind, Forge, ForgeError, ForgeThreadKind, GitHubForge, Notification, NotificationReason,
|
||||||
Timestamp,
|
RepoRef, Timestamp,
|
||||||
};
|
};
|
||||||
use serde_json::{Value, json};
|
use serde_json::{Value, json};
|
||||||
use wiremock::matchers::{header, method, path, query_param};
|
use wiremock::matchers::{header, method, path, query_param};
|
||||||
@@ -533,6 +533,89 @@ async fn notifications_without_a_cursor_still_return_the_newest_seen() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A notification row, as the account's feed sends it.
|
||||||
|
fn notification_row(id: i64, reason: &str, number: u64) -> Value {
|
||||||
|
json!({
|
||||||
|
"id": id,
|
||||||
|
"unread": true,
|
||||||
|
"reason": reason,
|
||||||
|
"updated_at": "2026-10-05T12:00:00Z",
|
||||||
|
"subject": {
|
||||||
|
"title": "Add the widget flange",
|
||||||
|
"url": format!("https://api.github.com/repos/acme/widgets/issues/{number}"),
|
||||||
|
"type": "Issue"
|
||||||
|
},
|
||||||
|
"repository": { "full_name": "acme/widgets" }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Deciding a row is not consuming it: the feed keeps returning anything
|
||||||
|
/// the account still has unread, so the read route is what ends the
|
||||||
|
/// repeat. It keys on the notification's own id, not the thread number —
|
||||||
|
/// the dedup id keeps that integer only as text.
|
||||||
|
#[tokio::test]
|
||||||
|
async fn marking_a_notification_read_puts_its_thread() {
|
||||||
|
let server = MockServer::start().await;
|
||||||
|
Mock::given(method("GET"))
|
||||||
|
.and(path("/notifications"))
|
||||||
|
.respond_with(
|
||||||
|
ResponseTemplate::new(200).set_body_json(json!([notification_row(
|
||||||
|
42188,
|
||||||
|
"review_requested",
|
||||||
|
142
|
||||||
|
)])),
|
||||||
|
)
|
||||||
|
.mount(&server)
|
||||||
|
.await;
|
||||||
|
Mock::given(method("PUT"))
|
||||||
|
.and(path("/notifications/threads/42188"))
|
||||||
|
.and(header("authorization", "Bearer tok"))
|
||||||
|
.respond_with(ResponseTemplate::new(205))
|
||||||
|
.mount(&server)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
let forge = forge(&server);
|
||||||
|
let page = forge.notifications(None).await.expect("poll succeeds");
|
||||||
|
let notification = &page.notifications[0];
|
||||||
|
forge.mark_read(notification).await.expect("marks read");
|
||||||
|
|
||||||
|
let requests = server.received_requests().await.expect("recording is on");
|
||||||
|
let puts: Vec<_> = requests
|
||||||
|
.iter()
|
||||||
|
.filter(|request| request.method.as_str() == "PUT")
|
||||||
|
.collect();
|
||||||
|
assert_eq!(puts.len(), 1, "one read call, on the row's id");
|
||||||
|
assert_eq!(puts[0].url.path(), "/notifications/threads/42188");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A row that reaches the caller with no read key is a shape break, not a
|
||||||
|
/// silent no-op: re-reading the same thread forever is the failure this
|
||||||
|
/// whole route exists to stop.
|
||||||
|
#[tokio::test]
|
||||||
|
async fn a_notification_without_a_read_key_fails_loudly() {
|
||||||
|
// Defaulted on deserialize, so this is also the row an inbox written
|
||||||
|
// before the field existed decodes to.
|
||||||
|
let notification: Notification = serde_json::from_value(json!({
|
||||||
|
"id": "github:notification:42188@2026-10-05T12:00:00Z",
|
||||||
|
"reason": "review_requested",
|
||||||
|
"repo": { "owner": "acme", "name": "widgets" },
|
||||||
|
"number": 142,
|
||||||
|
"is_pr": false,
|
||||||
|
"actor": null,
|
||||||
|
"title": "Add the widget flange",
|
||||||
|
"url": null,
|
||||||
|
"timestamp": "2026-10-05T12:00:00Z",
|
||||||
|
"raw": {}
|
||||||
|
}))
|
||||||
|
.expect("a read-key-less row parses");
|
||||||
|
|
||||||
|
let err = GitHubForge::new("tok")
|
||||||
|
.mark_read(¬ification)
|
||||||
|
.await
|
||||||
|
.expect_err("loud failure");
|
||||||
|
assert!(matches!(err, ForgeError::Parse(_)), "got: {err:?}");
|
||||||
|
}
|
||||||
|
|
||||||
/// The mention gate asks the forge who the credential is, because a token
|
/// The mention gate asks the forge who the credential is, because a token
|
||||||
/// read from a watch row names nobody.
|
/// read from a watch row names nobody.
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
|||||||
@@ -523,7 +523,11 @@ async function saveSandbox(choice: SandboxSelection): Promise<void> {
|
|||||||
try {
|
try {
|
||||||
sandboxState.value = await claw.setSandbox(choice)
|
sandboxState.value = await claw.setSandbox(choice)
|
||||||
pushNotice(
|
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
|
apiError.value = null
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -519,6 +519,10 @@ function streamTone(status: StreamStatus): 'ok' | 'warn' | 'error' {
|
|||||||
@download-attachment="(id, name) => emit('downloadAttachment', id, name)"
|
@download-attachment="(id, name) => emit('downloadAttachment', id, name)"
|
||||||
/>
|
/>
|
||||||
<AppMarkdown v-if="live.reply" :text="live.reply" streaming class="reply" />
|
<AppMarkdown v-if="live.reply" :text="live.reply" streaming class="reply" />
|
||||||
|
<p v-if="!live.reply" class="working" role="status">
|
||||||
|
<span class="spinner" aria-hidden="true" />
|
||||||
|
{{ agentName }} is working…
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -755,6 +759,42 @@ function streamTone(status: StreamStatus): 'ok' | 'warn' | 'error' {
|
|||||||
color: var(--accent-text);
|
color: var(--accent-text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* While the turn runs but no reply text has landed yet. Tool rows and
|
||||||
|
the thinking trace never render on this surface, so this line is the
|
||||||
|
turn's only pulse between its first event and its first delta — the
|
||||||
|
streaming cursor takes over once text arrives, and the line goes.
|
||||||
|
Reduced motion gets the static ring. */
|
||||||
|
.working {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin: 4px 0 0;
|
||||||
|
color: var(--text3);
|
||||||
|
font-size: 12.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner {
|
||||||
|
flex: none;
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
border: 2px solid var(--border-strong);
|
||||||
|
border-top-color: var(--accent);
|
||||||
|
border-radius: 50%;
|
||||||
|
animation: spin 0.8s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
to {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.spinner {
|
||||||
|
animation: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* A consent card: the agent asking its human something — distinct
|
/* A consent card: the agent asking its human something — distinct
|
||||||
from a tool row, toned by its resolution. */
|
from a tool row, toned by its resolution. */
|
||||||
.consent-card {
|
.consent-card {
|
||||||
|
|||||||
@@ -7,6 +7,10 @@
|
|||||||
// new key lands in the inventory. The delete button asks nothing itself
|
// new key lands in the inventory. The delete button asks nothing itself
|
||||||
// — the confirmation, which names the transcript that goes with the
|
// — the confirmation, which names the transcript that goes with the
|
||||||
// session, is the shell's.
|
// session, is the shell's.
|
||||||
|
//
|
||||||
|
// The non-interactive keys fold under *others*: folded (the default),
|
||||||
|
// the group shows only how many of them hold a lease, plus the
|
||||||
|
// more/less toggle; unfolded it lists every row.
|
||||||
import { SESSION_NAME_PATTERN, isResidentKey } from '~/composables/useClaw'
|
import { SESSION_NAME_PATTERN, isResidentKey } from '~/composables/useClaw'
|
||||||
import type { ClawSession } from '~/composables/useClaw'
|
import type { ClawSession } from '~/composables/useClaw'
|
||||||
|
|
||||||
@@ -28,6 +32,10 @@ const emit = defineEmits<{
|
|||||||
interface Group {
|
interface Group {
|
||||||
label: string
|
label: string
|
||||||
rows: { key: string; name: string; session: ClawSession }[]
|
rows: { key: string; name: string; session: ClawSession }[]
|
||||||
|
/** How many rows hold a lease; the others' header shows the count. */
|
||||||
|
working: number
|
||||||
|
/** Whether the rows fold away until the toggle says otherwise. */
|
||||||
|
collapsible: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const groups = computed<Group[]>(() => {
|
const groups = computed<Group[]>(() => {
|
||||||
@@ -52,13 +60,29 @@ const groups = computed<Group[]>(() => {
|
|||||||
name: session.key.replace(/^interactive:/, ''),
|
name: session.key.replace(/^interactive:/, ''),
|
||||||
session,
|
session,
|
||||||
})
|
})
|
||||||
|
const working = (sessions: ClawSession[]) =>
|
||||||
|
sessions.filter((session) => session.state === 'leased').length
|
||||||
const groups: Group[] = []
|
const groups: Group[] = []
|
||||||
if (interactive.length > 0)
|
if (interactive.length > 0)
|
||||||
groups.push({ label: 'interactive', rows: interactive.map(row) })
|
groups.push({
|
||||||
if (others.length > 0) groups.push({ label: 'other keys', rows: others.map(row) })
|
label: 'interactive',
|
||||||
|
rows: interactive.map(row),
|
||||||
|
working: working(interactive),
|
||||||
|
collapsible: false,
|
||||||
|
})
|
||||||
|
if (others.length > 0)
|
||||||
|
groups.push({
|
||||||
|
label: 'others',
|
||||||
|
rows: others.map(row),
|
||||||
|
working: working(others),
|
||||||
|
collapsible: true,
|
||||||
|
})
|
||||||
return groups
|
return groups
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** Whether the others group is folded out; it starts folded. */
|
||||||
|
const othersOpen = ref(false)
|
||||||
|
|
||||||
const shownCount = computed(() =>
|
const shownCount = computed(() =>
|
||||||
groups.value.reduce((total, group) => total + group.rows.length, 0),
|
groups.value.reduce((total, group) => total + group.rows.length, 0),
|
||||||
)
|
)
|
||||||
@@ -159,30 +183,45 @@ watch(
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div v-for="group in groups" :key="group.label" class="group">
|
<div v-for="group in groups" :key="group.label" class="group">
|
||||||
<span class="label">{{ group.label }}</span>
|
<div class="group-head">
|
||||||
<div
|
<span class="label">{{ group.label }}</span>
|
||||||
v-for="row in group.rows"
|
<span v-if="group.collapsible" class="working" :class="{ live: group.working > 0 }">
|
||||||
:key="row.key"
|
{{ group.working }} working
|
||||||
class="row"
|
</span>
|
||||||
:class="{ active: row.key === activeKey }"
|
|
||||||
:title="row.key"
|
|
||||||
>
|
|
||||||
<button class="entry" @click="$emit('select', row.key)">
|
|
||||||
<StatusDot :tone="stateTone(row.session.state)" />
|
|
||||||
<span class="name">{{ row.name }}</span>
|
|
||||||
<span v-if="row.session.inbox_depth > 0" class="depth" title="inbox depth">
|
|
||||||
{{ row.session.inbox_depth }}
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
<button
|
<button
|
||||||
class="ghost remove"
|
v-if="group.collapsible"
|
||||||
aria-label="delete session"
|
class="ghost toggle"
|
||||||
:title="`delete ${row.key}`"
|
:title="othersOpen ? 'fold the other keys away' : 'show every other key'"
|
||||||
@click.stop="$emit('delete', row.key)"
|
@click="othersOpen = !othersOpen"
|
||||||
>
|
>
|
||||||
×
|
{{ othersOpen ? 'less' : 'more' }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<template v-if="!group.collapsible || othersOpen">
|
||||||
|
<div
|
||||||
|
v-for="row in group.rows"
|
||||||
|
:key="row.key"
|
||||||
|
class="row"
|
||||||
|
:class="{ active: row.key === activeKey }"
|
||||||
|
:title="row.key"
|
||||||
|
>
|
||||||
|
<button class="entry" @click="$emit('select', row.key)">
|
||||||
|
<StatusDot :tone="stateTone(row.session.state)" />
|
||||||
|
<span class="name">{{ row.name }}</span>
|
||||||
|
<span v-if="row.session.inbox_depth > 0" class="depth" title="inbox depth">
|
||||||
|
{{ row.session.inbox_depth }}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="ghost remove"
|
||||||
|
aria-label="delete session"
|
||||||
|
:title="`delete ${row.key}`"
|
||||||
|
@click.stop="$emit('delete', row.key)"
|
||||||
|
>
|
||||||
|
×
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
</template>
|
</template>
|
||||||
@@ -287,10 +326,32 @@ watch(
|
|||||||
margin-bottom: 14px;
|
margin-bottom: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.group .label {
|
.group-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
padding: 0 8px 4px;
|
padding: 0 8px 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.group-head .working {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
text-align: right;
|
||||||
|
font-family: var(--mono);
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--text3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-head .working.live {
|
||||||
|
color: var(--ok);
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-head .toggle {
|
||||||
|
flex: none;
|
||||||
|
padding: 0 6px;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
/* The row owns the hover and active surface: the select button fills it
|
/* The row owns the hover and active surface: the select button fills it
|
||||||
and the delete button sits beside it, so neither has to nest in the
|
and the delete button sits beside it, so neither has to nest in the
|
||||||
other. */
|
other. */
|
||||||
|
|||||||
@@ -18,20 +18,36 @@ const kind = ref<SandboxKind>('local')
|
|||||||
const url = ref('')
|
const url = ref('')
|
||||||
const token = ref('')
|
const token = ref('')
|
||||||
const clearToken = ref(false)
|
const clearToken = ref(false)
|
||||||
|
const host = ref('')
|
||||||
|
const workspace = ref('')
|
||||||
|
|
||||||
const dirty = computed(() => {
|
const dirty = computed(() => {
|
||||||
const state = props.state
|
const state = props.state
|
||||||
if (!state) return false
|
if (!state) return false
|
||||||
if (kind.value !== state.kind) return true
|
if (kind.value !== state.kind) return true
|
||||||
if (kind.value !== 'http') return false
|
if (kind.value === 'http') {
|
||||||
const normalized = url.value.trim().replace(/\/+$/, '')
|
const normalized = url.value.trim().replace(/\/+$/, '')
|
||||||
if (normalized !== (state.url ?? '')) return true
|
if (normalized !== (state.url ?? '')) return true
|
||||||
return token.value.trim() !== '' || clearToken.value
|
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 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(() =>
|
const urlHint = computed(() =>
|
||||||
url.value.trim() && !urlValid.value
|
url.value.trim() && !urlValid.value
|
||||||
@@ -39,6 +55,12 @@ const urlHint = computed(() =>
|
|||||||
: 'The sandboxd base URL, for example https://box.example:7600.',
|
: '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 {
|
function sync(): void {
|
||||||
const state = props.state
|
const state = props.state
|
||||||
if (!state) return
|
if (!state) return
|
||||||
@@ -46,6 +68,8 @@ function sync(): void {
|
|||||||
url.value = state.url ?? ''
|
url.value = state.url ?? ''
|
||||||
token.value = ''
|
token.value = ''
|
||||||
clearToken.value = false
|
clearToken.value = false
|
||||||
|
host.value = state.host ?? ''
|
||||||
|
workspace.value = state.ssh_workspace ?? ''
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
@@ -71,6 +95,10 @@ function save(): void {
|
|||||||
choice.clear_token = true
|
choice.clear_token = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (kind.value === 'ssh') {
|
||||||
|
choice.host = host.value.trim()
|
||||||
|
choice.workspace = workspace.value.trim()
|
||||||
|
}
|
||||||
emit('save', choice)
|
emit('save', choice)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +106,9 @@ function save(): void {
|
|||||||
const workspacePath = computed(() => {
|
const workspacePath = computed(() => {
|
||||||
const state = props.state
|
const state = props.state
|
||||||
if (!state) return ''
|
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>
|
</script>
|
||||||
|
|
||||||
@@ -123,6 +153,47 @@ const workspacePath = computed(() => {
|
|||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</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>
|
||||||
|
|
||||||
<SettingCard v-if="kind === 'http'" title="Remote sandbox">
|
<SettingCard v-if="kind === 'http'" title="Remote sandbox">
|
||||||
@@ -167,7 +238,7 @@ const workspacePath = computed(() => {
|
|||||||
</SettingRow>
|
</SettingRow>
|
||||||
</SettingCard>
|
</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.
|
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.
|
Later edits stay in the sandbox; the claw does not copy them back.
|
||||||
</AppCallout>
|
</AppCallout>
|
||||||
|
|||||||
@@ -231,9 +231,9 @@ export interface ActiveBackend {
|
|||||||
active: { provider: string; model: string }
|
active: { provider: string; model: string }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Where the agent's `bash` runs: this host or a daemon speaking the
|
/** Where the agent's `bash` runs: this host, a daemon speaking the
|
||||||
* sandbox protocol over HTTP. */
|
* sandbox protocol over HTTP, or an ssh login on a far box. */
|
||||||
export type SandboxKind = 'local' | 'http'
|
export type SandboxKind = 'local' | 'http' | 'ssh'
|
||||||
|
|
||||||
/** The sandbox state `GET /v1/sandbox` serves. The token never rides
|
/** The sandbox state `GET /v1/sandbox` serves. The token never rides
|
||||||
* the wire; `token_set` says whether one is stored. */
|
* the wire; `token_set` says whether one is stored. */
|
||||||
@@ -241,6 +241,12 @@ export interface SandboxState {
|
|||||||
kind: SandboxKind
|
kind: SandboxKind
|
||||||
url: string | null
|
url: string | null
|
||||||
token_set: boolean
|
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. */
|
/** Where `bash` starts under the current choice. */
|
||||||
workspace: string
|
workspace: string
|
||||||
/** The daemon's chat workspace, whatever the choice. */
|
/** The daemon's chat workspace, whatever the choice. */
|
||||||
@@ -257,6 +263,10 @@ export interface SandboxSelection {
|
|||||||
url?: string
|
url?: string
|
||||||
token?: string
|
token?: string
|
||||||
clear_token?: boolean
|
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. */
|
/** A failed API call: the status plus the claw's `error` string when it sent one. */
|
||||||
|
|||||||
Reference in new issue
Block a user