feat(claw): carry the ssh private key in the sandbox choice

The ssh sandbox took its credential from a key file the local
disk had to hold, so a daemon whose secrets live in a store could
not reach a far box without staging a file first. The choice
gains private_key, the key text itself, threaded to the ssh
backend's with_private_key; unset, the built-in hunt tries the
agent and the default key files as before.

The route keeps the token's write-only contract: GET /v1/sandbox
answers private_key_set and never the key, PUT takes private_key
and clear_private_key, an absent field keeps the stored one, a
present-but-blank one clears it, and config.yaml's sandbox
section accepts the field for boot seeding. The settings page
grows the key textarea with its forget row, the token UI's
shape.

The three sandbox deps move to 0.4.2 for the seam, so the crate
builds once the rhema 0.4.2 release lands on crates.io; until
then the Rust gates cannot run and were checked by hand (cargo
fmt parses the tree, vue-tsc passes).
This commit is contained in:
vhaudiquet committed 2026-11-22 20:02:06 +01:00
1 parent 49c2fa42df
commit cbd52b3b3f
7 files changed
+221 -38

No files matched your search

@@ -20,6 +20,8 @@ const token = ref('')
const clearToken = ref(false)
const host = ref('')
const workspace = ref('')
const privateKey = ref('')
const clearPrivateKey = ref(false)
const dirty = computed(() => {
const state = props.state
@@ -33,6 +35,7 @@ const dirty = computed(() => {
if (kind.value === 'ssh') {
if (host.value.trim() !== (state.host ?? '')) return true
if (workspace.value.trim() !== (state.ssh_workspace ?? '')) return true
return privateKey.value.trim() !== '' || clearPrivateKey.value
}
return false
})
@@ -70,6 +73,8 @@ function sync(): void {
clearToken.value = false
host.value = state.host ?? ''
workspace.value = state.ssh_workspace ?? ''
privateKey.value = ''
clearPrivateKey.value = false
}
watch(
@@ -98,6 +103,11 @@ function save(): void {
if (kind.value === 'ssh') {
choice.host = host.value.trim()
choice.workspace = workspace.value.trim()
if (privateKey.value.trim() !== '') {
choice.private_key = privateKey.value
} else if (clearPrivateKey.value) {
choice.clear_private_key = true
}
}
emit('save', choice)
}
@@ -194,6 +204,33 @@ const workspacePath = computed(() => {
:disabled="saving"
/>
</SettingRow>
<SettingRow
title="Private key"
:description="state.private_key_set
? 'A key is stored. Leave this blank to keep it, or paste a replacement.'
: 'The key text itself (OpenSSH or PEM), not a path: the claw stores it, it stages no file. Leave blank to authenticate through an agent or the default key files.'"
>
<textarea
v-model="privateKey"
class="mono key-input"
rows="3"
:placeholder="state.private_key_set ? 'stored' : '-----BEGIN OPENSSH PRIVATE KEY-----'"
autocomplete="off"
spellcheck="false"
:disabled="saving || clearPrivateKey"
/>
</SettingRow>
<SettingRow
v-if="state.private_key_set"
title="Stored key"
:description="clearPrivateKey
? 'The stored key is removed when you save.'
: 'The key stays in the settings table until you replace or forget it.'"
>
<button class="ghost" :disabled="saving" @click="clearPrivateKey = !clearPrivateKey">
{{ clearPrivateKey ? 'Keep key' : 'Forget key' }}
</button>
</SettingRow>
</SettingCard>
<SettingCard v-if="kind === 'http'" title="Remote sandbox">
@@ -327,4 +364,12 @@ const workspacePath = computed(() => {
font-size: 12px;
font-weight: 500;
}
.key-input {
width: 100%;
min-width: 0;
resize: vertical;
font-size: 12px;
word-break: break-all;
}
</style>