@netwatchai/chat 0.1.0 → 0.1.1

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,6 +1,16 @@
1
1
  # Netwatch Widget
2
2
 
3
- An AI-powered monitoring assistant widget built as a Web Component. Embed it anywhere to add intelligent monitoring capabilities.
3
+ An AI-powered monitoring assistant shipped as a self-contained Web Component
4
+ (Shadow DOM — styles are fully isolated from the host page). Drop in one script
5
+ tag to add a chat bubble to any page.
6
+
7
+ Published to npm as **`@netwatchai/chat`** and served over jsDelivr:
8
+
9
+ ```
10
+ https://cdn.jsdelivr.net/npm/@netwatchai/chat@latest/lib/web.min.js
11
+ ```
12
+
13
+ (Pin a version with `@0.1.0` instead of `@latest` for stability.)
4
14
 
5
15
  ## Features
6
16
 
@@ -12,51 +22,75 @@ An AI-powered monitoring assistant widget built as a Web Component. Embed it any
12
22
  - 🌙 Dark mode support
13
23
  - 📦 Distributable via CDN
14
24
 
15
- ## Installation
16
-
17
- ### From npm
25
+ ## Embedding
18
26
 
19
- ```bash
20
- npm install agentic-netwatch-widget
21
- ```
27
+ Two equivalent ways — both load the single bundle from jsDelivr.
22
28
 
23
- ### From CDN
29
+ ### 1. Declarative (custom element)
24
30
 
25
31
  ```html
26
- <netwatch-widget
27
- api-endpoint="http://your-api.com"
28
- client-id="your-client-id"
29
- username="your-username"
30
- ></netwatch-widget>
32
+ <script type="module"
33
+ src="https://cdn.jsdelivr.net/npm/@netwatchai/chat@latest/lib/web.min.js"></script>
31
34
 
32
- <script src="https://cdn.jsdelivr.net/npm/agentic-netwatch-widget"></script>
35
+ <netwatch-widget
36
+ client-id="b48ea317-…"
37
+ api-endpoint="http://your-api:8000">
38
+ </netwatch-widget>
33
39
  ```
34
40
 
35
- ## Usage
36
-
37
- ### Basic Setup
41
+ ### 2. Programmatic (one-liner — PHP / CMS friendly)
38
42
 
39
43
  ```html
40
- <netwatch-widget
41
- api-endpoint="http://localhost:8000"
42
- client-id="demo-client"
43
- username="demo-user"
44
- ></netwatch-widget>
45
-
46
44
  <script type="module">
47
- import NetwatchWidget from 'agentic-netwatch-widget'
45
+ import NetwatchChat from "https://cdn.jsdelivr.net/npm/@netwatchai/chat@latest/lib/web.min.js";
46
+ NetwatchChat.initBubble({
47
+ clientId: "b48ea317-…",
48
+ apiHost: "http://your-api:8000",
49
+ });
48
50
  </script>
49
51
  ```
50
52
 
51
- ### Attributes
53
+ ### Options
52
54
 
53
- - `api-endpoint` (required): Backend API endpoint URL
54
- - `client-id` (required): Client identifier for the monitoring instance
55
- - `username` (required): Username for authentication
55
+ | Attribute | `initBubble` key | Required | Notes |
56
+ |----------------|-----------------------|----------|-------|
57
+ | `client-id` | `clientId` | yes | Netwatch client UUID |
58
+ | `api-endpoint` | `apiHost` / `apiEndpoint` | yes | API base URL (a trailing `/api/chat` is stripped automatically) |
59
+ | `username` | `username` | no | **Auto-resolved** from the host page's localStorage when embedded in the Netwatch UI. Pass explicitly to override, or when embedding on other hosts. |
56
60
 
57
- ## Development
61
+ ## Embedding in the Netwatch monitoring UI
62
+
63
+ The widget auto-reads the logged-in user from the host page's localStorage, so
64
+ it only needs its script injected on every (logged-in) page. The UI has no
65
+ built-in custom-JS setting, so use one of:
58
66
 
59
- ### Setup
67
+ **Option A — reverse proxy injection (recommended, survives upgrades).** With
68
+ nginx in front of the frontend:
69
+
70
+ ```nginx
71
+ location / {
72
+ proxy_pass http://frontend-upstream;
73
+ proxy_set_header Accept-Encoding ""; # sub_filter needs uncompressed HTML
74
+ sub_filter_once on;
75
+ sub_filter_types text/html;
76
+ sub_filter '</body>'
77
+ '<script type="module">import N from "https://cdn.jsdelivr.net/npm/@netwatchai/chat@latest/lib/web.min.js";N.initBubble({clientId:"b48ea317-…",apiHost:"http://your-api:8000"});</script></body>';
78
+ }
79
+ ```
80
+
81
+ **Option B — edit the frontend's page layout template** (`ui/include/views/layout.htmlpage.php`),
82
+ just before the `</body>` output. ⚠️ This is overwritten on every upgrade, so
83
+ reapply it after upgrading:
84
+
85
+ ```php
86
+ echo '<script type="module">import N from "https://cdn.jsdelivr.net/npm/@netwatchai/chat@latest/lib/web.min.js";N.initBubble({clientId:"b48ea317-…",apiHost:"http://your-api:8000"});</script>';
87
+ ```
88
+
89
+ > ⚠️ **Mixed content:** if the UI is served over HTTPS but `api-endpoint` is
90
+ > `http://…`, browsers silently block the API calls. Serve the API over HTTPS
91
+ > too, or keep both on plain HTTP within a private network/tunnel.
92
+
93
+ ## Development
60
94
 
61
95
  ```bash
62
96
  pnpm install
@@ -81,7 +115,8 @@ Start the dev server:
81
115
  pnpm run dev
82
116
  ```
83
117
 
84
- Visit `http://localhost:5173` to see the test page with the widget. It reads the env vars via `src/config.js` and instantiates the widget automatically.
118
+ Visit `http://localhost:5173` for the test page; it reads the env vars via
119
+ `src/config.js` and mounts the widget automatically.
85
120
 
86
121
  ### Build
87
122
 
@@ -89,43 +124,49 @@ Visit `http://localhost:5173` to see the test page with the widget. It reads the
89
124
  pnpm run build
90
125
  ```
91
126
 
92
- This generates:
93
- - `dist/netwatch-widget.umd.js` - Universal Module Definition (for direct script tags)
94
- - `dist/netwatch-widget.es.js` - ES Module (for npm)
127
+ Outputs to `lib/` (the `@latest/lib/web.min.js` jsDelivr path):
95
128
 
96
- ### Testing
129
+ - `lib/web.min.js` — ES module (modern `<script type="module">` / npm import)
130
+ - `lib/web.umd.js` — UMD build (legacy `<script>` tag → `window.NetwatchChat`)
97
131
 
98
- The widget is automatically loaded in `index.html` during development. Customize the attributes to test different configurations.
132
+ ## Publishing
99
133
 
100
- ## Architecture
134
+ Published to npm as `@netwatchai/chat` by `.github/workflows/widget-publish.yml`
135
+ (changesets-driven). Normal flow:
101
136
 
102
- The widget uses:
103
- - **Web Components** - Native browser API for encapsulation
104
- - **Shadow DOM** - Complete style isolation from parent page
105
- - **React** - Internal rendering framework
106
- - **Vercel AI SDK** - Streaming chat interface
107
- - **Tailwind CSS** - Utility-first styling
108
- - **Streamdown** - Markdown rendering
137
+ 1. Add a changeset describing your change:
109
138
 
110
- ## Building for CDN
139
+ ```bash
140
+ pnpm changeset # pick the bump, write a summary
141
+ ```
111
142
 
112
- The build outputs are ready for CDN distribution:
143
+ The summary becomes the public `CHANGELOG.md` keep it in Netwatch terms.
144
+ 2. Commit the `.changeset/*.md` and push to `main`.
113
145
 
114
- ```bash
115
- # Build the widget
116
- pnpm run build
146
+ > **Org caveat:** this GitHub org currently disallows Actions creating pull
147
+ > requests, so the changesets bot can't open the "Version Packages" PR. Until
148
+ > that's enabled (or Trusted Publishing is set up), do the version bump locally
149
+ > instead of relying on the bot:
150
+ >
151
+ > ```bash
152
+ > pnpm run version-packages # bumps package.json + CHANGELOG, consumes changesets
153
+ > git commit -am "widget: version" && git push origin main
154
+ > ```
155
+ >
156
+ > With no changesets left, the workflow's publish step runs `changeset publish`.
117
157
 
118
- # The UMD build can be used via script tag
119
- # The ES build can be installed via npm and imported
120
- ```
158
+ Requires repo secret **`NPM_TOKEN`** a *granular* npm token with **"Bypass
159
+ two-factor authentication (2FA)" checked** and read/write on the `@netwatchai`
160
+ scope (a token without the 2FA bypass fails publish with `EOTP`).
121
161
 
122
- ## Publishing to npm
162
+ ## Architecture
123
163
 
124
- ```bash
125
- # Update version in package.json
126
- # Then:
127
- pnpm publish
128
- ```
164
+ - **Web Components** — native browser API for encapsulation
165
+ - **Shadow DOM** complete style isolation from the parent page
166
+ - **React** — internal rendering framework
167
+ - **Vercel AI SDK** — streaming chat interface
168
+ - **Tailwind CSS** — utility-first styling
169
+ - **Streamdown** — markdown rendering
129
170
 
130
171
  ## License
131
172