# Interface IAuditStorage

Audit exports - Structured audit logging (Issue #193) Split from index.ts for file size compliance (Issue #285)

interface IAuditStorage {
write(
event: {
id: string;
version: "1.0";
timestamp: string;
timestampMs: number;
category:
| "authorization"
| "system"
| "configuration"
| "security"
| "authentication"
| "tool_invocation"
| "data_access"
| "data_modification";
severity: "info"
| "warning"
| "critical";
outcome: "error" | "success" | "failure" | "denied";
action: string;
description?: string;
actor: {
type: "system" | "user" | "external" | "agent";
id: string;
name?: string;
ip?: string;
userAgent?: string;
};
resource?: { type: string; id: string; name?: string; path?: string };
requestId?: string;
traceId?: string;
sessionId?: string;
toolName?: string;
durationMs?: number;
metadata?: Record<string, unknown>;
policyName?: string;
policyDecision?: string;
violationType?: string;
previousHash?: string;
hash?: string;
},
): Promise<void>;
flush(): Promise<void>;
close(): Promise<void>;
query(
criteria: {
startTime?: Date;
endTime?: Date;
categories?: (
| "authorization"
| "system"
| "configuration"
| "security"
| "authentication"
| "tool_invocation"
| "data_access"
| "data_modification"
)[];
severities?: ("info" | "warning" | "critical")[];
outcomes?: ("error" | "success" | "failure" | "denied")[];
actorId?: string;
resourceId?: string;
requestId?: string;
traceId?: string;
limit: number;
offset: number;
},
): Promise<
{
id: string;
version: "1.0";
timestamp: string;
timestampMs: number;
category: | "authorization"
| "system"
| "configuration"
| "security"
| "authentication"
| "tool_invocation"
| "data_access"
| "data_modification";
severity: "info"
| "warning"
| "critical";
outcome: "error" | "success" | "failure" | "denied";
action: string;
description?: string;
actor: {
type: "system" | "user" | "external" | "agent";
id: string;
name?: string;
ip?: string;
userAgent?: string;
};
resource?: { type: string; id: string; name?: string; path?: string };
requestId?: string;
traceId?: string;
sessionId?: string;
toolName?: string;
durationMs?: number;
metadata?: Record<string, unknown>;
policyName?: string;
policyDecision?: string;
violationType?: string;
previousHash?: string;
hash?: string;
}[],
>;
}

#### Implemented by

- FileAuditStorage
- InMemoryAuditStorage

- Defined in packages/nexus-agents/src/audit/audit-types.ts:196

##### Index

### Methods

write
flush
close
query

## Methods

### write

- write(
  event: {
  id: string;
  version: "1.0";
  timestamp: string;
  timestampMs: number;
  category:
  | "authorization"
  | "system"
  | "configuration"
  | "security"
  | "authentication"
  | "tool_invocation"
  | "data_access"
  | "data_modification";
  severity: "info"
  | "warning"
  | "critical";
  outcome: "error" | "success" | "failure" | "denied";
  action: string;
  description?: string;
  actor: {
  type: "system" | "user" | "external" | "agent";
  id: string;
  name?: string;
  ip?: string;
  userAgent?: string;
  };
  resource?: { type: string; id: string; name?: string; path?: string };
  requestId?: string;
  traceId?: string;
  sessionId?: string;
  toolName?: string;
  durationMs?: number;
  metadata?: Record<string, unknown>;
  policyName?: string;
  policyDecision?: string;
  violationType?: string;
  previousHash?: string;
  hash?: string;
  },
  ): Promise<void>

  Write an audit event to storage

  #### Parameters

  - event: {
    id: string;
    version: "1.0";
    timestamp: string;
    timestampMs: number;
    category:
    | "authorization"
    | "system"
    | "configuration"
    | "security"
    | "authentication"
    | "tool_invocation"
    | "data_access"
    | "data_modification";
    severity: "info"
    | "warning"
    | "critical";
    outcome: "error" | "success" | "failure" | "denied";
    action: string;
    description?: string;
    actor: {
    type: "system" | "user" | "external" | "agent";
    id: string;
    name?: string;
    ip?: string;
    userAgent?: string;
    };
    resource?: { type: string; id: string; name?: string; path?: string };
    requestId?: string;
    traceId?: string;
    sessionId?: string;
    toolName?: string;
    durationMs?: number;
    metadata?: Record<string, unknown>;
    policyName?: string;
    policyDecision?: string;
    violationType?: string;
    previousHash?: string;
    hash?: string;
    }

  #### Returns Promise<void>

  - Defined in packages/nexus-agents/src/audit/audit-types.ts:198

### flush

- flush(): Promise<void>

  Flush pending writes

  #### Returns Promise<void>

  - Defined in packages/nexus-agents/src/audit/audit-types.ts:201

### close

- close(): Promise<void>

  Close the storage

  #### Returns Promise<void>

  - Defined in packages/nexus-agents/src/audit/audit-types.ts:204

### query

- query(
  criteria: {
  startTime?: Date;
  endTime?: Date;
  categories?: (
  | "authorization"
  | "system"
  | "configuration"
  | "security"
  | "authentication"
  | "tool_invocation"
  | "data_access"
  | "data_modification"
  )[];
  severities?: ("info" | "warning" | "critical")[];
  outcomes?: ("error" | "success" | "failure" | "denied")[];
  actorId?: string;
  resourceId?: string;
  requestId?: string;
  traceId?: string;
  limit: number;
  offset: number;
  },
  ): Promise<
  {
  id: string;
  version: "1.0";
  timestamp: string;
  timestampMs: number;
  category: | "authorization"
  | "system"
  | "configuration"
  | "security"
  | "authentication"
  | "tool_invocation"
  | "data_access"
  | "data_modification";
  severity: "info"
  | "warning"
  | "critical";
  outcome: "error" | "success" | "failure" | "denied";
  action: string;
  description?: string;
  actor: {
  type: "system" | "user" | "external" | "agent";
  id: string;
  name?: string;
  ip?: string;
  userAgent?: string;
  };
  resource?: { type: string; id: string; name?: string; path?: string };
  requestId?: string;
  traceId?: string;
  sessionId?: string;
  toolName?: string;
  durationMs?: number;
  metadata?: Record<string, unknown>;
  policyName?: string;
  policyDecision?: string;
  violationType?: string;
  previousHash?: string;
  hash?: string;
  }[],
  >

  Query events by criteria

  #### Parameters

  - criteria: {
    startTime?: Date;
    endTime?: Date;
    categories?: (
    | "authorization"
    | "system"
    | "configuration"
    | "security"
    | "authentication"
    | "tool_invocation"
    | "data_access"
    | "data_modification"
    )[];
    severities?: ("info" | "warning" | "critical")[];
    outcomes?: ("error" | "success" | "failure" | "denied")[];
    actorId?: string;
    resourceId?: string;
    requestId?: string;
    traceId?: string;
    limit: number;
    offset: number;
    }

  #### Returns Promise<
  {
  id: string;
  version: "1.0";
  timestamp: string;
  timestampMs: number;
  category: | "authorization"
  | "system"
  | "configuration"
  | "security"
  | "authentication"
  | "tool_invocation"
  | "data_access"
  | "data_modification";
  severity: "info"
  | "warning"
  | "critical";
  outcome: "error" | "success" | "failure" | "denied";
  action: string;
  description?: string;
  actor: {
  type: "system" | "user" | "external" | "agent";
  id: string;
  name?: string;
  ip?: string;
  userAgent?: string;
  };
  resource?: { type: string; id: string; name?: string; path?: string };
  requestId?: string;
  traceId?: string;
  sessionId?: string;
  toolName?: string;
  durationMs?: number;
  metadata?: Record<string, unknown>;
  policyName?: string;
  policyDecision?: string;
  violationType?: string;
  previousHash?: string;
  hash?: string;
  }[],
  >

  - Defined in packages/nexus-agents/src/audit/audit-types.ts:207