feat(browser): add timeout, idle auto-close, and max-pages safety mechanisms

Prevent resource leaks and hanging actions in the browser tool:
- Per-action context timeout (default 30s, configurable via timeoutMs param or config)
- Idle page reaper goroutine closes pages unused for 10min (configurable)
- Max pages per tenant (default 5) with LRU eviction
- RefStore cleanup on page close/evict/reap to prevent memory leaks
This commit is contained in:
viettranx committed 2026-03-25 13:55:33 +07:00
1 parent afbecd3e4c
commit ee4d34ae28
8 files changed
+226 -12

No files matched your search

+8
View File
@@ -81,6 +81,14 @@ func NormalizeRef(raw string) string {
return s
}
// Remove deletes all refs for a target.
func (rs *RefStore) Remove(targetID string) {
rs.mu.Lock()
defer rs.mu.Unlock()
rs.removeFromOrder(targetID)
delete(rs.entries, targetID)
}
func (rs *RefStore) removeFromOrder(targetID string) {
for i, id := range rs.order {
if id == targetID {