Skip to content

Commit 5f2726e

Browse files
fadeevgithub-actions[bot]
authored andcommitted
docs: sync documentation
1 parent 8317836 commit 5f2726e

1,503 files changed

Lines changed: 28419 additions & 4568 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# PII Redaction
2+
3+
## Introduction
4+
5+
PII redaction is a **best-effort, client-side** layer that scans outbound
6+
message text for personally identifiable information and replaces matches with
7+
tagged placeholders (`[EMAIL_1]`, `[PHONE_2]`, …) before the request leaves the
8+
device. The model only ever sees the placeholders; the SDK restores the
9+
original values in the response — in both the live stream and the final result —
10+
so the user always sees real data.
11+
12+
> **This is obfuscation, not a compliance guarantee.** Detection is regex-based.
13+
> It can miss real PII and over-match ordinary text, it does not detect names,
14+
> and it does not cover non-text content (images, file uploads, attachments) or
15+
> model-generated tool-call arguments. Treat it as defense-in-depth, not as a
16+
> control you can rely on for regulatory purposes.
17+
18+
## What is covered
19+
20+
- **All message-role text** sent to the provider — user, system, assistant
21+
history, and tool results on continuation rounds.
22+
- **Injected pre-processor context** (memory/search/file snippets).
23+
- **Embedding inputs** in `useChatStorage` (message vectors, tool-filter
24+
prompts) — only the text sent to the embeddings endpoint is redacted; the
25+
text stored locally stays original.
26+
- **The summarization prompt** — redacted before the summary model call, and the
27+
returned summary is de-anonymized before it is stored/injected.
28+
29+
## What is **not** covered
30+
31+
- Names and other free-form identifiers (no regex for them).
32+
- Non-text content: images, base64/file uploads, file URLs, filenames. A
33+
one-time `console.warn` is emitted when such content is present.
34+
- Model-generated tool-call arguments (the model only ever saw placeholders, so
35+
these contain placeholders rather than raw PII — but they are not restored
36+
before local tool execution).
37+
- `expo/useChatStorage` does not yet support `piiRedaction`.
38+
39+
## Built-in categories
40+
41+
`EMAIL`, `PHONE` (US formats + E.164), `SSN` (dashed, plus dashless/spaced when an
42+
"SSN"/"social security" cue is nearby), `CREDIT_CARD` (Luhn-validated),
43+
`IP_ADDRESS` (IPv4 + IPv6), `API_KEY` (entropy-validated), `US_ADDRESS`, and
44+
`DATE_OF_BIRTH` (only with a "DOB"/"born"/"birthday" cue and a valid calendar
45+
date).
46+
47+
## Usage
48+
49+
### Hooks
50+
51+
```ts
52+
const { sendMessage } = useChat({
53+
getToken,
54+
piiRedaction: true, // one redactor shared across turns for this hook
55+
onPiiRedacted: (matches) => {
56+
// e.g. show "redacted 2 emails, 1 SSN" for user consent
57+
console.log(matches.map((m) => m.category));
58+
},
59+
});
60+
```
61+
62+
In `useChatStorage`, `piiRedaction: true` keeps one redactor **per conversation**
63+
(reset when you switch conversations). You can also disable redaction for a
64+
single request:
65+
66+
```ts
67+
await sendMessage({ messages, piiRedaction: false });
68+
```
69+
70+
### Custom configuration
71+
72+
Pass a `PiiRedactor` instance to bring your own state or tune detection:
73+
74+
```ts
75+
import { PiiRedactor } from "@anuma/sdk";
76+
77+
const redactor = new PiiRedactor({
78+
// Drop the higher-false-positive categories
79+
excludeCategories: ["US_ADDRESS", "DATE_OF_BIRTH"],
80+
// Add your own detectors (custom categories get their own placeholder tag)
81+
extraPatterns: [{ category: "EMPLOYEE_ID", regex: /\bEMP-\d{6}\b/g }],
82+
});
83+
84+
const { sendMessage } = useChat({ getToken, piiRedaction: redactor });
85+
```
86+
87+
### Direct (server / Node)
88+
89+
```ts
90+
import { runToolLoop, PiiRedactor } from "@anuma/sdk/server";
91+
92+
const redactor = new PiiRedactor();
93+
await runToolLoop({
94+
messages,
95+
model,
96+
getToken,
97+
piiRedaction: redactor, // reuse across calls in the same conversation
98+
onData: (chunk) => process.stdout.write(chunk), // already de-anonymized
99+
});
100+
```
101+
102+
## How it works
103+
104+
1. Outbound message text is redacted with a stateful `PiiRedactor`, which maps
105+
each distinct value to a stable placeholder.
106+
2. The redacted request is sent to the provider.
107+
3. The streamed response is de-anonymized through a buffering de-anonymizer that
108+
correctly restores placeholders even when they are split across stream
109+
chunks.
110+
4. The final response and the persisted assistant message are de-anonymized too,
111+
so live and stored views match. Because original values are stored locally,
112+
every outbound turn re-redacts the full history with the same per-conversation
113+
redactor, keeping placeholders consistent.
114+
115+
## API
116+
117+
```ts
118+
type PiiCategory =
119+
| "EMAIL" | "PHONE" | "SSN" | "CREDIT_CARD"
120+
| "IP_ADDRESS" | "API_KEY" | "US_ADDRESS" | "DATE_OF_BIRTH";
121+
122+
interface PiiRedactorOptions {
123+
patterns?: PiiPattern[]; // replace the entire default set
124+
extraPatterns?: PiiPattern[]; // append custom detectors
125+
excludeCategories?: string[]; // disable built-in categories
126+
}
127+
128+
class PiiRedactor {
129+
constructor(options?: PiiRedactorOptions);
130+
redactText(text: string): { text: string; matches: PiiMatch[] };
131+
redactMessages(messages: LlmapiMessage[]): { messages: LlmapiMessage[]; matches: PiiMatch[] };
132+
deAnonymize(text: string): string;
133+
getMappings(): ReadonlyMap<string, string>; // placeholder -> original (snapshot)
134+
clear(): void;
135+
get size(): number;
136+
}
137+
```

‎src/content/sdk/client/Internal/functions/deleteApiV1AdminOauthClientsByClientId.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> **deleteApiV1AdminOauthClientsByClientId**<`ThrowOnError`>(`options`: [`Options`](../type-aliases/Options.md)<[`DeleteApiV1AdminOauthClientsByClientIdData`](../type-aliases/DeleteApiV1AdminOauthClientsByClientIdData.md), `ThrowOnError`>): `RequestResult`<[`DeleteApiV1AdminOauthClientsByClientIdResponses`](../type-aliases/DeleteApiV1AdminOauthClientsByClientIdResponses.md), [`DeleteApiV1AdminOauthClientsByClientIdErrors`](../type-aliases/DeleteApiV1AdminOauthClientsByClientIdErrors.md), `ThrowOnError`>
44
5-
Defined in: [src/client/sdk.gen.ts:272](https://github.com/anuma-ai/sdk/blob/main/src/client/sdk.gen.ts#272)
5+
Defined in: [src/client/sdk.gen.ts:332](https://github.com/anuma-ai/sdk/blob/main/src/client/sdk.gen.ts#332)
66

77
Revoke an OAuth client (soft delete)
88

‎src/content/sdk/client/Internal/functions/deleteApiV1AdminPersonasById.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> **deleteApiV1AdminPersonasById**<`ThrowOnError`>(`options`: [`Options`](../type-aliases/Options.md)<[`DeleteApiV1AdminPersonasByIdData`](../type-aliases/DeleteApiV1AdminPersonasByIdData.md), `ThrowOnError`>): `RequestResult`<[`DeleteApiV1AdminPersonasByIdResponses`](../type-aliases/DeleteApiV1AdminPersonasByIdResponses.md), [`DeleteApiV1AdminPersonasByIdErrors`](../type-aliases/DeleteApiV1AdminPersonasByIdErrors.md), `ThrowOnError`>
44
5-
Defined in: [src/client/sdk.gen.ts:324](https://github.com/anuma-ai/sdk/blob/main/src/client/sdk.gen.ts#324)
5+
Defined in: [src/client/sdk.gen.ts:384](https://github.com/anuma-ai/sdk/blob/main/src/client/sdk.gen.ts#384)
66

77
Delete persona
88

‎src/content/sdk/client/Internal/functions/deleteApiV1AdminTextReset.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> **deleteApiV1AdminTextReset**<`ThrowOnError`>(`options`: [`Options`](../type-aliases/Options.md)<[`DeleteApiV1AdminTextResetData`](../type-aliases/DeleteApiV1AdminTextResetData.md), `ThrowOnError`>): `RequestResult`<[`DeleteApiV1AdminTextResetResponses`](../type-aliases/DeleteApiV1AdminTextResetResponses.md), [`DeleteApiV1AdminTextResetErrors`](../type-aliases/DeleteApiV1AdminTextResetErrors.md), `ThrowOnError`>
44
5-
Defined in: [src/client/sdk.gen.ts:408](https://github.com/anuma-ai/sdk/blob/main/src/client/sdk.gen.ts#408)
5+
Defined in: [src/client/sdk.gen.ts:484](https://github.com/anuma-ai/sdk/blob/main/src/client/sdk.gen.ts#484)
66

77
Reset text registrations
88

‎src/content/sdk/client/Internal/functions/deleteApiV1AdminUsersDelete.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
> **deleteApiV1AdminUsersDelete**<`ThrowOnError`>(`options`: [`Options`](../type-aliases/Options.md)<[`DeleteApiV1AdminUsersDeleteData`](../type-aliases/DeleteApiV1AdminUsersDeleteData.md), `ThrowOnError`>): `RequestResult`<[`DeleteApiV1AdminUsersDeleteResponses`](../type-aliases/DeleteApiV1AdminUsersDeleteResponses.md), [`DeleteApiV1AdminUsersDeleteErrors`](../type-aliases/DeleteApiV1AdminUsersDeleteErrors.md), `ThrowOnError`>
44
5-
Defined in: [src/client/sdk.gen.ts:420](https://github.com/anuma-ai/sdk/blob/main/src/client/sdk.gen.ts#420)
5+
Defined in: [src/client/sdk.gen.ts:496](https://github.com/anuma-ai/sdk/blob/main/src/client/sdk.gen.ts#496)
66

77
Delete user account (admin)
88

9-
Permanently deletes a user account and all associated cascading data (enrollments, requests, credit claims, etc.) and best-effort cancels any Stripe subscription. Accepts wallet\_address, phone, telegram, or email (exactly one required). Returns stripe\_cleanup\_succeeded=false when the account was deleted but the Stripe customer cleanup failed — operator must clean up Stripe manually.
9+
Permanently deletes a user's data for a support or compliance request. Deletes the portal account and all associated cascading data (enrollments, requests, credit claims, etc.), best-effort cancels any Stripe subscription, AND deletes the Privy user. Accepts wallet\_address, phone, telegram, or email (exactly one required). Works even when there is no portal account (Privy-only user) — in that case only the Privy user is deleted. Returns portal\_account\_deleted / privy\_user\_deleted flags indicating what was removed, and stripe\_cleanup\_succeeded=false when the account was deleted but the Stripe customer cleanup failed (operator must clean up Stripe manually). Returns 502 if the Privy user deletion fails.
1010

1111
## Type Parameters
1212

‎src/content/sdk/client/Internal/functions/deleteApiV1AuthMfaPasskeyCredentialsByCredentialId.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> **deleteApiV1AuthMfaPasskeyCredentialsByCredentialId**<`ThrowOnError`>(`options`: [`Options`](../type-aliases/Options.md)<[`DeleteApiV1AuthMfaPasskeyCredentialsByCredentialIdData`](../type-aliases/DeleteApiV1AuthMfaPasskeyCredentialsByCredentialIdData.md), `ThrowOnError`>): `RequestResult`<[`DeleteApiV1AuthMfaPasskeyCredentialsByCredentialIdResponses`](../type-aliases/DeleteApiV1AuthMfaPasskeyCredentialsByCredentialIdResponses.md), [`DeleteApiV1AuthMfaPasskeyCredentialsByCredentialIdErrors`](../type-aliases/DeleteApiV1AuthMfaPasskeyCredentialsByCredentialIdErrors.md), `ThrowOnError`>
44
5-
Defined in: [src/client/sdk.gen.ts:508](https://github.com/anuma-ai/sdk/blob/main/src/client/sdk.gen.ts#508)
5+
Defined in: [src/client/sdk.gen.ts:616](https://github.com/anuma-ai/sdk/blob/main/src/client/sdk.gen.ts#616)
66

77
Delete a passkey
88

‎src/content/sdk/client/Internal/functions/deleteApiV1DeveloperAppsByAppUuid.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> **deleteApiV1DeveloperAppsByAppUuid**<`ThrowOnError`>(`options`: [`Options`](../type-aliases/Options.md)<[`DeleteApiV1DeveloperAppsByAppUuidData`](../type-aliases/DeleteApiV1DeveloperAppsByAppUuidData.md), `ThrowOnError`>): `RequestResult`<[`DeleteApiV1DeveloperAppsByAppUuidResponses`](../type-aliases/DeleteApiV1DeveloperAppsByAppUuidResponses.md), [`DeleteApiV1DeveloperAppsByAppUuidErrors`](../type-aliases/DeleteApiV1DeveloperAppsByAppUuidErrors.md), `ThrowOnError`>
44
5-
Defined in: [src/client/sdk.gen.ts:764](https://github.com/anuma-ai/sdk/blob/main/src/client/sdk.gen.ts#764)
5+
Defined in: [src/client/sdk.gen.ts:1040](https://github.com/anuma-ai/sdk/blob/main/src/client/sdk.gen.ts#1040)
66

77
Delete app
88

‎src/content/sdk/client/Internal/functions/deleteApiV1DeveloperAppsByAppUuidApiKeysByKeyId.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> **deleteApiV1DeveloperAppsByAppUuidApiKeysByKeyId**<`ThrowOnError`>(`options`: [`Options`](../type-aliases/Options.md)<[`DeleteApiV1DeveloperAppsByAppUuidApiKeysByKeyIdData`](../type-aliases/DeleteApiV1DeveloperAppsByAppUuidApiKeysByKeyIdData.md), `ThrowOnError`>): `RequestResult`<[`DeleteApiV1DeveloperAppsByAppUuidApiKeysByKeyIdResponses`](../type-aliases/DeleteApiV1DeveloperAppsByAppUuidApiKeysByKeyIdResponses.md), [`DeleteApiV1DeveloperAppsByAppUuidApiKeysByKeyIdErrors`](../type-aliases/DeleteApiV1DeveloperAppsByAppUuidApiKeysByKeyIdErrors.md), `ThrowOnError`>
44
5-
Defined in: [src/client/sdk.gen.ts:832](https://github.com/anuma-ai/sdk/blob/main/src/client/sdk.gen.ts#832)
5+
Defined in: [src/client/sdk.gen.ts:1108](https://github.com/anuma-ai/sdk/blob/main/src/client/sdk.gen.ts#1108)
66

77
Delete API key
88

‎src/content/sdk/client/Internal/functions/deleteApiV1DeveloperAppsByAppUuidPrivy.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> **deleteApiV1DeveloperAppsByAppUuidPrivy**<`ThrowOnError`>(`options`: [`Options`](../type-aliases/Options.md)<[`DeleteApiV1DeveloperAppsByAppUuidPrivyData`](../type-aliases/DeleteApiV1DeveloperAppsByAppUuidPrivyData.md), `ThrowOnError`>): `RequestResult`<[`DeleteApiV1DeveloperAppsByAppUuidPrivyResponses`](../type-aliases/DeleteApiV1DeveloperAppsByAppUuidPrivyResponses.md), [`DeleteApiV1DeveloperAppsByAppUuidPrivyErrors`](../type-aliases/DeleteApiV1DeveloperAppsByAppUuidPrivyErrors.md), `ThrowOnError`>
44
5-
Defined in: [src/client/sdk.gen.ts:860](https://github.com/anuma-ai/sdk/blob/main/src/client/sdk.gen.ts#860)
5+
Defined in: [src/client/sdk.gen.ts:1136](https://github.com/anuma-ai/sdk/blob/main/src/client/sdk.gen.ts#1136)
66

77
Remove Privy
88

‎src/content/sdk/client/Internal/functions/deleteApiV1TextByChannelUnregister.md‎

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)