@nexalink/carecompass-sdk 0.3.0-beta.15 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,141 +1,358 @@
1
- # CareCompass Healthcare AI Infrastructure SDK
1
+ # CareCompass SDK
2
2
 
3
- CareCompass helps healthcare teams launch branded healthcare navigation assistants, member support assistants, and patient-facing AI experiences inside their own portals or applications. The SDK combines an embeddable chat experience with Nexalink-hosted healthcare AI infrastructure, reducing the implementation effort required to move from idea to deployable healthcare navigation workflow.
3
+ CareCompass is embeddable healthcare AI infrastructure for teams building AI-powered healthcare products.
4
4
 
5
- The SDK is publicly installable for developer convenience, but live regulated use requires Nexalink onboarding, issued credentials, and BAA coverage where PHI may be involved. CareCompass is designed for healthcare navigation and support workflows. It is not a general-purpose LLM SDK, not a medical diagnosis tool, not autonomous treatment recommendation software, and not a replacement for clinicians or clinical judgment.
5
+ It gives healthcare companies a secure SDK and hosted runtime for adding LLM-powered experiences to their own applications without building the regulated AI stack from scratch: model routing, tenant-aware runtime APIs, browser-safe authentication, prompt controls, guardrails, origin validation, deployment checks, and healthcare-specific onboarding.
6
6
 
7
- ## Who It's For
7
+ CareCompass is for teams that want to ship their own AI product experience while relying on Nexalink to operate the healthcare AI infrastructure layer underneath.
8
8
 
9
- - Healthcare startups building AI-powered patient experiences
10
- - Payer innovation and member engagement teams
11
- - Employer-benefits platforms
12
- - Provider organizations adding patient-facing support workflows
13
- - Digital health engineering teams
14
- - Healthcare product teams that need AI infrastructure quickly
9
+ The SDK gives teams two integration paths:
15
10
 
16
- ## Why Teams Use CareCompass
11
+ - **Headless core** for product teams that want full control over their own UI, workflow, state management, and rendering.
12
+ - **Optional UI kit** for teams that want a fast, branded AI chat experience they can drop into a web app and customize over time.
17
13
 
18
- - **Faster deployment**: add a healthcare-focused AI assistant to an existing healthcare product without months of infrastructure work.
19
- - **Reduced engineering effort**: avoid building and operating the supporting healthcare AI infrastructure around the assistant.
20
- - **Hosted healthcare AI runtime**: chat requests route through Nexalink-hosted APIs and the CareCompass AI runtime.
21
- - **Embedded branded experience**: use the React component, JavaScript mount helper, generated embed page, or iframe with your display name, labels, theme, logo, and support links.
22
- - **Prompt and configuration controls**: define approved prompt context, welcome copy, placement, allowed origins, and deployment environment.
23
- - **Deployment controls**: use key management, origin allowlists, hosted validation, and staging/production credential separation.
24
- - **Enterprise onboarding**: support BAA-gated onboarding where PHI may be involved.
14
+ CareCompass is not a diagnosis tool, autonomous treatment product, replacement for clinicians, or general-purpose LLM SDK. It is healthcare AI infrastructure for building compliance-oriented, embedded AI workflows.
25
15
 
26
- ## Why Not Build It Yourself?
16
+ ## Why Teams Choose CareCompass
27
17
 
28
- Most healthcare teams can access foundation models through OpenAI, Anthropic, Bedrock, Azure OpenAI, or similar providers. The harder work is not obtaining an LLM. The harder work is building and operating the healthcare AI infrastructure around it:
18
+ Healthcare teams can already access foundation models. The hard part is turning those models into production-ready healthcare software.
29
19
 
30
- - Healthcare-focused prompts and guardrails
31
- - Hosted inference infrastructure
32
- - Tenant isolation
33
- - Key management
34
- - Deployment validation
35
- - Browser embedding
36
- - Usage tracking
37
- - Compliance-oriented onboarding
20
+ CareCompass packages the healthcare-specific infrastructure layer that most teams would otherwise need to build themselves:
38
21
 
39
- CareCompass provides a managed healthcare AI infrastructure layer for these workflows, while keeping the embedded experience configurable for your application and brand.
22
+ - secure hosted runtime APIs
23
+ - tenant and environment routing
24
+ - browser-safe embed authentication
25
+ - origin allowlist validation
26
+ - prompt and configuration controls
27
+ - guardrails for regulated workflows
28
+ - deployment readiness checks
29
+ - white-label UI support
30
+ - operational onboarding for healthcare use cases
31
+
32
+ Instead of spending months building LLM infrastructure, product teams can use CareCompass to embed AI into their own application and focus on the workflow, customer experience, and clinical or operational use case they are trying to ship.
33
+
34
+ ## What You Can Build
35
+
36
+ CareCompass can power healthcare AI features inside products such as:
37
+
38
+ - clinical workflow copilots
39
+ - patient engagement assistants
40
+ - care navigation and resource guidance flows
41
+ - benefits or plan guidance experiences
42
+ - RCM and prior authorization support tools
43
+ - onboarding and support flows for digital health products
44
+ - internal operations copilots for healthcare teams
45
+ - white-labeled AI assistants inside existing healthcare applications
46
+
47
+ CareCompass is intentionally workflow-agnostic at the infrastructure layer. The customer owns the product experience; CareCompass provides the SDK, runtime, guardrails, and deployment model needed to make healthcare AI usable in production.
40
48
 
41
49
  ## What You Avoid Building
42
50
 
43
- - Model gateway
44
- - Chat embed
45
- - Prompt validation layer
46
- - Tenant and key management
47
- - Usage tracking
48
- - Hosted inference path
49
- - Staging and production credential separation
50
- - Deployment validation tooling
51
+ CareCompass handles infrastructure that healthcare AI teams usually need before they can safely ship:
52
+
53
+ - Hosted inference gateway
54
+ - Tenant-aware runtime APIs
55
+ - Browser-safe embed authentication model
56
+ - Tenant and environment routing
57
+ - Origin allowlist validation
58
+ - Prompt and configuration validation
59
+ - Guardrail enforcement
60
+ - Streaming and retry lifecycle state
61
+ - Default chat UI and iframe setup assets
62
+ - Deployment readiness tooling
63
+ - Anonymous deployment-health telemetry
51
64
  - Compliance-oriented onboarding workflow
52
65
 
53
- ## What You Can Build
66
+ ## SDK Architecture
54
67
 
55
- - Member support assistants
56
- - Benefits navigation assistants
57
- - Provider discovery support flows
58
- - Employer healthcare navigation portals
59
- - Payer member engagement tools
60
- - Digital health support chat experiences
68
+ ```text
69
+ Your product UI
70
+ |
71
+ | uses either
72
+ |-- CareCompass headless core
73
+ |-- CareCompass UI kit
74
+ |
75
+ CareCompass SDK
76
+ |
77
+ Nexalink-hosted CareCompass APIs
78
+ |
79
+ CareCompass AI runtime
80
+ ```
61
81
 
62
- ## Example Questions CareCompass Can Help With
82
+ The browser receives only public embed configuration: tenant identifier, environment, public embed key, allowed origins, endpoint, model preferences, feature flags, branding, labels, theme, placement, compliance, and approved prompt settings.
63
83
 
64
- CareCompass is intended for healthcare navigation and support, not diagnosis or treatment recommendations. Example navigation questions include:
84
+ Secret API keys stay in CLI, server-side, or trusted setup workflows. The browser never receives model credentials or Nexalink API keys.
65
85
 
66
- - "How do I find an in-network cardiologist?"
67
- - "What does my deductible mean?"
68
- - "How do I schedule a specialist appointment?"
69
- - "Where can I find behavioral health resources?"
70
- - "What support resources are available through my plan?"
86
+ ## Integration Options
71
87
 
72
- ## What CareCompass Is Not
88
+ ### 1. Headless Core
73
89
 
74
- - Not a general-purpose LLM SDK
75
- - Not a diagnosis tool
76
- - Not a replacement for clinical judgment
77
- - Not autonomous treatment recommendation software
90
+ Use the headless core when your team already has a product surface and wants CareCompass to own the AI runtime lifecycle, not the UI.
78
91
 
79
- ## Quick Start
92
+ The core manages:
80
93
 
81
- Account creation and credentials are required because CareCompass is healthcare AI infrastructure for regulated deployment workflows, not an unauthenticated demo widget. The CLI requires Node.js 18 or newer.
94
+ - message submission
95
+ - poll-backed streaming lifecycle events
96
+ - conversation snapshots
97
+ - loading, error, timeout, and retry state
98
+ - context injection
99
+ - subscriptions for custom renderers
100
+ - PHI preflight, safety callbacks, and metadata-only audit trails
101
+ - endpoint calls and telemetry integration
82
102
 
83
- ```bash
84
- npx @nexalink/carecompass-sdk init --account-type developer --api-key <nexalink-api-key> --payer-id acme-health --origin https://members.acme-health.com
85
- npx @nexalink/carecompass-sdk validate --config carecompass/carecompass.config.json
86
- npx @nexalink/carecompass-sdk doctor --config carecompass/carecompass.config.json
103
+ ```ts
104
+ import { createCareCompassCore } from "@nexalink/carecompass-sdk/core";
105
+ import config from "./carecompass/carecompass.config.json";
106
+
107
+ const careCompass = createCareCompassCore(config, {
108
+ initialContext: {
109
+ userId: "user_123",
110
+ organizationId: "acme-health",
111
+ },
112
+ });
113
+
114
+ const unsubscribe = careCompass.subscribe((snapshot) => {
115
+ renderMessages(snapshot.messages);
116
+ renderLoading(snapshot.loading);
117
+ renderError(snapshot.error);
118
+ });
119
+
120
+ for await (const event of careCompass.streamMessage(
121
+ "Help me understand the next step in this workflow.",
122
+ { context: { workflow: "patient-onboarding" } },
123
+ )) {
124
+ console.log(event.type);
125
+ }
126
+
127
+ unsubscribe();
128
+ careCompass.dispose();
87
129
  ```
88
130
 
89
- `init` validates your Nexalink API key, stores it locally, and generates:
131
+ The streaming API is lifecycle streaming over the existing CareCompass endpoint flow. It exposes submitted, status, completion, and error events so your UI can respond immediately while the hosted runtime works. It is not token-by-token model streaming.
90
132
 
91
- - `carecompass/carecompass.config.json`
92
- - `carecompass/system-prompt.md`
93
- - `carecompass/carecompass-embed.html`
94
- - `carecompass/carecompass-iframe.html`
95
- - `carecompass/README.md`
133
+ ### 2. Optional React UI Kit
96
134
 
97
- `npx` does not install a permanent `carecompass` command. Keep using `npx @nexalink/carecompass-sdk <command>` or install the package.
135
+ Use the UI kit when you want a fast branded AI interface with minimal setup.
98
136
 
99
- ## How It Works
137
+ ```tsx
138
+ import { CareCompassChat } from "@nexalink/carecompass-sdk/ui";
139
+ import config from "./carecompass/carecompass.config.json";
100
140
 
101
- ```text
102
- Your Application
103
- ↓
104
- CareCompass SDK
105
- ↓
106
- Nexalink Hosted APIs
107
- ↓
108
- CareCompass AI Runtime
141
+ export function HealthcareAssistant() {
142
+ return (
143
+ <CareCompassChat
144
+ config={config}
145
+ initialContext={{ userId: "user_123" }}
146
+ renderMessage={(message) => (
147
+ <p data-role={message.role}>{message.text}</p>
148
+ )}
149
+ retryLabel="Try again"
150
+ onEvent={(event) => console.log(event.type)}
151
+ />
152
+ );
153
+ }
154
+ ```
155
+
156
+ The UI kit includes:
157
+
158
+ - branded header, labels, disclaimer, and theme support
159
+ - loading, error, and retry states
160
+ - default assistant markdown rendering for headings, bold text, lists, rules, and tables
161
+ - safe text rendering without raw HTML injection
162
+ - `renderMessage` escape hatch for teams that want complete message-render control
163
+ - compatibility with existing `CareCompassEmbed` and `mountCareCompass` integrations
164
+
165
+ Custom message rendering:
166
+
167
+ ```tsx
168
+ <CareCompassChat
169
+ config={config}
170
+ renderMessage={(message) => (
171
+ <MessageBubble role={message.role}>{message.text}</MessageBubble>
172
+ )}
173
+ />
174
+ ```
175
+
176
+ ### RCM coding-assistance pilot workflow
177
+
178
+ The RCM kit is a narrow, structured coding-review workflow built on the same
179
+ headless core, compliance preflight, and metadata-only audit events. It returns
180
+ candidate codes for qualified human review; it never makes a final coding,
181
+ billing, claim-submission, diagnosis, or treatment decision.
182
+
183
+ The SDK sends `workflow: "rcm-coding-assistance"` as an explicit top-level ask
184
+ field. The hosted runtime authorizes the workflow from the issued embed key and
185
+ server-side tenant entitlement. Values in user context do not authorize a
186
+ workflow.
187
+
188
+ For the hosted RCM path, configure the tenant's RCM policy corpus in the
189
+ CareCompass tenant portal before embedding: an authorized administrator must
190
+ have an executed BAA, enable the RCM entitlement, set up the corpus, upload a
191
+ customer-owned policy version, explicitly approve it, and wait for ingestion to
192
+ become active. The browser sends structured encounter context only; it never
193
+ sends a corpus ID, policy text, or policy references.
194
+
195
+ ```tsx
196
+ import {
197
+ CARECOMPASS_RCM_SYNTHETIC_DEMO,
198
+ RcmCodingAssistant,
199
+ } from "@nexalink/carecompass-sdk/rcm";
200
+
201
+ <RcmCodingAssistant
202
+ config={config}
203
+ initialInput={CARECOMPASS_RCM_SYNTHETIC_DEMO}
204
+ workflowOptions={{
205
+ customerRules: { requirePolicySupport: true },
206
+ retrieval: "hosted",
207
+ }}
208
+ onAuditEvent={(event) => hostAudit(event)}
209
+ onSafetyEvent={(event) => hostSafetyMonitor(event)}
210
+ />;
211
+ ```
212
+
213
+ The included demo input is synthetic and contains no patient data. Use it only
214
+ with synthetic, approved policy material during development. The package
215
+ includes [`DEMO-ENC-1042-rcm-policy.md`](qa-fixtures/DEMO-ENC-1042-rcm-policy.md)
216
+ for the matching demo. Upload that file through **RCM policy corpus**, give it
217
+ the `2026.1-demo` version, explicitly approve it, and wait for ingestion before
218
+ submitting `CARECOMPASS_RCM_SYNTHETIC_DEMO`. It is deliberately not a real payer
219
+ policy or coding manual.
220
+
221
+ A production tenant must have an executed BAA, an RCM entitlement, and a
222
+ healthy active corpus; otherwise the hosted workflow fails closed with a
223
+ structured human-review escalation.
224
+
225
+ In hosted mode, the result's `policyReferences` are the sanitized citations
226
+ resolved by the runtime. Render those citations alongside a coder-review
227
+ suggestion. A `review_required` result requires policy support; empty retrieval,
228
+ invalid citations, guardrail intervention, or invalid JSON becomes an
229
+ `abstain`/`escalate` result with no recommendations. Hosts receive the normal
230
+ metadata-only audit and safety events, including authorization, retrieval,
231
+ validation, and escalation outcomes.
232
+
233
+ For a customer-managed trusted retrieval boundary, pass an `RcmPolicyRetriever`
234
+ instead of `"hosted"`. Its `approvedCorpusIds` allowlist is enforced by the SDK;
235
+ unapproved or missing references produce a human-review escalation.
236
+
237
+ To evaluate the pilot, compare **manual research minutes per case** before and
238
+ after assisted, human-reviewed use. The target is to measure a 25% or greater
239
+ reduction, not to make or submit a coding decision.
240
+
241
+ ### 3. React Hook
242
+
243
+ Use `useCareCompass` when your React app needs its own visual design but does
244
+ not want to manage subscriptions, retries, or teardown by hand.
245
+
246
+ ```tsx
247
+ import { useCareCompass } from "@nexalink/carecompass-sdk/react";
248
+ import config from "./carecompass/carecompass.config.json";
249
+
250
+ export function CareCompassPanel() {
251
+ const { snapshot, sendMessage, retryLast } = useCareCompass(config, {
252
+ initialContext: { workflow: "member-portal" },
253
+ onSafetyEvent: (event) => monitorSafety(event),
254
+ });
255
+
256
+ return (
257
+ <section>
258
+ {snapshot.messages.map((message) => (
259
+ <p key={message.id}>{message.text}</p>
260
+ ))}
261
+ <button
262
+ disabled={snapshot.loading}
263
+ onClick={() => void sendMessage("Find an in-network doctor")}
264
+ >
265
+ Find care
266
+ </button>
267
+ {snapshot.canRetry && (
268
+ <button onClick={() => void retryLast()}>Retry</button>
269
+ )}
270
+ </section>
271
+ );
272
+ }
273
+ ```
274
+
275
+ The hook returns the underlying `core` for audit export, safety/audit
276
+ subscriptions, tool/widget events, and the lifecycle `streamMessage` API.
277
+
278
+ ### 4. Web Component (Vue-compatible)
279
+
280
+ The Web Component is rendered directly from the headless core and exposes a
281
+ standard custom-element property, making it a good fit for Vue, Angular, CMS
282
+ shells, and mixed-framework pages without requiring a React runtime. Register
283
+ it only in the browser.
284
+
285
+ ```ts
286
+ import { defineCareCompassElement } from "@nexalink/carecompass-sdk/web-component";
287
+
288
+ defineCareCompassElement();
109
289
  ```
110
290
 
111
- Your application renders the CareCompass UI through the SDK. The browser receives only public embed configuration: payer ID, environment, public embed key, branding, labels, theme, support links, approved prompt settings, placement, and telemetry defaults. The browser does not receive the secret API key, private model endpoint details, SageMaker credentials, AppSync signing roles, or Nexalink server-side allowlists.
291
+ ```vue
292
+ <script setup lang="ts">
293
+ import { onMounted, ref } from "vue";
294
+ import { defineCareCompassElement } from "@nexalink/carecompass-sdk/web-component";
295
+ import config from "./carecompass/carecompass.config.json";
296
+
297
+ const chat = ref<HTMLElement & { config?: typeof config }>();
298
+ onMounted(() => {
299
+ defineCareCompassElement();
300
+ if (chat.value) chat.value.config = config;
301
+ });
302
+ </script>
303
+
304
+ <template><carecompass-chat ref="chat" /></template>
305
+ ```
306
+
307
+ For static hosts, the element also accepts a JSON `config` attribute. Prefer the
308
+ property assignment above in application code: it avoids HTML escaping and keeps
309
+ the configuration in your typed build pipeline.
310
+
311
+ ### 5. Script-tag Quickstart
312
+
313
+ The existing `mountCareCompass` path remains supported for quick static pages
314
+ and CMS integrations. Generate a script snippet from the same config:
315
+
316
+ ```ts
317
+ import { generateCareCompassSnippet } from "@nexalink/carecompass-sdk";
318
+
319
+ const html = generateCareCompassSnippet(config, { mode: "cdn" });
320
+ ```
321
+
322
+ The generated module calls `mountCareCompass` and does not require a React app.
112
323
 
113
- Chat requests go to Nexalink-hosted CareCompass API routes. Those hosted routes are responsible for authorization, origin validation, tenant isolation, prompt guardrails, rate limiting, request attribution, usage tracking, and routing to the CareCompass AI runtime.
324
+ ### 6. Iframe Fallback
114
325
 
115
- ## Account, Credentials, and BAA Requirements
326
+ Use an iframe when the host page needs strong CSS/JavaScript isolation or cannot
327
+ run a module script. The CLI `init` flow generates an iframe page, or you can
328
+ create the host markup with `generateCareCompassIframeSnippet(config)`.
116
329
 
117
- A Nexalink account with SDK access is required beyond package installation so Nexalink can validate payer identity, deployment environment, allowed origins, approved prompt configuration, credentials, and API usage.
330
+ ```ts
331
+ import { generateCareCompassIframeSnippet } from "@nexalink/carecompass-sdk";
118
332
 
119
- CareCompass uses two different keys:
333
+ const html = generateCareCompassIframeSnippet(config, {
334
+ src: "/carecompass/carecompass-embed.html",
335
+ });
336
+ ```
120
337
 
121
- - **API key**: a secret credential for trusted setup and server-side or CLI workflows, including `init` sign-in and validation. Never include it in browser code, generated embed HTML, frontend config, or source control.
122
- - **Embed key**: a public browser-facing identifier for the CareCompass embed. It is safe to include in `carecompass.config.json` and generated snippets. It identifies the payer, environment, and embed client for runtime requests, but it is not a secret or proof of identity on its own.
338
+ An iframe isolates page styles and scripts, but it adds a separate document for
339
+ focus management, analytics, responsive sizing, and host-to-widget context.
340
+ Choose the React hook or Web Component when the assistant needs rich in-page
341
+ coordination; choose the iframe for constrained or high-isolation environments.
123
342
 
124
- API keys are issued in the Nexalink portal. When PHI may be involved, a tenant owner or admin may need to execute the canonical BAA before generating the first key. The secret API key is shown once, stored locally by the developer, and should be handled as a server-side or CLI credential.
343
+ ### 7. Existing Embed Compatibility
125
344
 
126
- ## React Usage
345
+ Existing embed integrations can keep using the root package exports.
127
346
 
128
347
  ```tsx
129
348
  import { CareCompassEmbed } from "@nexalink/carecompass-sdk";
130
349
  import config from "./carecompass/carecompass.config.json";
131
350
 
132
- export function MemberSupport() {
351
+ export function HealthcareAssistant() {
133
352
  return <CareCompassEmbed config={config} />;
134
353
  }
135
354
  ```
136
355
 
137
- ## JavaScript Usage
138
-
139
356
  ```ts
140
357
  import { mountCareCompass } from "@nexalink/carecompass-sdk";
141
358
  import config from "./carecompass/carecompass.config.json";
@@ -143,9 +360,65 @@ import config from "./carecompass/carecompass.config.json";
143
360
  mountCareCompass(document.getElementById("carecompass-root"), config);
144
361
  ```
145
362
 
146
- ## Configuration Reference
363
+ ### Production runtime tokens
364
+
365
+ Production embeds require a fresh runtime token from an integrator-controlled
366
+ backend-for-frontend (BFF). Do not place a Nexalink API key, runtime-token
367
+ secret, or a reusable token in `carecompass.config.json` or browser code.
368
+
369
+ Provide `runtimeTokenProvider`; the SDK calls it before validation, every
370
+ inference request, and every status poll. The provider should call your BFF,
371
+ which holds the Nexalink API key and obtains a short-lived token for the
372
+ current browser origin and workflow.
373
+
374
+ ```tsx
375
+ const runtimeTokenProvider = async ({ workflow }: { workflow?: string }) => {
376
+ const response = await fetch("/api/carecompass/runtime-token", {
377
+ method: "POST",
378
+ credentials: "same-origin",
379
+ headers: { "content-type": "application/json" },
380
+ body: JSON.stringify({ workflow }),
381
+ });
382
+ if (!response.ok) throw new Error("Could not authorize CareCompass.");
383
+ return ((await response.json()) as { token: string }).token;
384
+ };
385
+
386
+ <CareCompassEmbed
387
+ config={config}
388
+ runtimeTokenProvider={runtimeTokenProvider}
389
+ />;
390
+ ```
391
+
392
+ For static hosts, pass the provider as the third argument to
393
+ `mountCareCompass`. For Web Components, assign it to the
394
+ `runtimeTokenProvider` property before setting `config`. Production requests
395
+ fail closed when the provider is absent, fails, or returns an empty token.
396
+
397
+ ## Quick Start
398
+
399
+ Live regulated use requires Nexalink onboarding, issued credentials, and BAA coverage where PHI may be involved. The package is publicly installable for developer convenience, but runtime access is credentialed.
400
+
401
+ ```bash
402
+ npx @nexalink/carecompass-sdk init --account-type developer --api-key <nexalink-api-key> --payer-id acme-health --origin https://app.acme-health.com
403
+ npx @nexalink/carecompass-sdk validate --config carecompass/carecompass.config.json
404
+ npx @nexalink/carecompass-sdk doctor --config carecompass/carecompass.config.json
405
+ ```
406
+
407
+ `payerId` is the current tenant identifier used by the SDK. Despite the name, it can represent any healthcare customer workspace, including providers, digital health companies, RCM vendors, care platforms, AI healthcare products, and other healthcare organizations.
147
408
 
148
- `carecompass/carecompass.config.json` is safe to commit when it contains only public embed configuration. Store the secret API key only in local CLI credentials or an approved server-side secret store.
409
+ `init` creates a starter setup kit:
410
+
411
+ - `carecompass/carecompass.config.json`
412
+ - `carecompass/system-prompt.md`
413
+ - `carecompass/carecompass-embed.html`
414
+ - `carecompass/carecompass-iframe.html`
415
+ - `carecompass/README.md`
416
+
417
+ `npx` does not install a permanent `carecompass` command. Keep using `npx @nexalink/carecompass-sdk <command>` or install the package in your project.
418
+
419
+ ## Public Configuration
420
+
421
+ `carecompass.config.json` is safe to commit when it contains only public embed configuration. Do not put the secret API key in browser code, generated HTML, frontend config, or source control.
149
422
 
150
423
  ```json
151
424
  {
@@ -153,11 +426,11 @@ mountCareCompass(document.getElementById("carecompass-root"), config);
153
426
  "environment": "staging",
154
427
  "apiBaseUrl": "https://www.nexalink.care",
155
428
  "embedKey": "embed_public_key_from_nexalink",
156
- "allowedOrigins": ["https://members.acme-health.com"],
429
+ "allowedOrigins": ["https://app.acme-health.com"],
157
430
  "branding": {
158
431
  "displayName": "Acme Health",
159
- "logoUrl": "https://members.acme-health.com/logo.svg",
160
- "supportUrl": "https://members.acme-health.com/support"
432
+ "logoUrl": "https://app.acme-health.com/logo.svg",
433
+ "supportUrl": "https://app.acme-health.com/support"
161
434
  },
162
435
  "theme": {
163
436
  "primaryColor": "#2563eb",
@@ -167,17 +440,28 @@ mountCareCompass(document.getElementById("carecompass-root"), config);
167
440
  "fontFamily": "system-ui, sans-serif"
168
441
  },
169
442
  "labels": {
170
- "title": "Acme Care Guide",
171
- "placeholder": "Ask about benefits, care options, or next steps...",
443
+ "title": "Acme AI Assistant",
444
+ "placeholder": "Ask about this workflow...",
172
445
  "sendButton": "Send",
173
- "disclaimer": "CareCompass provides navigation support, not medical advice.",
446
+ "disclaimer": "This assistant provides support, not medical advice.",
174
447
  "errorMessage": "CareCompass is unavailable right now."
175
448
  },
176
449
  "prompt": {
177
450
  "systemInstructionFile": "./system-prompt.md",
178
- "welcomeMessage": "How can I help you navigate your care today?",
451
+ "welcomeMessage": "How can I help?",
179
452
  "allowUserContext": false
180
453
  },
454
+ "compliance": {
455
+ "preset": "healthcare"
456
+ },
457
+ "model": {
458
+ "id": "care-navigation-v2",
459
+ "version": "2026-07"
460
+ },
461
+ "featureFlags": {
462
+ "care-plan-summary": true,
463
+ "provider-search": true
464
+ },
181
465
  "placement": {
182
466
  "mode": "inline"
183
467
  },
@@ -185,39 +469,100 @@ mountCareCompass(document.getElementById("carecompass-root"), config);
185
469
  }
186
470
  ```
187
471
 
188
- `carecompass/system-prompt.md` defines approved context before a member message reaches the AI runtime: plan terminology, support boundaries, escalation rules, and navigation context. The CLI resolves the prompt file into `carecompass/carecompass-embed.html`; the browser receives prompt text, not a local file path. Nexalink guardrails still validate prompt content.
472
+ ## Compliance Controls And Audit Trails
473
+
474
+ Compliance controls are local SDK preflight checks, not a substitute for Nexalink runtime guardrails, a BAA, or the host application's own HIPAA program. They detect common direct identifiers (email addresses, US phone numbers, SSNs, DOBs, member/policy IDs, and MRNs) in messages, responses, and string-valued context before the SDK stores or sends them.
475
+
476
+ Choose a preset in public SDK configuration, then override only the behavior you need:
189
477
 
190
- `carecompass/carecompass-iframe.html` contains the iframe to place on the integrating page:
478
+ | Preset | PHI behavior | Audit retention | Tradeoff |
479
+ | ------------ | --------------------------------------------------------------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------- |
480
+ | `standard` | Detects and emits a `policy_sensitive` safety callback; does not modify requests. | Off | Preserves existing SDK behavior; the host must opt into audit retention. |
481
+ | `healthcare` | Replaces detected values with `[REDACTED]` before requests and UI state. | On | Recommended default for PHI-oriented browser integrations; local detection cannot identify every form of PHI. |
482
+ | `strict` | Blocks a request or response with detectable PHI. | On | Stronger browser-side control, but legitimate identifier-bearing workflows need a host-approved alternative. |
191
483
 
192
- ```html
193
- <iframe
194
- title="Acme Health CareCompass"
195
- src="/carecompass/carecompass-embed.html"
196
- style="width: 100%; min-height: 640px; border: 0; border-radius: 8px;"
197
- loading="lazy"
198
- ></iframe>
484
+ ```ts
485
+ import { createCareCompassCore } from "@nexalink/carecompass-sdk/core";
486
+
487
+ const core = createCareCompassCore({
488
+ ...config,
489
+ compliance: {
490
+ preset: "healthcare",
491
+ phi: { replacement: "[PHI REMOVED]" },
492
+ },
493
+ });
494
+
495
+ const unsubscribeAudit = core.subscribeAudit((event) => {
496
+ // Persist to your audit system. Events contain type, outcome, timestamp,
497
+ // source, PHI category/count, and a generated ID—never message text,
498
+ // context values, identifiers, or raw errors.
499
+ persistAuditEvent(event);
500
+ });
501
+
502
+ const unsubscribeSafety = core.subscribeSafety((event) => {
503
+ // `blocked`, `redacted`, `escalated`, or `policy_sensitive` with only
504
+ // source plus PHI category/count for safe monitoring.
505
+ monitorSafetyEvent(event);
506
+ });
507
+
508
+ // Export a copy of the in-memory, metadata-only audit trail on demand.
509
+ const auditTrail = core.exportAuditTrail();
510
+
511
+ unsubscribeAudit();
512
+ unsubscribeSafety();
199
513
  ```
200
514
 
201
- Serve `carecompass/carecompass-embed.html` at the iframe `src`, often by copying the generated `carecompass` folder into public/static assets.
515
+ For host-owned tools and UI actions that happen outside the core request lifecycle, add their metadata-only events explicitly:
516
+
517
+ ```ts
518
+ core.recordToolCall("completed");
519
+ core.recordWidgetAction();
520
+ core.recordSafetyDecision("escalated");
521
+ ```
522
+
523
+ If your organization has an approved detector or redaction format, pass it through `createCareCompassCore` options. These hooks receive the raw value only inside your host application; the SDK still emits only PHI categories and counts in audit and safety events.
524
+
525
+ ```ts
526
+ const core = createCareCompassCore(config, {
527
+ compliance: {
528
+ phi: {
529
+ detect: (value) => approvedPhiDetector(value),
530
+ redact: (value, matches) => approvedRedactor(value, matches),
531
+ },
532
+ },
533
+ });
534
+ ```
535
+
536
+ The React UI kit accepts `onAuditEvent` and `onSafetyEvent` with the same safe payloads. Its submit and retry actions are automatically represented as widget audit events when auditing is enabled.
537
+
538
+ ## Credential Model
539
+
540
+ CareCompass uses two key types:
541
+
542
+ - **API key**: secret credential for trusted setup, CLI validation, and server-side workflows. Never expose it in browser code.
543
+ - **Embed key**: public browser-facing identifier used by the runtime embed. It identifies the tenant, environment, and embed client, but it is not a secret by itself.
544
+
545
+ Nexalink-hosted routes remain responsible for authorization, origin validation, tenant isolation, prompt guardrails, rate limiting, request attribution, usage tracking, and routing to the CareCompass runtime.
202
546
 
203
547
  ## CLI Reference
204
548
 
205
549
  ### `init`
206
550
 
207
- Runs first-time setup: routes users to signup, validates the API key, stores it locally, and generates the config, prompt starter, embed page, iframe, and setup guide with only public embed configuration.
551
+ Creates the local setup kit, validates credentials, stores the API key locally, and generates starter config and embed assets.
208
552
 
209
- Credentials are stored at `~/.nexalink/carecompass/credentials.json` by default. You can also set `CARECOMPASS_API_KEY`. For scripted setup, pass `--account-type developer`. Configure signup with `--developer-signup-url` or `CARECOMPASS_DEVELOPER_SIGNUP_URL`; default: `https://www.nexalink.care/developer/signup`.
553
+ ```bash
554
+ npx @nexalink/carecompass-sdk init --account-type developer --api-key <nexalink-api-key> --payer-id acme-health --origin https://app.acme-health.com
555
+ ```
210
556
 
211
- Generated HTML defaults to bundler-friendly imports from `@nexalink/carecompass-sdk`. For a raw browser HTML demo that is not processed by a bundler, add `--snippet-mode cdn`.
557
+ For raw browser HTML that is not processed by a bundler:
212
558
 
213
559
  ```bash
214
- npx @nexalink/carecompass-sdk init --account-type developer --api-key <nexalink-api-key> --payer-id acme-health --origin https://members.acme-health.com
215
- npx @nexalink/carecompass-sdk init --account-type developer --snippet-mode cdn --payer-id acme-health --origin https://members.acme-health.com
560
+ npx @nexalink/carecompass-sdk init --account-type developer --snippet-mode cdn --payer-id acme-health --origin https://app.acme-health.com
216
561
  ```
217
562
 
218
563
  ### `validate`
219
564
 
220
- Checks local config shape and credentials, then hosted validation for `apiBaseUrl`, `embedKey`, `payerId`, `environment`, and `allowedOrigins` unless `--local-only` is passed. Browser-side validation uses public embed headers and does not send the secret API key.
565
+ Checks local config shape and hosted runtime configuration.
221
566
 
222
567
  ```bash
223
568
  npx @nexalink/carecompass-sdk validate --config carecompass/carecompass.config.json
@@ -226,7 +571,7 @@ npx @nexalink/carecompass-sdk validate --local-only --config carecompass/carecom
226
571
 
227
572
  ### `snippet`
228
573
 
229
- Regenerates the HTML embed snippet after config, branding, origin, or prompt changes. `init` already runs this once.
574
+ Regenerates embed HTML after config, branding, origin, or prompt changes.
230
575
 
231
576
  ```bash
232
577
  npx @nexalink/carecompass-sdk snippet --config carecompass/carecompass.config.json
@@ -235,36 +580,42 @@ npx @nexalink/carecompass-sdk snippet --snippet-mode cdn --config carecompass/ca
235
580
 
236
581
  ### `doctor`
237
582
 
238
- Prints a deployment readiness summary for the selected config.
583
+ Prints a deployment readiness summary.
239
584
 
240
585
  ```bash
241
586
  npx @nexalink/carecompass-sdk doctor --config carecompass/carecompass.config.json
242
587
  ```
243
588
 
244
- ## Security and Compliance Model
589
+ ## Security And Compliance Positioning
245
590
 
246
- CareCompass is BAA-gated where PHI may be involved and HIPAA-oriented for regulated healthcare deployment workflows, but this README does not claim blanket HIPAA compliance for every implementation or deployment.
591
+ CareCompass is BAA-gated where PHI may be involved and built for regulated healthcare workflows, but this README does not claim blanket HIPAA compliance for every implementation or deployment.
247
592
 
248
- The SDK keeps secret keys out of the browser. Browser code receives public embed configuration only. Staging and production `apiBaseUrl` values must be Nexalink-hosted HTTPS URLs; `localhost` is accepted only for `development`.
593
+ The SDK is designed to keep sensitive operational details out of the browser:
249
594
 
250
- Nexalink-hosted API routes are responsible for authorization, origin allowlists, tenant isolation, prompt guardrails, rate limiting, request attribution, and usage tracking. Generated snippets escape serialized config, and React renders chat messages and labels as text.
595
+ - no secret API keys in frontend config
596
+ - no model endpoint credentials in browser code
597
+ - no customer-managed telemetry switches in runtime config
598
+ - no prompt, response, chat history, user context, PHI/PII, payer, tenant, deployment, session, or user identifiers, credentials, raw errors, stack traces, CLI arguments, terminal input, or file paths in SDK telemetry
599
+ - generated snippets escape serialized config
600
+ - default React rendering escapes raw HTML
251
601
 
252
- Telemetry is enabled automatically with Nexalink-managed defaults. The SDK sends only allowlisted anonymous deployment-health events to PostHog's public ingestion API. It does not bundle `posthog-js`, enable session replay or autocapture, identify users, set cookies, or persist analytics state. Prompts, responses, chat history, user context, PHI/PII, credentials, raw errors, stack traces, CLI arguments, terminal input, and file paths are excluded from telemetry.
602
+ Telemetry is enabled with Nexalink-managed defaults and sends only allowlisted anonymous deployment-health events.
253
603
 
254
604
  ## Runtime Notes
255
605
 
256
- Some development and MVP environments may use scale-to-zero infrastructure, which can add cold-start latency to the first request after an idle period. The request still routes through Nexalink-hosted APIs; the browser embed does not receive infrastructure credentials or call the model endpoint directly.
606
+ Some development and MVP environments may use scale-to-zero infrastructure, which can add cold-start latency to the first request after an idle period.
607
+
608
+ Requests still route through Nexalink-hosted APIs. The browser embed does not receive infrastructure credentials or call model endpoints directly.
257
609
 
258
610
  ## Troubleshooting
259
611
 
260
612
  - `Missing Nexalink API key`: run `init`, choose Developer, and sign in. For scripts, pass `--account-type developer` with `--api-key <key>`, or set `CARECOMPASS_API_KEY` with `CARECOMPASS_ACCOUNT_TYPE=developer`.
261
613
  - `zsh: command not found: carecompass`: `npx` does not install a permanent command. Run `npx @nexalink/carecompass-sdk <command>` or install the package.
262
- - `@parcel/core: Failed to resolve 'https://esm.sh/...'`: regenerate with bundler mode: `npx @nexalink/carecompass-sdk snippet --config carecompass/carecompass.config.json`. CDN mode is for raw browser HTML.
263
- - `CareCompass could not reach http://localhost:3000`: hosted sandboxes cannot reach your machine's `localhost`. Test locally or use a deployed Nexalink `apiBaseUrl`. Run `validate` before typing into the embed.
264
- - `Origin is not authorized`: add the exact website origin to the Nexalink portal SDK configuration.
614
+ - `@parcel/core: Failed to resolve 'https://esm.sh/...'`: regenerate with bundler mode. CDN mode is for raw browser HTML.
615
+ - `CareCompass could not reach http://localhost:3000`: hosted sandboxes cannot reach your machine's `localhost`. Test locally or use a deployed Nexalink `apiBaseUrl`.
616
+ - `Origin is not authorized`: add the exact website origin to the Nexalink SDK configuration.
265
617
  - `Prompt configuration violates CareCompass guardrails`: remove unsafe or unsupported instructions and re-run validation.
266
- - `CareCompass embed client is not authorized`: confirm `payerId`, `embedKey`, `environment`, and allowed origins match the key issued in the Nexalink portal.
267
- - `CareCompass AppSync inference service is not configured`: Nexalink server operators should confirm `NEXT_PUBLIC_API_URL` or `CARECOMPASS_APPSYNC_URL`. The embed does not require a payer-provided LLM URL.
618
+ - `CareCompass embed client is not authorized`: confirm `payerId`, `embedKey`, `environment`, and allowed origins match the key issued for the deployment.
268
619
 
269
620
  ## License
270
621