feat: AI task API, token-based context windows, SSH password auth, sudo bypass detection

Replace message-count context windows with token-budget based ones for both
studio and shell. Add /api/ai/task endpoint for background tool
check/install/update. Enhance sudo blocking to catch piped/chained elevation
commands. Add SSH password support via sshpass and connection editing UI.
Remove realTokens persistence in favor of consumption tracking. Bump to 0.4.1.

💘 Generated with Crush

Assisted-by: GLM-5.1 via Crush <crush@charm.land>
This commit is contained in:
Augustin
2026-04-26 20:06:20 +02:00
parent c9f2932147
commit d98110ce8a
16 changed files with 446 additions and 105 deletions

View File

@@ -79,10 +79,9 @@ type ShellMessage struct {
}
type ShellConvStore struct {
mu sync.RWMutex
path string
msgs []ShellMessage
realTokens int
mu sync.RWMutex
path string
msgs []ShellMessage
}
func NewShellConvStore() *ShellConvStore {
@@ -140,14 +139,10 @@ func (s *ShellConvStore) Clear() {
s.mu.Lock()
defer s.mu.Unlock()
s.msgs = []ShellMessage{}
s.realTokens = 0
s.save()
}
func (s *ShellConvStore) ApproxTokens() int {
if s.realTokens > 0 {
return s.realTokens
}
s.mu.RLock()
defer s.mu.RUnlock()
total := 0
@@ -161,16 +156,6 @@ func (s *ShellConvStore) ApproxTokens() int {
return total
}
// AddRealTokens accumulates actual token counts from the API response.
func (s *ShellConvStore) AddRealTokens(tokens int) {
if tokens <= 0 {
return
}
s.mu.Lock()
s.realTokens += tokens
s.mu.Unlock()
}
func (s *ShellConvStore) AtLimit() bool {
return s.ApproxTokens() >= shellMaxTokens
}