> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentium.in/llms.txt
> Use this file to discover all available pages before exploring further.

# PII guards

> Public pii guards signatures and configuration in @agentium/core 4.0.0.

Import these **4 exports** from `@agentium/core`. Read the [pii guards guide](/features/pii-guard) for setup and behavior, or return to the [package reference](/api-reference/core).

A `?` marks an optional field. These are declarations for lookup; run the examples in the linked guide. Follow related-type links for Agentium types and source links for imported dependency types.

## PiiGuard

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/guards/pii-guard.ts)

```typescript theme={null}
export declare class PiiGuard {
    constructor(config: PiiGuardConfig);
    scrub(text: string): string;
    rehydrate(text: string): string;
    scrubMessages(messages: ChatMessage[]): ChatMessage[];
    getMapping(): ReadonlyMap<string, string>;
    reset(): void;
    /**
     * Create an InputGuardrail that scrubs PII from user input.
     * When action is "redact", the guardrail blocks and returns the scrubbed version in the reason.
     * When action is "placeholder" or "hash", the guardrail passes but modifies the input.
     */
    toInputGuardrail(): InputGuardrail;
    /**
     * Create a beforeLLMCall hook that scrubs PII from all messages on every roundtrip.
     */
    toBeforeLLMCallHook(): (messages: ChatMessage[], roundtrip: number) => Promise<ChatMessage[] | void>;
    /**
     * Create an afterToolExec hook that scrubs PII from tool results.
     */
    toAfterToolExecHook(): (toolName: string, result: string) => Promise<string | void>;
}
```

Related: [`ChatMessage`](/api-reference/core/models#chatmessage), [`InputGuardrail`](/api-reference/core/agent#inputguardrail), [`PiiGuardConfig`](/api-reference/core/guards#piiguardconfig).

## PiiGuardConfig

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/guards/pii-guard.ts)

```typescript theme={null}
export interface PiiGuardConfig {
    patterns?: PiiPattern[];
    builtIn?: PiiType[];
    action: "redact" | "hash" | "placeholder";
    rehydrate?: boolean;
    customDetector?: (text: string) => Array<{
        start: number;
        end: number;
        type: string;
    }>;
}
```

Related: [`PiiPattern`](/api-reference/core/guards#piipattern), [`PiiType`](/api-reference/core/guards#piitype).

## PiiPattern

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/guards/pii-guard.ts)

```typescript theme={null}
export interface PiiPattern {
    name: string;
    regex: RegExp;
}
```

## PiiType

[Source](https://github.com/agentiumOS/agentium/blob/v4.0.0/packages/core/src/guards/pii-guard.ts)

```typescript theme={null}
export type PiiType = "email" | "phone" | "ssn" | "creditCard" | "ipAddress" | "name";
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.