# Agent workspace stub: Streams page + profile-context handler

Companion to the FactualMinds post "Amazon Connect custom agent UI and Customer Profiles (Oct 2026)".

| File | What it is |
| --- | --- |
| `index.html`, `app.mjs` | Minimal Amazon Connect Streams page: embeds the CCP, subscribes to contact events, renders profile context in a live region, moves focus only after the agent accepts. Not run against a live instance. |
| `profile-context.mjs` | Backend handler. Takes an injected `searchProfiles(params)` function, validates input, calls SearchProfiles by `_phone`, `_email` or `_account`, returns a flat string map, degrades on timeout or error. |
| `profile-context.test.mjs` | `node --test`, mock client only. No AWS credentials, no network. |
| `events/` | Sample browser request and a SearchProfiles-shaped response used by the test. |

Run the test (Node 24, no dependencies):

    node --test

To use the page: `npm install amazon-connect-streams`, serve its built `connect-streams-min.js` next to `index.html` over HTTPS, add that origin to the instance's Approved origins, set `CCP_URL`, and put the handler behind your own authenticated endpoint. In Lambda, wire the client with `@aws-sdk/client-customer-profiles` (`SearchProfilesCommand`) and grant that role `profile:SearchProfiles` on the one domain ARN.

What is not covered: authentication of the browser to your backend, the Customer Profiles domain setup, and a browser-level test of `app.mjs`.
