You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Core: Implement Activity-Based Polling via Local Log Monitoring #70
Instead of polling usage limits on a strict interval (which can consume unnecessary resources and CPU), we can monitor the local log directories of the AI CLIs (like ~/.config/claude/projects/, ~/.codex/sessions/, or Gemini logs). When new entries are written to these logs, it indicates the user is actively consuming tokens, and we should trigger a usage refresh. We want the user to be able to configure this effectively via a 3-modality mode selection.
Requirements
Introduce an autoRefreshMode configuration that accepts 'none', 'interval', or 'activity' (defaulting to 'activity').
Create an ActivityMonitor utility that watches known log directories for Claude, Codex, and Gemini using fs.watch.
Make the activity debounce interval configurable.
In 'activity' mode, the polling operates like an on-demand interval: it wakes up and starts its refresh cycle when activity is detected in the logs (delaying the first pull by the configured debounce), and goes back to an idle/disabled state when no further log activity is detected since the last check.
Update CLI args in bin/agent-tank.js with --auto-refresh-mode and --activity-debounce and document the feature in README.md.
Acceptance Criteria
autoRefreshMode logic safely handles the three options (none, interval, activity), defaulting to activity.
ActivityMonitor successfully detects changes in target directories for Claude, Codex, and Gemini, triggering refreshes based on the provided debounce interval.
During active usage, polling functions as an interval loop; during idle periods, polling is disabled to save resources.
CLI and README are updated with these configurations.
We will use Node's native fs.watch to monitor the typical log paths for Claude, Codex, and Gemini. By tracking the activity state, we can simulate an on-demand interval loop: when log changes are detected, we fire the refresh callback (debounced to avoid hammering during token streaming) and keep the cycle alive. If no activity happens within the window, the cycle sleeps. Documentation is updated iteratively as required.
File: src/activity-monitor.js
Why this file: Encapsulates file system watching logic away from the main agent lifecycle, ensuring clean architecture.
constfs=require('fs');constpath=require('path');constos=require('os');classActivityMonitor{constructor(refreshCallback,debounceMs=60000){this.refreshCallback=refreshCallback;this.debounceMs=debounceMs;this.timeout=null;this.watchers=[];// Standard paths for Codex, Claude, and Gemini logsthis.targetDirs=[path.join(os.homedir(),'.codex','sessions'),path.join(os.homedir(),'.config','claude','projects'),path.join(os.homedir(),'.claude','projects'),path.join(os.homedir(),'.config','gemini'),path.join(os.homedir(),'.gemini')];}start(){console.log('[ActivityMonitor] Starting to watch log directories for activity...');this.targetDirs.forEach(dir=>{if(fs.existsSync(dir)){try{constwatcher=fs.watch(dir,{recursive: true},(eventType,filename)=>{// Triggers on any file change in the directoryif(filename&&!filename.startsWith('.')){this._onActivityDetected(dir,filename);}});this.watchers.push(watcher);console.log(`[ActivityMonitor] Watching directory: ${dir}`);}catch(err){console.error(`[ActivityMonitor] Failed to watch ${dir}:`,err.message);}}});}stop(){this.watchers.forEach(w=>w.close());this.watchers=[];if(this.timeout){clearTimeout(this.timeout);this.timeout=null;}}_onActivityDetected(dir,filename){// Debounce the refresh so we don't trigger it continuously during streaming.// Once triggered, if no more logs are written, the cycle automatically goes idle.if(this.timeout){clearTimeout(this.timeout);}this.timeout=setTimeout(()=>{console.log(`[ActivityMonitor] Activity settled (detected in ${filename}). Triggering refresh.`);this.refreshCallback();},this.debounceMs);}}module.exports={ ActivityMonitor };
File: src/index.js
Why this file: We need to hook the ActivityMonitor into the main application lifecycle and respect the new autoRefreshMode (none, interval, or activity), providing it the refreshAll function as a callback.
Activity
propr-dev commentedon Mar 16, 2026
Suggested Implementation:
Implementation Approach
We will use Node's native
fs.watchto monitor the typical log paths for Claude, Codex, and Gemini. By tracking the activity state, we can simulate an on-demand interval loop: when log changes are detected, we fire the refresh callback (debounced to avoid hammering during token streaming) and keep the cycle alive. If no activity happens within the window, the cycle sleeps. Documentation is updated iteratively as required.File:
src/activity-monitor.jsWhy this file: Encapsulates file system watching logic away from the main agent lifecycle, ensuring clean architecture.
File:
src/index.jsWhy this file: We need to hook the
ActivityMonitorinto the main application lifecycle and respect the newautoRefreshMode(none,interval, oractivity), providing it therefreshAllfunction as a callback.File:
bin/agent-tank.jsWhy this file: Expose the CLI configuration.
File:
README.mdWhy this file: Keep the documentation up to date.
propr-dev commentedon Mar 17, 2026
🤖 AI processing has started for this issue using claude agent with claude-opus-4-5-20251101 model.
I'll analyze the problem and work on a solution. This may take a few minutes.
Processing Details:
claudeclaude-opus-4-5-2025110170/claude-opus-4-5-20251101-core-implement-activity-b-20260317-0003-om765-epic-implement-json-ctnissue-70-20260317-0003-claude-opus-4-5-20251101-om7🔍 Track Task Execution
The ActivityMonitor module works correctly. Let me provide a summary …
The ActivityMonitor module works correctly. Let me provide a summary …