ps_audit_get
Retrieve audit log entries to monitor and review AI agent actions, supporting filtering by time, action type, and result limits for governance oversight.
Instructions
Get audit log entries.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| since | No | ||
| action | No | ||
| limit | No |
Implementation Reference
- src/operator/index.ts:346-359 (handler)Main handler function that retrieves and filters audit log entries. Accepts optional 'since' timestamp, 'action' filter, and 'limit' parameters. Returns filtered AuditLogEntry array.
export function ps_audit_get(request: AuditGetRequest = {}): AuditLogEntry[] { let results = auditLog; if (request.since) { results = results.filter(e => e.timestamp >= request.since!); } if (request.action) { results = results.filter(e => e.action === request.action); } const limit = request.limit ?? 100; return results.slice(-limit); } - src/operator/index.ts:317-344 (schema)Type definitions for AuditLogEntry (timestamp, action, actor, details) and AuditGetRequest (since, action, limit) interfaces that define the input/output structure.
export interface AuditLogEntry { timestamp: number; action: string; actor: string; details: Record<string, unknown>; } const auditLog: AuditLogEntry[] = []; export function recordAudit(action: string, actor: string, details: Record<string, unknown>): void { auditLog.push({ timestamp: Date.now(), action, actor, details }); // Keep last 1000 entries if (auditLog.length > 1000) { auditLog.shift(); } } export interface AuditGetRequest { since?: number; action?: string; limit?: number; } - src/handlers/tool-registry.ts:288-292 (registration)Tool registration in the registry mapping the tool name 'ps_audit_get' to its handler function with category 'audit' and description.
ps_audit_get: { handler: (args) => ps_audit_get(args as any), category: 'audit', description: 'Get audit log entries', }, - src/tools/registry.ts:446-459 (schema)Tool metadata definition including name, description, and JSON Schema inputSchema specifying the parameters (since, action, limit) and their types.
export const AUDIT_TOOLS: Tool[] = [ { name: 'ps_audit_get', description: 'Get audit log entries.', inputSchema: { type: 'object' as const, properties: { since: { type: 'number' }, action: { type: 'string' }, limit: { type: 'number' } } } } ]; - src/operator/index.ts:324-338 (helper)Helper code defining the auditLog array (in-memory storage) and recordAudit function that populates the log. The audit log stores up to 1000 entries.
const auditLog: AuditLogEntry[] = []; export function recordAudit(action: string, actor: string, details: Record<string, unknown>): void { auditLog.push({ timestamp: Date.now(), action, actor, details }); // Keep last 1000 entries if (auditLog.length > 1000) { auditLog.shift(); } }