feat(audit): Add core audit logging infrastructure
- Add AuditLogger class with rotation support - Add audit configuration to config schema - Instrument tool execution with full audit logging - Instrument session lifecycle (create, message, delete, transfer, compact) - Add audit logger initialization in daemon - Add cron scheduler audit logging Audit events captured: - tool.start/success/error/denied - session.create/message/delete/transfer/compact - cron.trigger/add/remove All logs go to ~/.local/share/flynn/audit.log (JSON lines) with rotation (10MB files, 30-day retention)
This commit is contained in:
@@ -12,6 +12,7 @@ import type { OutboundAttachmentCollector } from './attachments.js';
|
||||
import { shouldCompact } from '../../context/tokens.js';
|
||||
import { compactHistory, type CompactionConfig, type CompactionResult, DEFAULT_COMPACTION_CONFIG } from '../../context/compaction.js';
|
||||
import { estimateCost } from '../../models/costs.js';
|
||||
import { auditLogger } from '../../audit/index.js';
|
||||
|
||||
// ── Public types ──────────────────────────────────────────────────────
|
||||
|
||||
@@ -255,6 +256,16 @@ export class AgentOrchestrator {
|
||||
`${result.tokensBefore} → ${result.tokensAfter} tokens`,
|
||||
);
|
||||
|
||||
if (this._session) {
|
||||
auditLogger?.sessionCompact({
|
||||
session_id: this._session.id,
|
||||
messages_before: result.tokensBefore,
|
||||
messages_after: result.tokensAfter,
|
||||
tokens_before: result.tokensBefore,
|
||||
tokens_after: result.tokensAfter,
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user