@primexperts.co/pulse-agent 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 PrimExperts
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # @primexperts/pulse-agent
2
+
3
+ Embeddable floating Pulse chat widget for client websites.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @primexperts/pulse-agent
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { createPulseAgent } from '@primexperts/pulse-agent';
15
+
16
+ const agent = createPulseAgent({
17
+ slug: 'client-abc',
18
+ apiBaseUrl: 'https://api.pulsecrm.com',
19
+ requireProfile: true,
20
+ autoOpen: false
21
+ });
22
+
23
+ // optional
24
+ agent.open();
25
+ ```
26
+
27
+ ## Browser/CDN Usage (No Bundler)
28
+
29
+ ```html
30
+ <script src="https://unpkg.com/@primexperts/pulse-agent/dist/browser/pulse-agent.global.js"></script>
31
+ <script>
32
+ const agent = window.PulseAgent.createPulseAgent({
33
+ slug: 'client-abc',
34
+ apiBaseUrl: 'https://api.pulsecrm.com'
35
+ });
36
+ </script>
37
+ ```
38
+
39
+ ## Required Backend Endpoints
40
+
41
+ - `GET /api/pulse/public/webchat/resolve?slug=<slug>`
42
+ - `POST /api/pulse/public/webchat/{widgetToken}/message`
43
+ - `GET /api/pulse/public/webchat/{widgetToken}/stream?conversationId=<id>`
44
+
45
+ ## API
46
+
47
+ ### `createPulseAgent(options)`
48
+
49
+ Options:
50
+ - `slug` (required): public organization slug.
51
+ - `apiBaseUrl` (optional): defaults to `http://localhost:9091`.
52
+ - `mount` (optional): container element or selector, defaults to `document.body`.
53
+ - `autoOpen` (optional): open panel immediately.
54
+ - `requireProfile` (optional): requires name/email before first message, default `true`.
55
+ - `widgetToken` (optional): bypass slug resolution.
56
+ - `title` (optional): panel title.
57
+
58
+ Returns `PulseAgentHandle`:
59
+ - `open()`
60
+ - `close()`
61
+ - `destroy()`
62
+ - `update(partialOptions)`
63
+
64
+ ## Notes
65
+
66
+ - This package is framework-agnostic and browser-only.
67
+ - No dashboard/auth code is included in this project.
68
+ - `npm run build` now outputs:
69
+ - ESM + type declarations in `dist/`
70
+ - browser global bundle in `dist/browser/pulse-agent.global.js`
@@ -0,0 +1,279 @@
1
+ const DEFAULT_API_BASE_URL = 'http://localhost:9091';
2
+ const STYLE_ID = 'pulse-agent-widget-style';
3
+ function createPulseAgent(options) {
4
+ assertBrowser();
5
+ const state = createState(options);
6
+ ensureStyle();
7
+ const mountRoot = resolveMount(state.options.mount);
8
+ const root = document.createElement('section');
9
+ root.className = 'pulse-agent-root';
10
+ root.innerHTML = template(state.options.title ?? 'Pulse Support');
11
+ mountRoot.appendChild(root);
12
+ const button = root.querySelector('[data-role="toggle"]');
13
+ const panel = root.querySelector('[data-role="panel"]');
14
+ const closeBtn = root.querySelector('[data-role="close"]');
15
+ const log = root.querySelector('[data-role="log"]');
16
+ const prechat = root.querySelector('[data-role="prechat"]');
17
+ const nameInput = root.querySelector('[data-role="name"]');
18
+ const emailInput = root.querySelector('[data-role="email"]');
19
+ const continueBtn = root.querySelector('[data-role="continue"]');
20
+ const textarea = root.querySelector('[data-role="message"]');
21
+ const sendBtn = root.querySelector('[data-role="send"]');
22
+ pushMessage(state, log, { role: 'system', content: 'Welcome to Pulse. Send us a message.' });
23
+ button.addEventListener('click', () => toggle(panel, state));
24
+ closeBtn.addEventListener('click', () => close(panel, state));
25
+ continueBtn.addEventListener('click', () => {
26
+ const name = nameInput.value.trim();
27
+ const email = emailInput.value.trim();
28
+ if (!name || !email) {
29
+ pushMessage(state, log, { role: 'system', content: 'Name and email are required before chat starts.' });
30
+ return;
31
+ }
32
+ state.profile = { name, email };
33
+ prechat.classList.add('hidden');
34
+ });
35
+ sendBtn.addEventListener('click', async () => {
36
+ const text = textarea.value.trim();
37
+ if (!text || state.sending) {
38
+ return;
39
+ }
40
+ if (state.options.requireProfile !== false && !state.profile) {
41
+ pushMessage(state, log, { role: 'system', content: 'Complete profile first.' });
42
+ return;
43
+ }
44
+ if (!state.widgetToken) {
45
+ await resolveWidgetToken(state, log);
46
+ if (!state.widgetToken) {
47
+ return;
48
+ }
49
+ }
50
+ state.sending = true;
51
+ sendBtn.disabled = true;
52
+ pushMessage(state, log, { role: 'visitor', content: text });
53
+ textarea.value = '';
54
+ try {
55
+ const payload = state.profile
56
+ ? { message: text, name: state.profile.name, email: state.profile.email }
57
+ : { message: text };
58
+ const res = await fetch(`${trimSlash(state.options.apiBaseUrl)}/api/pulse/public/webchat/${state.widgetToken}/message`, {
59
+ method: 'POST',
60
+ headers: { 'Content-Type': 'application/json' },
61
+ body: JSON.stringify(payload)
62
+ });
63
+ if (!res.ok) {
64
+ throw new Error(`Failed to send message (${res.status})`);
65
+ }
66
+ const body = (await res.json());
67
+ const conversationId = body.conversationId ?? body.id;
68
+ if (!conversationId) {
69
+ pushMessage(state, log, { role: 'system', content: 'Message sent but conversation ID was missing.' });
70
+ }
71
+ else if (!state.conversationId) {
72
+ state.conversationId = conversationId;
73
+ connectStream(state, log);
74
+ }
75
+ }
76
+ catch (error) {
77
+ const message = error instanceof Error ? error.message : 'Message failed.';
78
+ pushMessage(state, log, { role: 'system', content: message });
79
+ }
80
+ finally {
81
+ state.sending = false;
82
+ sendBtn.disabled = false;
83
+ }
84
+ });
85
+ resolveWidgetToken(state, log).then(() => {
86
+ if (state.options.autoOpen) {
87
+ open(panel, state);
88
+ }
89
+ if (state.options.requireProfile === false) {
90
+ prechat.classList.add('hidden');
91
+ }
92
+ });
93
+ return {
94
+ open: () => open(panel, state),
95
+ close: () => close(panel, state),
96
+ destroy: () => {
97
+ if (state.stream) {
98
+ state.stream.close();
99
+ }
100
+ root.remove();
101
+ },
102
+ update: (partial) => {
103
+ state.options = normalizeOptions({ ...state.options, ...partial });
104
+ if (partial.widgetToken) {
105
+ state.widgetToken = partial.widgetToken;
106
+ }
107
+ }
108
+ };
109
+ }
110
+ function template(title) {
111
+ return `
112
+ <button class="pulse-agent-fab" data-role="toggle" aria-label="Open Pulse chat">P</button>
113
+ <div class="pulse-agent-panel hidden" data-role="panel" aria-live="polite">
114
+ <header class="pulse-agent-header">
115
+ <strong>${escapeHtml(title)}</strong>
116
+ <button class="pulse-agent-close" data-role="close">Close</button>
117
+ </header>
118
+ <div class="pulse-agent-log" data-role="log"></div>
119
+ <div class="pulse-agent-compose">
120
+ <div class="pulse-agent-prechat" data-role="prechat">
121
+ <input data-role="name" type="text" placeholder="Your name" />
122
+ <input data-role="email" type="email" placeholder="Work email" />
123
+ <button data-role="continue">Continue</button>
124
+ </div>
125
+ <textarea data-role="message" rows="3" placeholder="How can we help?"></textarea>
126
+ <button data-role="send">Send</button>
127
+ </div>
128
+ </div>`;
129
+ }
130
+ function ensureStyle() {
131
+ if (document.getElementById(STYLE_ID)) {
132
+ return;
133
+ }
134
+ const style = document.createElement('style');
135
+ style.id = STYLE_ID;
136
+ style.textContent = `
137
+ .pulse-agent-root { position: fixed; right: 16px; bottom: 16px; z-index: 9999; font-family: Arial, sans-serif; }
138
+ .pulse-agent-fab { width: 56px; height: 56px; border-radius: 999px; border: 0; background: #1d4ed8; color: #fff; font-weight: 700; cursor: pointer; box-shadow: 0 10px 26px rgba(30,64,175,.35); }
139
+ .pulse-agent-panel { position: absolute; right: 0; bottom: 66px; width: min(380px, calc(100vw - 24px)); height: 540px; background: #fff; border: 1px solid #cbd5e1; border-radius: 14px; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; box-shadow: 0 18px 42px rgba(0,0,0,.2); }
140
+ .pulse-agent-panel.hidden { display: none; }
141
+ .pulse-agent-header { display: flex; justify-content: space-between; align-items: center; background: #0f172a; color: #fff; padding: 10px 12px; }
142
+ .pulse-agent-close { border: 0; border-radius: 6px; padding: 4px 8px; cursor: pointer; }
143
+ .pulse-agent-log { padding: 12px; display: grid; align-content: start; gap: 8px; background: #f8fafc; overflow: auto; }
144
+ .pulse-agent-bubble { max-width: 85%; padding: 8px 10px; border-radius: 10px; line-height: 1.35; white-space: pre-wrap; font-size: 14px; }
145
+ .pulse-agent-bubble.visitor { justify-self: end; background: #dbeafe; color: #1e3a8a; }
146
+ .pulse-agent-bubble.agent { justify-self: start; background: #e2e8f0; color: #111827; }
147
+ .pulse-agent-bubble.system { justify-self: center; background: #fef9c3; color: #854d0e; }
148
+ .pulse-agent-compose { border-top: 1px solid #dbe2ea; padding: 10px; display: grid; gap: 8px; }
149
+ .pulse-agent-prechat { display: grid; gap: 6px; }
150
+ .pulse-agent-prechat.hidden { display: none; }
151
+ .pulse-agent-compose textarea, .pulse-agent-prechat input { width: 100%; box-sizing: border-box; border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px; font: inherit; }
152
+ .pulse-agent-compose button, .pulse-agent-prechat button { border: 0; border-radius: 8px; padding: 8px 10px; background: #1d4ed8; color: #fff; cursor: pointer; }
153
+ `;
154
+ document.head.appendChild(style);
155
+ }
156
+ function createState(options) {
157
+ const normalized = normalizeOptions(options);
158
+ return {
159
+ options: normalized,
160
+ widgetToken: normalized.widgetToken?.trim() || null,
161
+ profile: null,
162
+ conversationId: null,
163
+ stream: null,
164
+ messages: [],
165
+ opened: false,
166
+ sending: false
167
+ };
168
+ }
169
+ function normalizeOptions(options) {
170
+ if (!options.slug?.trim()) {
171
+ throw new Error('PulseAgent: options.slug is required.');
172
+ }
173
+ return {
174
+ ...options,
175
+ slug: options.slug.trim(),
176
+ apiBaseUrl: options.apiBaseUrl?.trim() || DEFAULT_API_BASE_URL,
177
+ autoOpen: options.autoOpen === true,
178
+ requireProfile: options.requireProfile !== false
179
+ };
180
+ }
181
+ function resolveMount(mount) {
182
+ if (!mount) {
183
+ return document.body;
184
+ }
185
+ if (typeof mount === 'string') {
186
+ const node = document.querySelector(mount);
187
+ if (!node) {
188
+ throw new Error(`PulseAgent: mount selector not found: ${mount}`);
189
+ }
190
+ return node;
191
+ }
192
+ return mount;
193
+ }
194
+ async function resolveWidgetToken(state, log) {
195
+ if (state.widgetToken) {
196
+ return;
197
+ }
198
+ try {
199
+ const url = `${trimSlash(state.options.apiBaseUrl)}/api/pulse/public/webchat/resolve?slug=${encodeURIComponent(state.options.slug)}`;
200
+ const res = await fetch(url);
201
+ if (!res.ok) {
202
+ throw new Error(`Widget not configured for slug "${state.options.slug}".`);
203
+ }
204
+ const body = (await res.json());
205
+ state.widgetToken = body.widgetToken;
206
+ pushMessage(state, log, { role: 'system', content: `Connected to ${body.organizationName}.` });
207
+ }
208
+ catch (error) {
209
+ const message = error instanceof Error ? error.message : 'Failed to resolve widget token.';
210
+ pushMessage(state, log, { role: 'system', content: message });
211
+ }
212
+ }
213
+ function connectStream(state, log) {
214
+ if (!state.widgetToken || !state.conversationId) {
215
+ return;
216
+ }
217
+ state.stream?.close();
218
+ const streamUrl = `${trimSlash(state.options.apiBaseUrl)}/api/pulse/public/webchat/${state.widgetToken}/stream?conversationId=${encodeURIComponent(state.conversationId)}`;
219
+ const stream = new EventSource(streamUrl);
220
+ state.stream = stream;
221
+ stream.onmessage = (event) => {
222
+ try {
223
+ const payload = JSON.parse(event.data);
224
+ if (payload.senderType === 'USER' && payload.content?.trim()) {
225
+ pushMessage(state, log, { role: 'agent', content: payload.content });
226
+ }
227
+ }
228
+ catch {
229
+ return;
230
+ }
231
+ };
232
+ stream.onerror = () => {
233
+ stream.close();
234
+ state.stream = null;
235
+ };
236
+ }
237
+ function pushMessage(state, log, message) {
238
+ state.messages.push(message);
239
+ const bubble = document.createElement('div');
240
+ bubble.className = `pulse-agent-bubble ${message.role}`;
241
+ bubble.textContent = message.content;
242
+ log.appendChild(bubble);
243
+ log.scrollTop = log.scrollHeight;
244
+ }
245
+ function toggle(panel, state) {
246
+ if (state.opened) {
247
+ close(panel, state);
248
+ }
249
+ else {
250
+ open(panel, state);
251
+ }
252
+ }
253
+ function open(panel, state) {
254
+ panel.classList.remove('hidden');
255
+ state.opened = true;
256
+ }
257
+ function close(panel, state) {
258
+ panel.classList.add('hidden');
259
+ state.opened = false;
260
+ }
261
+ function trimSlash(value) {
262
+ return value.replace(/\/+$/, '');
263
+ }
264
+ function assertBrowser() {
265
+ if (typeof window === 'undefined' || typeof document === 'undefined') {
266
+ throw new Error('PulseAgent: browser environment required.');
267
+ }
268
+ }
269
+ function escapeHtml(input) {
270
+ return input
271
+ .replace(/&/g, '&amp;')
272
+ .replace(/</g, '&lt;')
273
+ .replace(/>/g, '&gt;')
274
+ .replace(/"/g, '&quot;')
275
+ .replace(/'/g, '&#39;');
276
+ }
277
+ //# sourceMappingURL=pulse-agent.js.map
278
+ window.PulseAgent = window.PulseAgent || {};
279
+ window.PulseAgent.createPulseAgent = createPulseAgent;
@@ -0,0 +1,2 @@
1
+ export * from './widget/pulse-agent';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './widget/pulse-agent';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,17 @@
1
+ export interface PulseAgentOptions {
2
+ slug: string;
3
+ apiBaseUrl?: string;
4
+ mount?: HTMLElement | string;
5
+ autoOpen?: boolean;
6
+ requireProfile?: boolean;
7
+ widgetToken?: string;
8
+ title?: string;
9
+ }
10
+ export interface PulseAgentHandle {
11
+ open(): void;
12
+ close(): void;
13
+ destroy(): void;
14
+ update(partial: Partial<PulseAgentOptions>): void;
15
+ }
16
+ export declare function createPulseAgent(options: PulseAgentOptions): PulseAgentHandle;
17
+ //# sourceMappingURL=pulse-agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pulse-agent.d.ts","sourceRoot":"","sources":["../../src/widget/pulse-agent.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,IAAI,IAAI,CAAC;IACd,OAAO,IAAI,IAAI,CAAC;IAChB,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC;CACnD;AAuBD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAqH7E"}
@@ -0,0 +1,277 @@
1
+ const DEFAULT_API_BASE_URL = 'http://localhost:9091';
2
+ const STYLE_ID = 'pulse-agent-widget-style';
3
+ export function createPulseAgent(options) {
4
+ assertBrowser();
5
+ const state = createState(options);
6
+ ensureStyle();
7
+ const mountRoot = resolveMount(state.options.mount);
8
+ const root = document.createElement('section');
9
+ root.className = 'pulse-agent-root';
10
+ root.innerHTML = template(state.options.title ?? 'Pulse Support');
11
+ mountRoot.appendChild(root);
12
+ const button = root.querySelector('[data-role="toggle"]');
13
+ const panel = root.querySelector('[data-role="panel"]');
14
+ const closeBtn = root.querySelector('[data-role="close"]');
15
+ const log = root.querySelector('[data-role="log"]');
16
+ const prechat = root.querySelector('[data-role="prechat"]');
17
+ const nameInput = root.querySelector('[data-role="name"]');
18
+ const emailInput = root.querySelector('[data-role="email"]');
19
+ const continueBtn = root.querySelector('[data-role="continue"]');
20
+ const textarea = root.querySelector('[data-role="message"]');
21
+ const sendBtn = root.querySelector('[data-role="send"]');
22
+ pushMessage(state, log, { role: 'system', content: 'Welcome to Pulse. Send us a message.' });
23
+ button.addEventListener('click', () => toggle(panel, state));
24
+ closeBtn.addEventListener('click', () => close(panel, state));
25
+ continueBtn.addEventListener('click', () => {
26
+ const name = nameInput.value.trim();
27
+ const email = emailInput.value.trim();
28
+ if (!name || !email) {
29
+ pushMessage(state, log, { role: 'system', content: 'Name and email are required before chat starts.' });
30
+ return;
31
+ }
32
+ state.profile = { name, email };
33
+ prechat.classList.add('hidden');
34
+ });
35
+ sendBtn.addEventListener('click', async () => {
36
+ const text = textarea.value.trim();
37
+ if (!text || state.sending) {
38
+ return;
39
+ }
40
+ if (state.options.requireProfile !== false && !state.profile) {
41
+ pushMessage(state, log, { role: 'system', content: 'Complete profile first.' });
42
+ return;
43
+ }
44
+ if (!state.widgetToken) {
45
+ await resolveWidgetToken(state, log);
46
+ if (!state.widgetToken) {
47
+ return;
48
+ }
49
+ }
50
+ state.sending = true;
51
+ sendBtn.disabled = true;
52
+ pushMessage(state, log, { role: 'visitor', content: text });
53
+ textarea.value = '';
54
+ try {
55
+ const payload = state.profile
56
+ ? { message: text, name: state.profile.name, email: state.profile.email }
57
+ : { message: text };
58
+ const res = await fetch(`${trimSlash(state.options.apiBaseUrl)}/api/pulse/public/webchat/${state.widgetToken}/message`, {
59
+ method: 'POST',
60
+ headers: { 'Content-Type': 'application/json' },
61
+ body: JSON.stringify(payload)
62
+ });
63
+ if (!res.ok) {
64
+ throw new Error(`Failed to send message (${res.status})`);
65
+ }
66
+ const body = (await res.json());
67
+ const conversationId = body.conversationId ?? body.id;
68
+ if (!conversationId) {
69
+ pushMessage(state, log, { role: 'system', content: 'Message sent but conversation ID was missing.' });
70
+ }
71
+ else if (!state.conversationId) {
72
+ state.conversationId = conversationId;
73
+ connectStream(state, log);
74
+ }
75
+ }
76
+ catch (error) {
77
+ const message = error instanceof Error ? error.message : 'Message failed.';
78
+ pushMessage(state, log, { role: 'system', content: message });
79
+ }
80
+ finally {
81
+ state.sending = false;
82
+ sendBtn.disabled = false;
83
+ }
84
+ });
85
+ resolveWidgetToken(state, log).then(() => {
86
+ if (state.options.autoOpen) {
87
+ open(panel, state);
88
+ }
89
+ if (state.options.requireProfile === false) {
90
+ prechat.classList.add('hidden');
91
+ }
92
+ });
93
+ return {
94
+ open: () => open(panel, state),
95
+ close: () => close(panel, state),
96
+ destroy: () => {
97
+ if (state.stream) {
98
+ state.stream.close();
99
+ }
100
+ root.remove();
101
+ },
102
+ update: (partial) => {
103
+ state.options = normalizeOptions({ ...state.options, ...partial });
104
+ if (partial.widgetToken) {
105
+ state.widgetToken = partial.widgetToken;
106
+ }
107
+ }
108
+ };
109
+ }
110
+ function template(title) {
111
+ return `
112
+ <button class="pulse-agent-fab" data-role="toggle" aria-label="Open Pulse chat">P</button>
113
+ <div class="pulse-agent-panel hidden" data-role="panel" aria-live="polite">
114
+ <header class="pulse-agent-header">
115
+ <strong>${escapeHtml(title)}</strong>
116
+ <button class="pulse-agent-close" data-role="close">Close</button>
117
+ </header>
118
+ <div class="pulse-agent-log" data-role="log"></div>
119
+ <div class="pulse-agent-compose">
120
+ <div class="pulse-agent-prechat" data-role="prechat">
121
+ <input data-role="name" type="text" placeholder="Your name" />
122
+ <input data-role="email" type="email" placeholder="Work email" />
123
+ <button data-role="continue">Continue</button>
124
+ </div>
125
+ <textarea data-role="message" rows="3" placeholder="How can we help?"></textarea>
126
+ <button data-role="send">Send</button>
127
+ </div>
128
+ </div>`;
129
+ }
130
+ function ensureStyle() {
131
+ if (document.getElementById(STYLE_ID)) {
132
+ return;
133
+ }
134
+ const style = document.createElement('style');
135
+ style.id = STYLE_ID;
136
+ style.textContent = `
137
+ .pulse-agent-root { position: fixed; right: 16px; bottom: 16px; z-index: 9999; font-family: Arial, sans-serif; }
138
+ .pulse-agent-fab { width: 56px; height: 56px; border-radius: 999px; border: 0; background: #1d4ed8; color: #fff; font-weight: 700; cursor: pointer; box-shadow: 0 10px 26px rgba(30,64,175,.35); }
139
+ .pulse-agent-panel { position: absolute; right: 0; bottom: 66px; width: min(380px, calc(100vw - 24px)); height: 540px; background: #fff; border: 1px solid #cbd5e1; border-radius: 14px; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; box-shadow: 0 18px 42px rgba(0,0,0,.2); }
140
+ .pulse-agent-panel.hidden { display: none; }
141
+ .pulse-agent-header { display: flex; justify-content: space-between; align-items: center; background: #0f172a; color: #fff; padding: 10px 12px; }
142
+ .pulse-agent-close { border: 0; border-radius: 6px; padding: 4px 8px; cursor: pointer; }
143
+ .pulse-agent-log { padding: 12px; display: grid; align-content: start; gap: 8px; background: #f8fafc; overflow: auto; }
144
+ .pulse-agent-bubble { max-width: 85%; padding: 8px 10px; border-radius: 10px; line-height: 1.35; white-space: pre-wrap; font-size: 14px; }
145
+ .pulse-agent-bubble.visitor { justify-self: end; background: #dbeafe; color: #1e3a8a; }
146
+ .pulse-agent-bubble.agent { justify-self: start; background: #e2e8f0; color: #111827; }
147
+ .pulse-agent-bubble.system { justify-self: center; background: #fef9c3; color: #854d0e; }
148
+ .pulse-agent-compose { border-top: 1px solid #dbe2ea; padding: 10px; display: grid; gap: 8px; }
149
+ .pulse-agent-prechat { display: grid; gap: 6px; }
150
+ .pulse-agent-prechat.hidden { display: none; }
151
+ .pulse-agent-compose textarea, .pulse-agent-prechat input { width: 100%; box-sizing: border-box; border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px; font: inherit; }
152
+ .pulse-agent-compose button, .pulse-agent-prechat button { border: 0; border-radius: 8px; padding: 8px 10px; background: #1d4ed8; color: #fff; cursor: pointer; }
153
+ `;
154
+ document.head.appendChild(style);
155
+ }
156
+ function createState(options) {
157
+ const normalized = normalizeOptions(options);
158
+ return {
159
+ options: normalized,
160
+ widgetToken: normalized.widgetToken?.trim() || null,
161
+ profile: null,
162
+ conversationId: null,
163
+ stream: null,
164
+ messages: [],
165
+ opened: false,
166
+ sending: false
167
+ };
168
+ }
169
+ function normalizeOptions(options) {
170
+ if (!options.slug?.trim()) {
171
+ throw new Error('PulseAgent: options.slug is required.');
172
+ }
173
+ return {
174
+ ...options,
175
+ slug: options.slug.trim(),
176
+ apiBaseUrl: options.apiBaseUrl?.trim() || DEFAULT_API_BASE_URL,
177
+ autoOpen: options.autoOpen === true,
178
+ requireProfile: options.requireProfile !== false
179
+ };
180
+ }
181
+ function resolveMount(mount) {
182
+ if (!mount) {
183
+ return document.body;
184
+ }
185
+ if (typeof mount === 'string') {
186
+ const node = document.querySelector(mount);
187
+ if (!node) {
188
+ throw new Error(`PulseAgent: mount selector not found: ${mount}`);
189
+ }
190
+ return node;
191
+ }
192
+ return mount;
193
+ }
194
+ async function resolveWidgetToken(state, log) {
195
+ if (state.widgetToken) {
196
+ return;
197
+ }
198
+ try {
199
+ const url = `${trimSlash(state.options.apiBaseUrl)}/api/pulse/public/webchat/resolve?slug=${encodeURIComponent(state.options.slug)}`;
200
+ const res = await fetch(url);
201
+ if (!res.ok) {
202
+ throw new Error(`Widget not configured for slug "${state.options.slug}".`);
203
+ }
204
+ const body = (await res.json());
205
+ state.widgetToken = body.widgetToken;
206
+ pushMessage(state, log, { role: 'system', content: `Connected to ${body.organizationName}.` });
207
+ }
208
+ catch (error) {
209
+ const message = error instanceof Error ? error.message : 'Failed to resolve widget token.';
210
+ pushMessage(state, log, { role: 'system', content: message });
211
+ }
212
+ }
213
+ function connectStream(state, log) {
214
+ if (!state.widgetToken || !state.conversationId) {
215
+ return;
216
+ }
217
+ state.stream?.close();
218
+ const streamUrl = `${trimSlash(state.options.apiBaseUrl)}/api/pulse/public/webchat/${state.widgetToken}/stream?conversationId=${encodeURIComponent(state.conversationId)}`;
219
+ const stream = new EventSource(streamUrl);
220
+ state.stream = stream;
221
+ stream.onmessage = (event) => {
222
+ try {
223
+ const payload = JSON.parse(event.data);
224
+ if (payload.senderType === 'USER' && payload.content?.trim()) {
225
+ pushMessage(state, log, { role: 'agent', content: payload.content });
226
+ }
227
+ }
228
+ catch {
229
+ return;
230
+ }
231
+ };
232
+ stream.onerror = () => {
233
+ stream.close();
234
+ state.stream = null;
235
+ };
236
+ }
237
+ function pushMessage(state, log, message) {
238
+ state.messages.push(message);
239
+ const bubble = document.createElement('div');
240
+ bubble.className = `pulse-agent-bubble ${message.role}`;
241
+ bubble.textContent = message.content;
242
+ log.appendChild(bubble);
243
+ log.scrollTop = log.scrollHeight;
244
+ }
245
+ function toggle(panel, state) {
246
+ if (state.opened) {
247
+ close(panel, state);
248
+ }
249
+ else {
250
+ open(panel, state);
251
+ }
252
+ }
253
+ function open(panel, state) {
254
+ panel.classList.remove('hidden');
255
+ state.opened = true;
256
+ }
257
+ function close(panel, state) {
258
+ panel.classList.add('hidden');
259
+ state.opened = false;
260
+ }
261
+ function trimSlash(value) {
262
+ return value.replace(/\/+$/, '');
263
+ }
264
+ function assertBrowser() {
265
+ if (typeof window === 'undefined' || typeof document === 'undefined') {
266
+ throw new Error('PulseAgent: browser environment required.');
267
+ }
268
+ }
269
+ function escapeHtml(input) {
270
+ return input
271
+ .replace(/&/g, '&amp;')
272
+ .replace(/</g, '&lt;')
273
+ .replace(/>/g, '&gt;')
274
+ .replace(/"/g, '&quot;')
275
+ .replace(/'/g, '&#39;');
276
+ }
277
+ //# sourceMappingURL=pulse-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pulse-agent.js","sourceRoot":"","sources":["../../src/widget/pulse-agent.ts"],"names":[],"mappings":"AAmCA,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;AACrD,MAAM,QAAQ,GAAG,0BAA0B,CAAC;AAE5C,MAAM,UAAU,gBAAgB,CAAC,OAA0B;IACzD,aAAa,EAAE,CAAC;IAChB,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IACnC,WAAW,EAAE,CAAC;IAEd,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAC/C,IAAI,CAAC,SAAS,GAAG,kBAAkB,CAAC;IACpC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,eAAe,CAAC,CAAC;IAClE,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAE5B,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAoB,sBAAsB,CAAE,CAAC;IAC9E,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAiB,qBAAqB,CAAE,CAAC;IACzE,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAoB,qBAAqB,CAAE,CAAC;IAC/E,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAiB,mBAAmB,CAAE,CAAC;IACrE,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAiB,uBAAuB,CAAE,CAAC;IAC7E,MAAM,SAAS,G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C,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@primexperts.co/pulse-agent",
3
+ "version": "1.0.0",
4
+ "description": "Embeddable Pulse floating chat agent widget.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "scripts": {
20
+ "clean": "node -e \"if(require('fs').existsSync('dist')) require('fs').rmSync('dist',{recursive:true,force:true})\"",
21
+ "build:types": "tsc -p tsconfig.build.json",
22
+ "build:browser": "node scripts/build-browser-global.mjs",
23
+ "build": "npm run clean && npm run build:types && npm run build:browser",
24
+ "prepublishOnly": "npm run build"
25
+ },
26
+ "private": false,
27
+ "license": "MIT",
28
+ "author": "PrimExperts",
29
+ "dependencies": {
30
+ "tslib": "^2.8.1"
31
+ },
32
+ "devDependencies": {
33
+ "typescript": "~5.8.2"
34
+ }
35
+ }