/claim #290
Summary
- Add
AWSComprehendRedactor, AWSComprehendPIIRedactor, and AWSComprehendRestClient exports from the JS SDK AI package.
- Support direct text redaction, prompt/message redaction, endpoint
chat() wrapping, and stream/operator helpers for observable-style chains.
- Use an injectable Comprehend-compatible client for tests and a dependency-free SigV4 REST client for live AWS Comprehend calls.
- Add a runnable example under
JS/edgechains/examples/aws-comprehend-redaction that works without AWS credentials by using a deterministic mock client.
Requirement Checklist
- JavaScript SDK only: yes
- New chainable redaction classes for endpoint/observable-style usage: yes
- Testcases for the classes: yes
- Full working example under
JS/edgechains/examples: yes
- Short demo included in this PR: yes
- CLA signed and CI passing: yes
Validation
npx vitest run src/ai/src/tests/awsComprehendRedactor.test.ts
npm run build
npm start from JS/edgechains/examples/aws-comprehend-redaction
Demo
Short demo GIF:
The example prints the original prompt, the redacted prompt, the endpoint-wrapped response, and the stream output. It can also use live AWS Comprehend when USE_LIVE_AWS_COMPREHEND=true and AWS credentials are present.
Full demo transcript, included so the output remains reviewable even if GitHub clips the embedded media:
EdgeChains #290 demo: AWS Comprehend redaction
Runnable example with deterministic mock client; live AWS supported by env vars.
$ cd JS/edgechains/examples/aws-comprehend-redaction
$ npm start
Original prompt:
My name is Jane Doe. Email me at jane@example.com and call 555-0100 about invoice INV-42.
Redacted prompt:
My name is [REDACTED_NAME]. Email me at [REDACTED_EMAIL] and call [REDACTED_PHONE] about invoice INV-42.
Endpoint response:
Prompt received by endpoint: My name is [REDACTED_NAME]. Email me at [REDACTED_EMAIL] and call [REDACTED_PHONE] about invoice INV-42.
Stream output:
My name is [REDACTED_NAME]. Email me at [REDACTED_EMAIL] and call [REDACTED_PHONE] about invoice INV-42.
✓ npx vitest run src/ai/src/tests/awsComprehendRedactor.test.ts