@squadico/chatbot 1.2.1 → 1.4.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 +109 -19
- 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 +43 -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/i18n.d.ts +20 -0
- package/dist/lib/i18n.d.ts.map +1 -1
- 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-BjqOavOO.js +1984 -0
- package/dist/src-BjqOavOO.js.map +1 -0
- package/dist/src-DS8P9HdZ.cjs +7 -0
- package/dist/src-DS8P9HdZ.cjs.map +1 -0
- package/dist/types.d.ts +14 -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-2GKPJcbZ.js +0 -2708
- package/dist/src-2GKPJcbZ.js.map +0 -1
- package/dist/src-CcILETWB.cjs +0 -8
- package/dist/src-CcILETWB.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -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
|
|
@@ -147,6 +157,7 @@ All optional. An attribute is a string; object or function values are set as
|
|
|
147
157
|
| `layout` | `sidebar` | `sidebar` \| `floating`. The sidebar takes the full height of the right edge; `floating` opens a rounded window in the launcher's corner, `width` wide and `--sqc-height` tall (`640px`, never more than the screen allows). Full screen on a phone either way |
|
|
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 |
|
|
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 |
|
|
150
161
|
| `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 |
|
|
151
162
|
|
|
152
163
|
### Icon of the floating button
|
|
@@ -224,6 +235,9 @@ squadico-chatbot {
|
|
|
224
235
|
--sqc-z: 9999;
|
|
225
236
|
--sqc-font-family: 'Inter', sans-serif; /* default: Plus Jakarta Sans */
|
|
226
237
|
--sqc-font-heading: 'Inter', sans-serif; /* header, Markdown headings; default: the body family */
|
|
238
|
+
/* Series of the charts an agent draws, 1 to 6; defaults #2448cc, #0d7f78,
|
|
239
|
+
#b86e00, #a92f73, #557c00, #5a6a80 */
|
|
240
|
+
--sqc-series-1: #2563eb;
|
|
227
241
|
}
|
|
228
242
|
```
|
|
229
243
|
|
|
@@ -237,6 +251,57 @@ downloaded** — the widget issues no font request. If the page loads Plus Jakar
|
|
|
237
251
|
Sans itself, `font-family` resolution crosses the shadow root and the widget
|
|
238
252
|
benefits; otherwise the system fallbacks apply.
|
|
239
253
|
|
|
254
|
+
## Widgets
|
|
255
|
+
|
|
256
|
+
Since 1.4.0 the package also exports the elements the chat draws an answer's
|
|
257
|
+
interactive blocks with, for a host that has no chat around them (the Squadico
|
|
258
|
+
console renders agent answers this way):
|
|
259
|
+
|
|
260
|
+
```ts
|
|
261
|
+
import {
|
|
262
|
+
defineChatWidgets,
|
|
263
|
+
defineWidgetExtras,
|
|
264
|
+
parseAnswer,
|
|
265
|
+
isLive,
|
|
266
|
+
WIDGET_TAGS,
|
|
267
|
+
} from '@squadico/chatbot/widgets'
|
|
268
|
+
|
|
269
|
+
defineChatWidgets() // <sqc-table>, <sqc-choices>, <sqc-confirm>
|
|
270
|
+
defineWidgetExtras() // <sqc-form>, <sqc-chart>, <sqc-approval>
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Both are idempotent and do nothing where there is no DOM, and importing the
|
|
274
|
+
entry touches none either, so it is safe to import server-side (Next.js).
|
|
275
|
+
`parseAnswer(text, language, confirmable = true)` splits an answer into Markdown
|
|
276
|
+
and widget blocks, and says whether Yes / No buttons go under it; pass
|
|
277
|
+
`confirmable: false` where none may (a visitor's own message, a turn still
|
|
278
|
+
streaming), and the `(yes/no)` marker then stays in the text. `isLive` says
|
|
279
|
+
whether a message is still answerable; `WIDGET_TAGS` maps each widget to its
|
|
280
|
+
tag name. Types ship in `dist/widgets/index.d.ts`.
|
|
281
|
+
|
|
282
|
+
| Tag | Data property |
|
|
283
|
+
| --------------- | ------------------------------------------------ |
|
|
284
|
+
| `sqc-table` | `table` |
|
|
285
|
+
| `sqc-choices` | `options`, `multiple`, `checked` |
|
|
286
|
+
| `sqc-confirm` | none: Yes / No / Propose something else |
|
|
287
|
+
| `sqc-approval` | `call` (the paused tool call) |
|
|
288
|
+
| `sqc-form` | `form` (fields, as a `FormSpec`) |
|
|
289
|
+
| `sqc-chart` | `chart` (spec), `body` (file text: `string` or `Promise<string>`), `filename` |
|
|
290
|
+
|
|
291
|
+
Every element takes these as **properties**, not attributes, plus `locked`
|
|
292
|
+
(shown, no longer interactive) and `language` (`en` | `fr` | `es`). An answer
|
|
293
|
+
leaves as a bubbling, composed DOM event: `sqc-reply` with `{ text }` (the
|
|
294
|
+
visitor's answer, which also locks the element), or `sqc-decision` with
|
|
295
|
+
`{ approved }` from `sqc-approval`. `sqc-confirm`'s third button dispatches
|
|
296
|
+
`sqc-compose`, with no detail: the host focuses its message composer (left
|
|
297
|
+
empty), and the element stays live until the visitor's next message arrives.
|
|
298
|
+
The elements are styled by the same `--sqc-*` variables as the chat, including
|
|
299
|
+
`--sqc-series-1` to `--sqc-series-6` for the charts; outside a chat the
|
|
300
|
+
fallbacks apply.
|
|
301
|
+
|
|
302
|
+
The standalone build is two files: `chatbot.global.js` (the chat) and
|
|
303
|
+
`chatbot-widgets.global.js` (form, chart and approval, loaded by the chat on demand).
|
|
304
|
+
|
|
240
305
|
## Integration
|
|
241
306
|
|
|
242
307
|
### HTML / CDN
|
|
@@ -246,7 +311,7 @@ and [unpkg](https://unpkg.com) as soon as a version is published — there is
|
|
|
246
311
|
nothing else to deploy. Add the script, then the tag, anywhere in the page:
|
|
247
312
|
|
|
248
313
|
```html
|
|
249
|
-
<script src="https://cdn.jsdelivr.net/npm/@squadico/chatbot@1.
|
|
314
|
+
<script src="https://cdn.jsdelivr.net/npm/@squadico/chatbot@1.4.0/dist/chatbot.global.js"></script>
|
|
250
315
|
<squadico-chatbot
|
|
251
316
|
embed-key="sq_pub_paste_yours_here"
|
|
252
317
|
context='{"workspaceId":"WS-1"}'
|
|
@@ -254,9 +319,22 @@ nothing else to deploy. Add the script, then the tag, anywhere in the page:
|
|
|
254
319
|
```
|
|
255
320
|
|
|
256
321
|
unpkg works the same way:
|
|
257
|
-
`https://unpkg.com/@squadico/chatbot@1.
|
|
258
|
-
|
|
259
|
-
|
|
322
|
+
`https://unpkg.com/@squadico/chatbot@1.4.0/dist/chatbot.global.js`.
|
|
323
|
+
|
|
324
|
+
The form an agent may ask the visitor to fill in, the charts it draws and the
|
|
325
|
+
Yes / No card of a tool call waiting on the visitor's approval live
|
|
326
|
+
in a second file, `chatbot-widgets.global.js`, published next to
|
|
327
|
+
`chatbot.global.js` in `dist/`. The chat loads it on its own, from the same
|
|
328
|
+
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
|
|
329
|
+
not need it. A self-hosted copy must therefore keep both files side by side.
|
|
330
|
+
The short CDN URL (`https://cdn.jsdelivr.net/npm/@squadico/chatbot@1.4.0`,
|
|
331
|
+
served through the package's `jsdelivr` / `unpkg` fields) works too: a script URL
|
|
332
|
+
that does not end in `.js` is taken as the package root, and the extras file is
|
|
333
|
+
fetched from its `dist/` folder. The injected script carries the main script's
|
|
334
|
+
`nonce`, so a CSP built on nonces covers it. Until the file arrives — or if it
|
|
335
|
+
cannot — a form shows its field labels and a chart its filename, as plain text.
|
|
336
|
+
|
|
337
|
+
**Pin the version.** `@1.4.0` never changes, so a release cannot alter a
|
|
260
338
|
customer page. Leaving it out (`@squadico/chatbot/dist/…`) serves the latest
|
|
261
339
|
version, cached by jsDelivr for up to 12 hours; a range such as `@1` follows the
|
|
262
340
|
newest `1.x.y`. Prefer a pinned version in production.
|
|
@@ -441,6 +519,18 @@ event: held
|
|
|
441
519
|
data: {}
|
|
442
520
|
```
|
|
443
521
|
|
|
522
|
+
And while nothing can be read yet — the agent searching its knowledge, following
|
|
523
|
+
a skill, asking a member of its team or using a tool — the stream says so:
|
|
524
|
+
|
|
525
|
+
```
|
|
526
|
+
event: progress
|
|
527
|
+
data: {"activity":"knowledge"}
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
`activity` is `knowledge`, `skill`, `delegation` or `tool`: a kind of work, never
|
|
531
|
+
the tool's name nor what it was called with. One frame per tool call, before the
|
|
532
|
+
answer starts; a client that does not know the frame skips it and loses nothing.
|
|
533
|
+
|
|
444
534
|
`handoff` comes before the answer of the agent the conversation was passed to,
|
|
445
535
|
which has no handle on the application: the widget signs that answer with
|
|
446
536
|
`to_agent_name`. `escalated` follows the answer of an agent that handed the
|
|
@@ -597,7 +687,7 @@ the variable — everything `npm run build` produces talks to
|
|
|
597
687
|
npm run dev # minimal sandbox on :3010
|
|
598
688
|
SQUADICO_API_URL=https://staging.example npm run dev # sandbox on another API
|
|
599
689
|
npm run build # ESM + CJS + IIFE + .d.ts declarations
|
|
600
|
-
npm run size # real gzip weight
|
|
690
|
+
npm run size # real gzip weight; budgets: 30 kB chatbot.global.js, 20 kB chatbot-widgets.global.js
|
|
601
691
|
npm run type-check # tsc --noEmit
|
|
602
692
|
npm run test # vitest run
|
|
603
693
|
npm run lint # eslint
|