@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 +479 -128
- package/dist/cli.js +185 -32
- package/dist/client.d.ts +32 -2
- package/dist/client.js +42 -3
- package/dist/compliance.d.ts +69 -0
- package/dist/compliance.js +121 -0
- package/dist/component.d.ts +32 -2
- package/dist/component.js +117 -56
- package/dist/core.d.ts +95 -0
- package/dist/core.js +352 -0
- package/dist/index.d.ts +13 -4
- package/dist/index.js +6 -2
- package/dist/markdown.d.ts +4 -0
- package/dist/markdown.js +183 -0
- package/dist/mount.d.ts +4 -1
- package/dist/mount.js +2 -2
- package/dist/rcm.d.ts +93 -0
- package/dist/rcm.js +284 -0
- package/dist/react.d.ts +2 -0
- package/dist/react.js +1 -0
- package/dist/schema.d.ts +49 -0
- package/dist/schema.js +36 -0
- package/dist/telemetry.js +114 -82
- package/dist/ui.d.ts +3 -0
- package/dist/ui.js +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +2 -2
- package/dist/web-component.d.ts +13 -0
- package/dist/web-component.js +236 -0
- package/package.json +43 -12
- package/qa-fixtures/DEMO-ENC-1042-rcm-policy.md +27 -0
package/README.md
CHANGED
|
@@ -1,141 +1,358 @@
|
|
|
1
|
-
# CareCompass
|
|
1
|
+
# CareCompass SDK
|
|
2
2
|
|
|
3
|
-
CareCompass
|
|
3
|
+
CareCompass is embeddable healthcare AI infrastructure for teams building AI-powered healthcare products.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
16
|
+
## Why Teams Choose CareCompass
|
|
27
17
|
|
|
28
|
-
|
|
18
|
+
Healthcare teams can already access foundation models. The hard part is turning those models into production-ready healthcare software.
|
|
29
19
|
|
|
30
|
-
|
|
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
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
-
|
|
46
|
-
- Tenant
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
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
|
-
##
|
|
66
|
+
## SDK Architecture
|
|
54
67
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
88
|
+
### 1. Headless Core
|
|
73
89
|
|
|
74
|
-
|
|
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
|
-
|
|
92
|
+
The core manages:
|
|
80
93
|
|
|
81
|
-
|
|
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
|
-
```
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
135
|
+
Use the UI kit when you want a fast branded AI interface with minimal setup.
|
|
98
136
|
|
|
99
|
-
|
|
137
|
+
```tsx
|
|
138
|
+
import { CareCompassChat } from "@nexalink/carecompass-sdk/ui";
|
|
139
|
+
import config from "./carecompass/carecompass.config.json";
|
|
100
140
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
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
|
-
|
|
324
|
+
### 6. Iframe Fallback
|
|
114
325
|
|
|
115
|
-
|
|
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
|
-
|
|
330
|
+
```ts
|
|
331
|
+
import { generateCareCompassIframeSnippet } from "@nexalink/carecompass-sdk";
|
|
118
332
|
|
|
119
|
-
|
|
333
|
+
const html = generateCareCompassIframeSnippet(config, {
|
|
334
|
+
src: "/carecompass/carecompass-embed.html",
|
|
335
|
+
});
|
|
336
|
+
```
|
|
120
337
|
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
343
|
+
### 7. Existing Embed Compatibility
|
|
125
344
|
|
|
126
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
`
|
|
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://
|
|
429
|
+
"allowedOrigins": ["https://app.acme-health.com"],
|
|
157
430
|
"branding": {
|
|
158
431
|
"displayName": "Acme Health",
|
|
159
|
-
"logoUrl": "https://
|
|
160
|
-
"supportUrl": "https://
|
|
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
|
|
171
|
-
"placeholder": "Ask about
|
|
443
|
+
"title": "Acme AI Assistant",
|
|
444
|
+
"placeholder": "Ask about this workflow...",
|
|
172
445
|
"sendButton": "Send",
|
|
173
|
-
"disclaimer": "
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
```
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
-
|
|
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
|
-
|
|
551
|
+
Creates the local setup kit, validates credentials, stores the API key locally, and generates starter config and embed assets.
|
|
208
552
|
|
|
209
|
-
|
|
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
|
-
|
|
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 --
|
|
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
|
|
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
|
|
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
|
|
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
|
|
589
|
+
## Security And Compliance Positioning
|
|
245
590
|
|
|
246
|
-
CareCompass is BAA-gated where PHI may be involved and
|
|
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
|
|
593
|
+
The SDK is designed to keep sensitive operational details out of the browser:
|
|
249
594
|
|
|
250
|
-
|
|
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
|
|
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.
|
|
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
|
|
263
|
-
- `CareCompass could not reach http://localhost:3000`: hosted sandboxes cannot reach your machine's `localhost`. Test locally or use a deployed Nexalink `apiBaseUrl`.
|
|
264
|
-
- `Origin is not authorized`: add the exact website origin to the Nexalink
|
|
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
|
|
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
|
|