audit-log.mjs
31 lines 886 B
Raw
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd feat(calendar): enforce agent context tiers in retrieval AP… Human minor ⚠ breaking 1 day ago
1 /**
2 * Hub audit log. Appends events to data_dir/hub_audit.log.
3 */
4
5 import fs from 'fs';
6 import path from 'path';
7
8 /**
9 * Append an audit entry. Creates data_dir if needed.
10 * @param {string} dataDir - Path to data directory
11 * @param {{
12 * userId: string,
13 * action: string,
14 * proposalId: string,
15 * detail?: Record<string, unknown>,
16 * }} entry
17 */
18 export function appendAudit(dataDir, entry) {
19 const logPath = path.join(dataDir, 'hub_audit.log');
20 const dir = path.dirname(logPath);
21 if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
22 const line =
23 JSON.stringify({
24 ts: new Date().toISOString(),
25 user_id: entry.userId,
26 action: entry.action,
27 proposal_id: entry.proposalId,
28 ...(entry.detail && typeof entry.detail === 'object' ? { detail: entry.detail } : {}),
29 }) + '\n';
30 fs.appendFileSync(logPath, line, 'utf8');
31 }
File History 2 commits
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd feat(calendar): enforce agent context tiers in retrieval AP… Human minor 1 day ago
sha256:9103f98c89257ed2b01c237cea895dabb3e85ea337dccb1161c175e4422355b6 docs: accept Calendar Events v0 spec with Phase 0 security … Human 1 day ago