nivq-chat-widget 1.0.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 ADDED
@@ -0,0 +1,95 @@
1
+ # nivq-chat-widget
2
+
3
+ Embeddable NivQ chat experience as a framework-agnostic Web Component
4
+ (`<nivq-chat>`). Drop it into any site — plain HTML, React, Angular, Vue — with
5
+ one tag and get the NivQ chat UI in a floating launcher (FAB) or inline panel.
6
+
7
+ - **Style-isolated** — renders in a Shadow DOM; no CSS bleed in either direction.
8
+ - **Secret-safe** — never touches your OAuth2 `clientSecret`. It fetches a
9
+ short-lived token from your own token-broker endpoint. See
10
+ [`docs/integration.md`](docs/integration.md).
11
+ - **Themeable** — defaults to the NivQ brand; override palette, logo, radius.
12
+ - **Lazy charts** — the Vega rendering stack loads only when a turn returns a chart.
13
+
14
+ ## Quick start
15
+
16
+ ```html
17
+ <script type="module" src="https://cdn.jsdelivr.net/npm/nivq-chat-widget@1/dist/nivq-chat.js"></script>
18
+ <nivq-chat
19
+ agent-id="YOUR_AGENT_ID"
20
+ api-base-url="https://api.nivq.ai"
21
+ token-endpoint="/nivq-token">
22
+ </nivq-chat>
23
+ ```
24
+
25
+ You must run a small **token broker** on your backend (≈20 lines) so the secret
26
+ never reaches the browser. Full guide + Node/Spring examples:
27
+ [`docs/integration.md`](docs/integration.md).
28
+
29
+ ## Develop
30
+
31
+ ```bash
32
+ bun install
33
+
34
+ # 1. Run the mock token broker against a NivQ backend + a dev API client:
35
+ NIVQ_API_BASE=http://localhost:8080 \
36
+ NIVQ_CLIENT_ID=nivq_… NIVQ_CLIENT_SECRET=… \
37
+ bun run broker
38
+
39
+ # 2. Run the dev harness, then fill in agent id + endpoints and click Mount:
40
+ bun run dev
41
+
42
+ bun run build # → dist/nivq-chat.js (+ lazy chart chunk)
43
+ bun run type-check
44
+ ```
45
+
46
+ ## Architecture
47
+
48
+ ```
49
+ <nivq-chat> (custom element, src/element.ts)
50
+ └─ Shadow DOM + injected Tailwind stylesheet (tokens scoped to :host)
51
+ └─ React root (src/Widget.tsx) — FAB or inline
52
+ ├─ TokenProvider (src/auth) — fetches/caches the broker token
53
+ ├─ useWidgetChat (src/chat) — SSE streaming, ephemeral/local state
54
+ └─ chat UI (src/chat) — forked from nivq-web-client
55
+ ```
56
+
57
+ Presentational chat components are forked from `nivq-web-client`; a shared
58
+ `nivq-chat-ui` package is a possible future consolidation.
59
+
60
+ ## Publish (maintainers)
61
+
62
+ Published to npm; the CDN URL is served straight from npm by jsDelivr — one
63
+ publish covers both `npm i` and `<script>` consumers.
64
+
65
+ ### CI release (recommended)
66
+
67
+ `.github/workflows/release.yml` publishes automatically when a `v*` tag is
68
+ pushed. The flow:
69
+
70
+ ```bash
71
+ npm version <patch|minor|major> # bumps package.json + creates tag vX.Y.Z
72
+ git push --follow-tags # CI builds (via prepublishOnly) and publishes
73
+ ```
74
+
75
+ One-time setup: add repo secret **`NPM_TOKEN`** (npm automation token with
76
+ publish rights for the `nivq-chat-widget` package) under Settings → Secrets and variables →
77
+ Actions. `.github/workflows/ci.yml` runs type-check + build on every push/PR.
78
+
79
+ ### Manual publish (fallback)
80
+
81
+ ```bash
82
+ npm login # your npm account with publish rights
83
+ npm publish # prepublishOnly runs the build automatically
84
+ ```
85
+
86
+ After publish the CDN URL is live immediately:
87
+
88
+ ```
89
+ https://cdn.jsdelivr.net/npm/nivq-chat-widget@1/dist/nivq-chat.js
90
+ ```
91
+
92
+ `files: ["dist"]` ships only the build output (entry + chunks + `nivq-chat.d.ts`).
93
+ Tell customers to pin the major (`@1`) — they get patches/minors, never breaking
94
+ changes. Every release bumps `version` (immutable, long-cached URLs); the entry
95
+ imports its chunks by relative path, so all `dist/*` files publish together.