bunnyquery 1.21.13 → 1.21.15
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 +23 -4
- package/bunnyquery.css +77 -44
- package/bunnyquery.js +411 -29
- package/dist/engine.cjs +341 -13
- package/dist/engine.cjs.map +1 -1
- package/dist/engine.d.mts +88 -1
- package/dist/engine.d.ts +88 -1
- package/dist/engine.mjs +335 -14
- package/dist/engine.mjs.map +1 -1
- package/package.json +1 -1
- package/src/engine/activity.ts +253 -0
- package/src/engine/index.ts +8 -0
- package/src/engine/prompts/chat_system_prompt.ts +1 -1
- package/src/engine/requests.ts +58 -0
- package/src/engine/session.ts +5 -0
- package/src/engine/sse.ts +110 -3
- package/src/widget.css +71 -44
- package/styles/chat.css +6 -0
package/README.md
CHANGED
|
@@ -108,7 +108,6 @@ call `BunnyQuery.init()`:
|
|
|
108
108
|
|
|
109
109
|
// 2. Mount BunnyQuery into the container
|
|
110
110
|
BunnyQuery.init(skapi, "chatbox", {
|
|
111
|
-
theme: "light",
|
|
112
111
|
signup: true,
|
|
113
112
|
});
|
|
114
113
|
</script>
|
|
@@ -153,7 +152,7 @@ Mounts the widget. Returns the `BunnyQuery` object.
|
|
|
153
152
|
|
|
154
153
|
| Option | Type | Default | Description |
|
|
155
154
|
| ------------------------ | --------- | -------- | -------------------------------------------------------------------------------------------- |
|
|
156
|
-
| `theme` | `string` | `
|
|
155
|
+
| `theme` | `string` | `null` | Starting colour mode: `null` follows the visitor's OS setting (and changes with it), `"light"` or `"dark"` fixes it. A mode the visitor picks in the widget is saved and wins on later visits. |
|
|
157
156
|
| `title` | `string` | `null` | Header title text. `null` keeps `"BunnyQuery · <project name>"`; any string replaces the whole line, and `""` leaves the header title empty. It is one element, so it ellipsizes as a unit. |
|
|
158
157
|
| `inputPlaceholder` | `string` | `null` | Placeholder in the chat composer. `null` keeps `"Ask anything about: <project name>"`; `""` shows no placeholder. |
|
|
159
158
|
| `showLogin` | `boolean` | `true` | Whether an **anonymous** visitor is offered a `Login` button in the chat header. Signed-in users are unaffected: they get the settings gear in that slot either way. Set `false` for an embed that handles its own auth, or that does not want visitors making accounts. |
|
|
@@ -201,7 +200,7 @@ The `BunnyQuery` global also exposes:
|
|
|
201
200
|
|
|
202
201
|
| Method | Description |
|
|
203
202
|
| ---------------------------------- | ----------------------------------------------------------------------------------- |
|
|
204
|
-
| `setTheme(theme)` | Apply `"light"` or `"dark"` and
|
|
203
|
+
| `setTheme(theme)` | Apply `"light"` or `"dark"` and save it, like the visitor picking it. |
|
|
205
204
|
| `toggleTheme()` | Switch between light and dark. |
|
|
206
205
|
| `logout()` | Sign the current user out and return to the login view. |
|
|
207
206
|
| `registerAttachmentParser(parser)` | Register a client-side attachment parser. May be called before or after `init()`. See [Attachment parser plugins](#attachment-parser-plugins). |
|
|
@@ -521,7 +520,14 @@ To customize colors, override the variables in your own stylesheet **after**
|
|
|
521
520
|
}
|
|
522
521
|
```
|
|
523
522
|
|
|
524
|
-
|
|
523
|
+
Until the visitor picks a mode, the widget follows their OS colour mode (or the
|
|
524
|
+
`theme` option, when the host sets one). A mode picked with the toggle or in
|
|
525
|
+
Settings is saved to `localStorage`, so a returning user keeps their choice.
|
|
526
|
+
|
|
527
|
+
The default colours are the bunnyquery.com dashboard chat's: in dark mode the
|
|
528
|
+
widget is a near-black card (`--bq-paper` `#161618`), replies sit one step
|
|
529
|
+
lighter (`--bq-bubble` `#1f1f23`) and text boxes are recessed (`--bq-field`
|
|
530
|
+
`#101012`, edged with `--bq-input-line`).
|
|
525
531
|
|
|
526
532
|
## Importing the chat engine
|
|
527
533
|
|
|
@@ -666,6 +672,19 @@ widget rather than approximately:
|
|
|
666
672
|
for a reply (`retrievalNoteOfAnswer`) into the file-and-page citations the
|
|
667
673
|
widget shows under an answer; `answerUsedNoDataTool` says whether a reply read
|
|
668
674
|
no data at all.
|
|
675
|
+
- **`chatActivityLine(msg, now?, lang?)`** is the progress line under a waiting
|
|
676
|
+
turn: "Reading your question", "Searching your files for "oil leak"",
|
|
677
|
+
"Reading BP-252.pdf", "Looking at what it found", "Writing the answer". The
|
|
678
|
+
engine records the step from the live stream (the tool the model called, its
|
|
679
|
+
input, whether it answered) and the sentence moves on every
|
|
680
|
+
`CHAT_ACTIVITY_ROTATE_MS` (4 seconds) while a step lasts, looping its list, so
|
|
681
|
+
call it again about once a second and update only the text. It returns the
|
|
682
|
+
sentence without dots: draw your animated dot trail right after it. `lang` is a
|
|
683
|
+
BCP 47 tag such as `navigator.language`; `ko` picks Korean, anything else
|
|
684
|
+
English. The widget and bunnyquery.com show it in a chat turn's own waiting
|
|
685
|
+
bubble (not on indexing rows), as a `span.bq-activity-text` before the
|
|
686
|
+
`.bq-loader` dots. A turn that does not stream shows the thinking sentences,
|
|
687
|
+
timed from when the bubble was first drawn.
|
|
669
688
|
- **`ChatSession.cancelPendingReply(msg, idx)`** is the "stop waiting" control:
|
|
670
689
|
handed the pending assistant bubble, it cancels the running request on the
|
|
671
690
|
server, marks the question cancelled and promotes the next queued message.
|
package/bunnyquery.css
CHANGED
|
@@ -14,29 +14,38 @@
|
|
|
14
14
|
* ==========================================================================*/
|
|
15
15
|
|
|
16
16
|
/* ---- Tokens: light (default) ---------------------------------------------*/
|
|
17
|
+
/* Same values as the BunnyQuery dashboard chat (web-bunnyquery bq-tokens.less +
|
|
18
|
+
agent.vue), so an embedded chat and the dashboard's chat look the same. The
|
|
19
|
+
widget is one card, so --bq-paper here is the dashboard's chat card colour
|
|
20
|
+
(its --bq-surface), not its page canvas. --bq-bubble is the reply bubble one
|
|
21
|
+
step above it (the dashboard's --bq-chat-bubble), --bq-field the text boxes. */
|
|
17
22
|
.bq-agent,
|
|
18
23
|
.bq-modal-root {
|
|
19
24
|
--bq-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
|
|
20
|
-
--bq-ink: #
|
|
21
|
-
--bq-paper: #
|
|
22
|
-
--bq-
|
|
23
|
-
--bq-
|
|
24
|
-
--bq-
|
|
25
|
+
--bq-ink: #111113;
|
|
26
|
+
--bq-paper: #ffffff;
|
|
27
|
+
--bq-bubble: #ffffff;
|
|
28
|
+
--bq-field: #ffffff;
|
|
29
|
+
--bq-muted: #5e5e66;
|
|
30
|
+
--bq-line: #d6d6db;
|
|
31
|
+
/* control edges (text boxes); dividers stay on --bq-line */
|
|
32
|
+
--bq-input-line: #8a8a93;
|
|
33
|
+
--bq-hover-bg: #ececef;
|
|
25
34
|
--bq-main: #c2185b;
|
|
26
35
|
--bq-light-main: #f06292;
|
|
27
|
-
--bq-danger: #
|
|
28
|
-
--bq-danger-bg: #
|
|
29
|
-
--bq-main-bg: #
|
|
30
|
-
--bq-success: #
|
|
31
|
-
--bq-success-bg: #
|
|
32
|
-
--bq-success-border: #
|
|
33
|
-
--bq-warning: #
|
|
34
|
-
--bq-warning-bg: #
|
|
35
|
-
--bq-warning-border: #
|
|
36
|
+
--bq-danger: #c03b3b;
|
|
37
|
+
--bq-danger-bg: #fdf1f1;
|
|
38
|
+
--bq-main-bg: #fcf0f5;
|
|
39
|
+
--bq-success: #25722a;
|
|
40
|
+
--bq-success-bg: #edf8ef;
|
|
41
|
+
--bq-success-border: #a9d4ae;
|
|
42
|
+
--bq-warning: #7a5f00;
|
|
43
|
+
--bq-warning-bg: #fff7de;
|
|
44
|
+
--bq-warning-border: #d99a00;
|
|
36
45
|
--bq-info: #1a5bb5;
|
|
37
46
|
--bq-info-bg: #e8f0fb;
|
|
38
|
-
--bq-info-border: #
|
|
39
|
-
--bq-placeholder: #
|
|
47
|
+
--bq-info-border: #6aa5f0;
|
|
48
|
+
--bq-placeholder: #909098;
|
|
40
49
|
/* hard offset shadow for bubbles; swapped for a light edge in dark */
|
|
41
50
|
--bq-shadow: rgba(0, 0, 0, 0.12);
|
|
42
51
|
--bq-code-bg: #1e1e1e;
|
|
@@ -45,31 +54,35 @@
|
|
|
45
54
|
}
|
|
46
55
|
|
|
47
56
|
/* ---- Tokens: dark --------------------------------------------------------*/
|
|
57
|
+
/* Not #000: the dashboard's dark chat card (#161618), replies one step lighter
|
|
58
|
+
(#1f1f23) and text boxes recessed below the card (#101012). */
|
|
48
59
|
.bq-agent[data-bq-theme="dark"],
|
|
49
60
|
.bq-modal-root[data-bq-theme="dark"] {
|
|
50
|
-
--bq-ink: #
|
|
51
|
-
--bq-paper: #
|
|
52
|
-
--bq-
|
|
53
|
-
|
|
54
|
-
--bq-
|
|
55
|
-
--bq-
|
|
56
|
-
--bq-
|
|
57
|
-
--bq-
|
|
58
|
-
--bq-
|
|
59
|
-
--bq-
|
|
60
|
-
--bq-
|
|
61
|
-
--bq-
|
|
62
|
-
--bq-
|
|
63
|
-
--bq-success
|
|
64
|
-
--bq-
|
|
65
|
-
--bq-
|
|
66
|
-
--bq-warning
|
|
67
|
-
--bq-
|
|
68
|
-
--bq-
|
|
69
|
-
--bq-info
|
|
70
|
-
--bq-
|
|
71
|
-
|
|
72
|
-
--bq-
|
|
61
|
+
--bq-ink: #ececef;
|
|
62
|
+
--bq-paper: #161618;
|
|
63
|
+
--bq-bubble: #1f1f23;
|
|
64
|
+
--bq-field: #101012;
|
|
65
|
+
--bq-muted: #a9a9b2;
|
|
66
|
+
--bq-line: #333338;
|
|
67
|
+
--bq-input-line: #74747e;
|
|
68
|
+
--bq-hover-bg: #26262a;
|
|
69
|
+
--bq-main: #f2709c;
|
|
70
|
+
--bq-light-main: #f7a1bf;
|
|
71
|
+
--bq-danger: #f0706d;
|
|
72
|
+
--bq-danger-bg: #2a1617;
|
|
73
|
+
--bq-main-bg: #2a1620;
|
|
74
|
+
--bq-success: #6cc068;
|
|
75
|
+
--bq-success-bg: #142318;
|
|
76
|
+
--bq-success-border: #3f8a45;
|
|
77
|
+
--bq-warning: #f2c14e;
|
|
78
|
+
--bq-warning-bg: #29220f;
|
|
79
|
+
--bq-warning-border: #b8892a;
|
|
80
|
+
--bq-info: #6cb4f5;
|
|
81
|
+
--bq-info-bg: #131d29;
|
|
82
|
+
--bq-info-border: #3a7cc4;
|
|
83
|
+
--bq-placeholder: #6c6c75;
|
|
84
|
+
/* light edge: a black hard shadow is invisible on the dark card */
|
|
85
|
+
--bq-shadow: rgba(255, 255, 255, 0.11);
|
|
73
86
|
--bq-icon-invert: 1;
|
|
74
87
|
}
|
|
75
88
|
|
|
@@ -330,8 +343,8 @@
|
|
|
330
343
|
.bq-input-text {
|
|
331
344
|
width: 100%;
|
|
332
345
|
padding: 0.7rem 0.8rem;
|
|
333
|
-
border: 1px solid var(--bq-line);
|
|
334
|
-
background: var(--bq-
|
|
346
|
+
border: 1px solid var(--bq-input-line);
|
|
347
|
+
background: var(--bq-field);
|
|
335
348
|
color: var(--bq-ink);
|
|
336
349
|
font-family: var(--bq-mono);
|
|
337
350
|
font-size: 0.9rem;
|
|
@@ -840,8 +853,8 @@
|
|
|
840
853
|
box-sizing: border-box;
|
|
841
854
|
overflow-y: hidden; /* autoGrowInput switches to auto only at the max-height cap */
|
|
842
855
|
resize: none;
|
|
843
|
-
border: 1px solid var(--bq-line);
|
|
844
|
-
background: var(--bq-
|
|
856
|
+
border: 1px solid var(--bq-input-line);
|
|
857
|
+
background: var(--bq-field);
|
|
845
858
|
color: var(--bq-ink);
|
|
846
859
|
padding: 0.7rem 0.7rem 0.7rem var(--chat-control-height);
|
|
847
860
|
font-family: var(--bq-mono);
|
|
@@ -1029,7 +1042,7 @@
|
|
|
1029
1042
|
max-width: 100%;
|
|
1030
1043
|
max-height: 90vh;
|
|
1031
1044
|
overflow-y: auto;
|
|
1032
|
-
background: var(--bq-
|
|
1045
|
+
background: var(--bq-bubble);
|
|
1033
1046
|
color: var(--bq-ink);
|
|
1034
1047
|
border: 1px solid var(--bq-line);
|
|
1035
1048
|
box-shadow: 4px 4px rgba(0, 0, 0, 0.2);
|
|
@@ -1151,6 +1164,20 @@
|
|
|
1151
1164
|
filter: invert(var(--bq-icon-invert));
|
|
1152
1165
|
}
|
|
1153
1166
|
|
|
1167
|
+
/* ---- Reply bubbles one step above the conversation -----------------------*/
|
|
1168
|
+
/* chat.css paints replies on --bq-paper, the conversation colour, so in dark
|
|
1169
|
+
mode a reply was only a hairline on the card. Same rule as the dashboard
|
|
1170
|
+
(agent.vue): replies on --bq-bubble; the user, error, cancelled and retried
|
|
1171
|
+
variants keep their own chat.css colours, and the two "plain" notes stay on
|
|
1172
|
+
the conversation colour. */
|
|
1173
|
+
.bq-messages .bq-bubble {
|
|
1174
|
+
background: var(--bq-bubble);
|
|
1175
|
+
}
|
|
1176
|
+
.bq-messages .bq-message.is-error.is-retried .bq-bubble,
|
|
1177
|
+
.bq-messages .bq-message.bq-index-pass.is-user:not(.is-cancelled):not(.is-pending-older) .bq-bubble {
|
|
1178
|
+
background: var(--bq-paper);
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1154
1181
|
/**
|
|
1155
1182
|
* @skapi/chat-engine — shared chat-display styles.
|
|
1156
1183
|
*
|
|
@@ -1236,6 +1263,12 @@
|
|
|
1236
1263
|
.bq-message.is-assistant:not(.is-error):not(.is-cancelled):not(.bq-index-pass) .bq-bubble:has(> .bq-loader) > .bq-loader {
|
|
1237
1264
|
vertical-align: middle;
|
|
1238
1265
|
}
|
|
1266
|
+
/* The waiting turn's progress line ("Searching your files for ..."): a sentence
|
|
1267
|
+
from the engine (chatActivityLine) sitting right before the dot trail, so the
|
|
1268
|
+
dots read as its ending. Middle-aligned with the inline bunny like the dots. */
|
|
1269
|
+
.bq-bubble > .bq-activity-text {
|
|
1270
|
+
vertical-align: middle;
|
|
1271
|
+
}
|
|
1239
1272
|
/* The dot-trail cycles '.', '..', '...', so left to itself it is a box that
|
|
1240
1273
|
changes width three times every 1.2s: the bubble pulsed with it, and the
|
|
1241
1274
|
stop-waiting control that follows the dots moved each time, which made it hard
|