@squadico/chatbot 1.3.0 → 1.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 +110 -20
- package/dist/answer-CDGrP8YE.js +1193 -0
- package/dist/answer-CDGrP8YE.js.map +1 -0
- package/dist/answer-DRaV2dVt.cjs +8 -0
- package/dist/answer-DRaV2dVt.cjs.map +1 -0
- package/dist/chatbot-widgets.global.js +4 -0
- package/dist/chatbot-widgets.global.js.map +1 -0
- package/dist/chatbot.global.js +12 -7
- package/dist/chatbot.global.js.map +1 -1
- package/dist/components/ChatbotWidget.d.ts.map +1 -1
- package/dist/components/MessageList.d.ts +4 -1
- package/dist/components/MessageList.d.ts.map +1 -1
- package/dist/components/RichText.d.ts +6 -4
- package/dist/components/RichText.d.ts.map +1 -1
- package/dist/element.d.ts.map +1 -1
- package/dist/extras-ClIRRLqo.js +604 -0
- package/dist/extras-ClIRRLqo.js.map +1 -0
- package/dist/extras-lsCe4xgN.cjs +4 -0
- package/dist/extras-lsCe4xgN.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/jsx.d.ts +41 -0
- package/dist/jsx.d.ts.map +1 -1
- package/dist/lib/client.d.ts +8 -4
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/lib/conversation.d.ts +5 -1
- package/dist/lib/conversation.d.ts.map +1 -1
- package/dist/lib/i18n.d.ts +20 -0
- package/dist/lib/i18n.d.ts.map +1 -1
- package/dist/lib/useChat.d.ts +6 -0
- package/dist/lib/useChat.d.ts.map +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +2 -2
- package/dist/react.js.map +1 -1
- package/dist/src-BWDC0W4O.js +2005 -0
- package/dist/src-BWDC0W4O.js.map +1 -0
- package/dist/src-DvrmRR89.cjs +7 -0
- package/dist/src-DvrmRR89.cjs.map +1 -0
- package/dist/types.d.ts +16 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/widgets/approval/SqcApproval.d.ts +17 -0
- package/dist/widgets/approval/SqcApproval.d.ts.map +1 -0
- package/dist/widgets/approval/name.d.ts +3 -0
- package/dist/widgets/approval/name.d.ts.map +1 -0
- package/dist/widgets/chart/SqcChart.d.ts +19 -0
- package/dist/widgets/chart/SqcChart.d.ts.map +1 -0
- package/dist/widgets/chart/draw.d.ts +31 -0
- package/dist/widgets/chart/draw.d.ts.map +1 -0
- package/dist/widgets/chart/png.d.ts +10 -0
- package/dist/widgets/chart/png.d.ts.map +1 -0
- package/dist/widgets/chart/read.d.ts +11 -0
- package/dist/widgets/chart/read.d.ts.map +1 -0
- package/dist/widgets/chart/strings.d.ts +32 -0
- package/dist/widgets/chart/strings.d.ts.map +1 -0
- package/dist/widgets/choices/SqcChoices.d.ts +17 -0
- package/dist/widgets/choices/SqcChoices.d.ts.map +1 -0
- package/dist/widgets/confirm/SqcConfirm.d.ts +12 -0
- package/dist/widgets/confirm/SqcConfirm.d.ts.map +1 -0
- package/dist/widgets/define.d.ts +8 -0
- package/dist/widgets/define.d.ts.map +1 -0
- package/dist/widgets/element.d.ts +26 -0
- package/dist/widgets/element.d.ts.map +1 -0
- package/dist/widgets/extras-loader.d.ts +21 -0
- package/dist/widgets/extras-loader.d.ts.map +1 -0
- package/dist/widgets/extras.d.ts +3 -0
- package/dist/widgets/extras.d.ts.map +1 -0
- package/dist/widgets/extras.global.d.ts +2 -0
- package/dist/widgets/extras.global.d.ts.map +1 -0
- package/dist/widgets/form/SqcForm.d.ts +14 -0
- package/dist/widgets/form/SqcForm.d.ts.map +1 -0
- package/dist/widgets/form/reply.d.ts +7 -0
- package/dist/widgets/form/reply.d.ts.map +1 -0
- package/dist/widgets/i18n.d.ts +4 -0
- package/dist/widgets/i18n.d.ts.map +1 -0
- package/dist/widgets/index.d.ts +10 -0
- package/dist/widgets/index.d.ts.map +1 -0
- package/dist/widgets/inline.d.ts +11 -0
- package/dist/widgets/inline.d.ts.map +1 -0
- package/dist/widgets/live.d.ts +12 -0
- package/dist/widgets/live.d.ts.map +1 -0
- package/dist/widgets/names.d.ts +10 -0
- package/dist/widgets/names.d.ts.map +1 -0
- package/dist/widgets/parse/answer.d.ts +11 -0
- package/dist/widgets/parse/answer.d.ts.map +1 -0
- package/dist/widgets/parse/confirm.d.ts +19 -0
- package/dist/widgets/parse/confirm.d.ts.map +1 -0
- package/dist/widgets/parse/form.d.ts +6 -0
- package/dist/widgets/parse/form.d.ts.map +1 -0
- package/dist/widgets/styles.d.ts +3 -0
- package/dist/widgets/styles.d.ts.map +1 -0
- package/dist/widgets/table/SqcTable.d.ts +16 -0
- package/dist/widgets/table/SqcTable.d.ts.map +1 -0
- package/dist/widgets/types.d.ts +68 -0
- package/dist/widgets/types.d.ts.map +1 -0
- package/dist/widgets.cjs +1 -0
- package/dist/widgets.js +3 -0
- package/package.json +7 -2
- package/dist/components/Approval.d.ts +0 -37
- package/dist/components/Approval.d.ts.map +0 -1
- package/dist/components/Choices.d.ts +0 -27
- package/dist/components/Choices.d.ts.map +0 -1
- package/dist/components/Confirm.d.ts +0 -16
- package/dist/components/Confirm.d.ts.map +0 -1
- package/dist/lib/confirm.d.ts +0 -17
- package/dist/lib/confirm.d.ts.map +0 -1
- package/dist/src-DcJyi601.cjs +0 -8
- package/dist/src-DcJyi601.cjs.map +0 -1
- package/dist/src-Nh5rZvti.js +0 -2710
- package/dist/src-Nh5rZvti.js.map +0 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ documents ([knowledge base](https://www.squadico.com/features/knowledge-base)),
|
|
|
11
11
|
act in your tools ([tools and MCP](https://www.squadico.com/features/tools-mcp))
|
|
12
12
|
and answer on [your website](https://www.squadico.com/integrations/website),
|
|
13
13
|
Slack, WhatsApp or Microsoft Teams. See it live on the
|
|
14
|
-
[Crema Collective demo shop](https://
|
|
14
|
+
[Crema Collective demo shop](https://demo.squadico.com).
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
17
|
npm install @squadico/chatbot
|
|
@@ -34,11 +34,17 @@ Installation).
|
|
|
34
34
|
|--------------------------------|------------------------------------------------|-------------------------------|
|
|
35
35
|
| `@squadico/chatbot` | Registers `<squadico-chatbot>` | Every host |
|
|
36
36
|
| `@squadico/chatbot/react` | `<SquadicoChatbot />`, typed props + callbacks | Next.js / React |
|
|
37
|
-
| `@squadico/chatbot/standalone` |
|
|
37
|
+
| `@squadico/chatbot/standalone` | IIFE bundle, plus the extras file it fetches | classic `<script>` tag, CDN |
|
|
38
38
|
| `@squadico/chatbot/jsx` | JSX types for the tag | React, using the tag directly |
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
runtime
|
|
40
|
+
The standalone build is two files in `dist/`: `chatbot.global.js` (the chat,
|
|
41
|
+
Preact runtime and CSS included — under **30 kB gzip**) and
|
|
42
|
+
`chatbot-widgets.global.js` (the form, chart and tool-approval widgets, under 20 kB gzip),
|
|
43
|
+
which the chat fetches from beside its own script the first time an answer
|
|
44
|
+
needs it. That lookup reads `document.currentScript`, so load the bundle with a
|
|
45
|
+
**classic** `<script>` (not `type="module"`, not imported by a bundler), and keep
|
|
46
|
+
both files side by side when self-hosting. The budgets are checked at build time
|
|
47
|
+
by `npm run size`.
|
|
42
48
|
|
|
43
49
|
## Implementation choices
|
|
44
50
|
|
|
@@ -91,17 +97,21 @@ runtime + CSS). The budget is checked at build time by `npm run size`.
|
|
|
91
97
|
lists, listing tables, code, links) are converted into Preact nodes — hence
|
|
92
98
|
escaped by construction — and `href`s are limited to `http`/`https`/`mailto`.
|
|
93
99
|
No Markdown library: the subset the agent produces is enough.
|
|
94
|
-
- **
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
- **Option lists = clickable options.** `- ( ) Delivery` lines are a single
|
|
101
|
+
choice: one button per option, and clicking sends the exact label as the
|
|
102
|
+
turn's answer, since the agent matches it against the candidates by name.
|
|
103
|
+
`- [ ] Email` lines are a multiple choice: tick any, then one button sends the
|
|
104
|
+
labels joined by `, `. `(x)` / `[x]` pre-tick an option. Over 20 options, the
|
|
105
|
+
list stays plain Markdown. Only the last answer's options are live — those of
|
|
106
|
+
earlier turns stay displayed, locked on what was picked.
|
|
107
|
+
- **Closed questions = Yes / No buttons.** When the last line of an answer ends
|
|
108
|
+
with `(yes/no)`, `(oui/non)` or `(sí/no)` (any case, spaces allowed around
|
|
109
|
+
`/`), the marker is hidden and three buttons appear: Yes and No send `yes` or
|
|
110
|
+
`no` in the visitor's language — the agent recognizes those bare answers
|
|
111
|
+
without an LLM call — and "Propose something else" sends nothing: it hands the
|
|
112
|
+
visitor the composer, empty. An agent that writes no marker still gets the
|
|
113
|
+
buttons under a narrow set of confirmation phrasings
|
|
114
|
+
(`src/widgets/parse/confirm.ts`): an open question must not show buttons.
|
|
105
115
|
- **Pending tool call = two buttons, and nothing written.** A tool the
|
|
106
116
|
organization marked as needing approval stops the turn before it runs: the
|
|
107
117
|
answer is the agent's recap, and the frame beside it says which call is
|
|
@@ -148,6 +158,7 @@ All optional. An attribute is a string; object or function values are set as
|
|
|
148
158
|
| `open` | absent | Presence = open at mount, for a first visit — a panel the user opened or closed themselves wins |
|
|
149
159
|
| `persist-open` | `true` | The panel stays open (or closed) across a refresh or a page change, for the lifetime of the tab. `persist-open="false"` → the state starts from `open` on every mount |
|
|
150
160
|
| `show-context` | `true` | Since 1.3.0. Shows the page context as chips under the header. `show-context="false"` hides them — the context is still sent with every message |
|
|
161
|
+
| `scope` | absent | Since 1.5.0. Partitions remembered conversations the way the host does (an organization, a workspace). A conversation is only resumed under the scope it was opened with; changing it opens a new one |
|
|
151
162
|
| `locale` | browser languages, then `en` | Interface language and date locale, in BCP-47. When absent, `navigator.languages` is read in the user's order of preference. Three languages ship — `en`, `fr`, `es`; anything else falls back to English. The region is only read by `Intl`: `fr-CA` = French copy, Canadian dates |
|
|
152
163
|
|
|
153
164
|
### Icon of the floating button
|
|
@@ -225,6 +236,9 @@ squadico-chatbot {
|
|
|
225
236
|
--sqc-z: 9999;
|
|
226
237
|
--sqc-font-family: 'Inter', sans-serif; /* default: Plus Jakarta Sans */
|
|
227
238
|
--sqc-font-heading: 'Inter', sans-serif; /* header, Markdown headings; default: the body family */
|
|
239
|
+
/* Series of the charts an agent draws, 1 to 6; defaults #2448cc, #0d7f78,
|
|
240
|
+
#b86e00, #a92f73, #557c00, #5a6a80 */
|
|
241
|
+
--sqc-series-1: #2563eb;
|
|
228
242
|
}
|
|
229
243
|
```
|
|
230
244
|
|
|
@@ -238,6 +252,57 @@ downloaded** — the widget issues no font request. If the page loads Plus Jakar
|
|
|
238
252
|
Sans itself, `font-family` resolution crosses the shadow root and the widget
|
|
239
253
|
benefits; otherwise the system fallbacks apply.
|
|
240
254
|
|
|
255
|
+
## Widgets
|
|
256
|
+
|
|
257
|
+
Since 1.4.0 the package also exports the elements the chat draws an answer's
|
|
258
|
+
interactive blocks with, for a host that has no chat around them (the Squadico
|
|
259
|
+
console renders agent answers this way):
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
import {
|
|
263
|
+
defineChatWidgets,
|
|
264
|
+
defineWidgetExtras,
|
|
265
|
+
parseAnswer,
|
|
266
|
+
isLive,
|
|
267
|
+
WIDGET_TAGS,
|
|
268
|
+
} from '@squadico/chatbot/widgets'
|
|
269
|
+
|
|
270
|
+
defineChatWidgets() // <sqc-table>, <sqc-choices>, <sqc-confirm>
|
|
271
|
+
defineWidgetExtras() // <sqc-form>, <sqc-chart>, <sqc-approval>
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Both are idempotent and do nothing where there is no DOM, and importing the
|
|
275
|
+
entry touches none either, so it is safe to import server-side (Next.js).
|
|
276
|
+
`parseAnswer(text, language, confirmable = true)` splits an answer into Markdown
|
|
277
|
+
and widget blocks, and says whether Yes / No buttons go under it; pass
|
|
278
|
+
`confirmable: false` where none may (a visitor's own message, a turn still
|
|
279
|
+
streaming), and the `(yes/no)` marker then stays in the text. `isLive` says
|
|
280
|
+
whether a message is still answerable; `WIDGET_TAGS` maps each widget to its
|
|
281
|
+
tag name. Types ship in `dist/widgets/index.d.ts`.
|
|
282
|
+
|
|
283
|
+
| Tag | Data property |
|
|
284
|
+
| --------------- | ------------------------------------------------ |
|
|
285
|
+
| `sqc-table` | `table` |
|
|
286
|
+
| `sqc-choices` | `options`, `multiple`, `checked` |
|
|
287
|
+
| `sqc-confirm` | none: Yes / No / Propose something else |
|
|
288
|
+
| `sqc-approval` | `call` (the paused tool call) |
|
|
289
|
+
| `sqc-form` | `form` (fields, as a `FormSpec`) |
|
|
290
|
+
| `sqc-chart` | `chart` (spec), `body` (file text: `string` or `Promise<string>`), `filename` |
|
|
291
|
+
|
|
292
|
+
Every element takes these as **properties**, not attributes, plus `locked`
|
|
293
|
+
(shown, no longer interactive) and `language` (`en` | `fr` | `es`). An answer
|
|
294
|
+
leaves as a bubbling, composed DOM event: `sqc-reply` with `{ text }` (the
|
|
295
|
+
visitor's answer, which also locks the element), or `sqc-decision` with
|
|
296
|
+
`{ approved }` from `sqc-approval`. `sqc-confirm`'s third button dispatches
|
|
297
|
+
`sqc-compose`, with no detail: the host focuses its message composer (left
|
|
298
|
+
empty), and the element stays live until the visitor's next message arrives.
|
|
299
|
+
The elements are styled by the same `--sqc-*` variables as the chat, including
|
|
300
|
+
`--sqc-series-1` to `--sqc-series-6` for the charts; outside a chat the
|
|
301
|
+
fallbacks apply.
|
|
302
|
+
|
|
303
|
+
The standalone build is two files: `chatbot.global.js` (the chat) and
|
|
304
|
+
`chatbot-widgets.global.js` (form, chart and approval, loaded by the chat on demand).
|
|
305
|
+
|
|
241
306
|
## Integration
|
|
242
307
|
|
|
243
308
|
### HTML / CDN
|
|
@@ -247,7 +312,7 @@ and [unpkg](https://unpkg.com) as soon as a version is published — there is
|
|
|
247
312
|
nothing else to deploy. Add the script, then the tag, anywhere in the page:
|
|
248
313
|
|
|
249
314
|
```html
|
|
250
|
-
<script src="https://cdn.jsdelivr.net/npm/@squadico/chatbot@1.
|
|
315
|
+
<script src="https://cdn.jsdelivr.net/npm/@squadico/chatbot@1.5.0/dist/chatbot.global.js"></script>
|
|
251
316
|
<squadico-chatbot
|
|
252
317
|
embed-key="sq_pub_paste_yours_here"
|
|
253
318
|
context='{"workspaceId":"WS-1"}'
|
|
@@ -255,9 +320,22 @@ nothing else to deploy. Add the script, then the tag, anywhere in the page:
|
|
|
255
320
|
```
|
|
256
321
|
|
|
257
322
|
unpkg works the same way:
|
|
258
|
-
`https://unpkg.com/@squadico/chatbot@1.
|
|
259
|
-
|
|
260
|
-
|
|
323
|
+
`https://unpkg.com/@squadico/chatbot@1.5.0/dist/chatbot.global.js`.
|
|
324
|
+
|
|
325
|
+
The form an agent may ask the visitor to fill in, the charts it draws and the
|
|
326
|
+
Yes / No card of a tool call waiting on the visitor's approval live
|
|
327
|
+
in a second file, `chatbot-widgets.global.js`, published next to
|
|
328
|
+
`chatbot.global.js` in `dist/`. The chat loads it on its own, from the same
|
|
329
|
+
folder as its own script, the first time an answer holds a form, a chart or an approval — so it is never fetched by a conversation that does
|
|
330
|
+
not need it. A self-hosted copy must therefore keep both files side by side.
|
|
331
|
+
The short CDN URL (`https://cdn.jsdelivr.net/npm/@squadico/chatbot@1.5.0`,
|
|
332
|
+
served through the package's `jsdelivr` / `unpkg` fields) works too: a script URL
|
|
333
|
+
that does not end in `.js` is taken as the package root, and the extras file is
|
|
334
|
+
fetched from its `dist/` folder. The injected script carries the main script's
|
|
335
|
+
`nonce`, so a CSP built on nonces covers it. Until the file arrives — or if it
|
|
336
|
+
cannot — a form shows its field labels and a chart its filename, as plain text.
|
|
337
|
+
|
|
338
|
+
**Pin the version.** `@1.5.0` never changes, so a release cannot alter a
|
|
261
339
|
customer page. Leaving it out (`@squadico/chatbot/dist/…`) serves the latest
|
|
262
340
|
version, cached by jsDelivr for up to 12 hours; a range such as `@1` follows the
|
|
263
341
|
newest `1.x.y`. Prefer a pinned version in production.
|
|
@@ -442,6 +520,18 @@ event: held
|
|
|
442
520
|
data: {}
|
|
443
521
|
```
|
|
444
522
|
|
|
523
|
+
And while nothing can be read yet — the agent searching its knowledge, following
|
|
524
|
+
a skill, asking a member of its team or using a tool — the stream says so:
|
|
525
|
+
|
|
526
|
+
```
|
|
527
|
+
event: progress
|
|
528
|
+
data: {"activity":"knowledge"}
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
`activity` is `knowledge`, `skill`, `delegation` or `tool`: a kind of work, never
|
|
532
|
+
the tool's name nor what it was called with. One frame per tool call, before the
|
|
533
|
+
answer starts; a client that does not know the frame skips it and loses nothing.
|
|
534
|
+
|
|
445
535
|
`handoff` comes before the answer of the agent the conversation was passed to,
|
|
446
536
|
which has no handle on the application: the widget signs that answer with
|
|
447
537
|
`to_agent_name`. `escalated` follows the answer of an agent that handed the
|
|
@@ -598,7 +688,7 @@ the variable — everything `npm run build` produces talks to
|
|
|
598
688
|
npm run dev # minimal sandbox on :3010
|
|
599
689
|
SQUADICO_API_URL=https://staging.example npm run dev # sandbox on another API
|
|
600
690
|
npm run build # ESM + CJS + IIFE + .d.ts declarations
|
|
601
|
-
npm run size # real gzip weight
|
|
691
|
+
npm run size # real gzip weight; budgets: 30 kB chatbot.global.js, 20 kB chatbot-widgets.global.js
|
|
602
692
|
npm run type-check # tsc --noEmit
|
|
603
693
|
npm run test # vitest run
|
|
604
694
|
npm run lint # eslint
|