feat: add Kilo and Pi agent watchers#43
Conversation
There was a problem hiding this comment.
inspect review
Triage: 85 entities analyzed | 0 critical, 0 high, 12 medium, 73 low
Verdict: standard_review
Findings (2)
- [low] determineStatus() references msg.data even though MessageData has no
datafield. In packages/runtime/src/agents/watchers/kilo.ts, determineStatus containsif (typeof msg?.data === "string") { const parsed = JSON.parse(msg.data); msg = parsed; }, but MessageData is defined withoutdata. This is a real type/logic mismatch (likely confusion between MessageRow vs parsed MessageData) and the branch is effectively dead under correct typing. - [low] poll() contains a copy-paste fallback that repeats the exact same SQL query, so it cannot recover from any schema/query failure. In packages/runtime/src/agents/watchers/kilo.ts, the catch block labeled 'Try alternative query for Kilo schema' executes the identical
SELECT id, title, directory, time_updated FROM session WHERE time_updated > ? ORDER BY time_updated DESCagain, making the fallback useless and misleading.
Reviewed by inspect | Entity-level triage found 0 high-risk changes
- Remove unreachable `msg.data` string-parsing branch in determineStatus(). The caller (readSessionStatus) already parses the JSON before calling this function, so the branch could never fire and conflicted with the MessageData type contract. - Remove duplicate fallback query in poll() that ran the identical SQL on failure — it could never succeed where the first attempt failed. On query error, just close the DB handle and return so the next poll cycle reopens it.
|
Hey, nice work on this, the schema docs and test coverage are solid. Two small things to clean up before we merge: 1. Dead branch in The 2. Duplicate fallback query in The inner catch runs the same SQL as the outer try, if it failed once it'll fail the same way again. Looks like a copy-paste leftover from when there was going to be an alternative query. Can collapse to a single try/catch that closes the DB handle on failure. Both are just dead code, not bugs. The watcher logic itself is correct. |
Regenerate the three snapshot files to include the new `l lazydiff L new window` footer line added to the renderer.
Summary
KiloAgentWatcher.KILO_DB_PATH.Details
The Kilo watcher polls the Kilo CLI SQLite database at
~/.local/share/kilo/kilo.db, orKILO_DB_PATHwhen set, usingbun:sqlitein read-only mode.It maps Kilo sessions back to opensessions mux sessions through each row's
working_directory, then derives status from the headmessage_nodesentry referenced bymain_chain_id.Supported status handling includes:
runningfor user/tool messages, streaming assistant messages, and assistant tool callsdonefor assistant messages withfinish_reason=stoperrorforfinish_reason=errorinterruptedfor Kilo interrupt marker messagesstalewhen a running session stops advancing for 15 secondsThe watcher also skips hidden sessions, ignores old inactive sessions, emits title updates, and reopens the database after read failures.
Testing
cd packages/runtime && bun test test/kilo.test.tsResult: 30 tests passing.