bunnyquery 1.19.2 → 1.20.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 +25 -4
- package/bunnyquery.css +21 -0
- package/bunnyquery.js +316 -44
- package/dist/engine.cjs +286 -39
- package/dist/engine.cjs.map +1 -1
- package/dist/engine.d.mts +96 -1
- package/dist/engine.d.ts +96 -1
- package/dist/engine.mjs +285 -40
- package/dist/engine.mjs.map +1 -1
- package/package.json +1 -1
- package/src/engine/config.ts +36 -0
- package/src/engine/index.ts +4 -0
- package/src/engine/prompts/chat_system_prompt.ts +36 -41
- package/src/engine/prompts/indexing_system_prompt.ts +5 -5
- package/src/engine/prompts/indexing_user_message.ts +3 -3
- package/src/engine/requests.ts +8 -2
- package/src/engine/session.ts +268 -10
- package/styles/chat.css +21 -0
package/README.md
CHANGED
|
@@ -28,7 +28,16 @@ release-by-release changelog is [HISTORY.md](HISTORY.md).
|
|
|
28
28
|
- **Grounded answers**: the agent answers only from the project's data, says so when
|
|
29
29
|
the data does not have it, and names the file and page an answer came from as
|
|
30
30
|
citation chips under the reply. The open web is off unless the project's owner
|
|
31
|
-
turns it on (`webAccess`).
|
|
31
|
+
turns it on (`webAccess`). A long file (a manual, a book) is searched by chapter
|
|
32
|
+
from its contents list, and for a signed-in user the question goes along with the
|
|
33
|
+
search so the server learns which page answered it.
|
|
34
|
+
- **"Wrong answer?"**: the latest answer that read data carries a small button that
|
|
35
|
+
sends "This answer seems wrong. Please check it again against the documents." as
|
|
36
|
+
an ordinary message, once per answer. The agent re-reads the cited pages and
|
|
37
|
+
searches again, then corrects the answer, or corrects it and records the right
|
|
38
|
+
page with an exact quote that proves it (signed-in users only), or keeps it and
|
|
39
|
+
quotes the supporting text. A user's word alone never changes what search has
|
|
40
|
+
learned.
|
|
32
41
|
- **Authentication**: email/password login, optional signup, password change,
|
|
33
42
|
email verification, account recovery, and "Sign in with Google".
|
|
34
43
|
- **Conversation history**: paginated, with "Fetching history…" indicators on
|
|
@@ -161,6 +170,7 @@ Mounts the widget. Returns the `BunnyQuery` object.
|
|
|
161
170
|
| `skipDuplicateFiles` | `boolean` | `null` | Whether a chat attachment the signed-in user **already uploaded** to this project (same stored file name, same size in bytes, same uploader, found from the file's `src::` record, and a stored copy that finished indexing or is still being indexed) is skipped: it is neither uploaded nor indexed again, the chip reads "already uploaded", and the message uses the stored copy's url. The project's **Skip duplicate files** setting (the `skip_duplicate_files` key of `bq::settings`, **on** unless the owner turned it off) is the **ceiling**, and this option may only restrict below it: `effective = projectSetting && skipDuplicateFiles !== false`. `null` or `true` follows the project; `false` lets this page re-upload duplicates; a value above the project setting has no effect. A stored copy whose indexing failed or was cancelled is not a duplicate, so the file uploads as usual. The check never blocks an upload: a failed lookup, or one slower than 15 seconds, uploads as usual. |
|
|
162
171
|
| `reuseMcpToolList` | `boolean` | `false` | OpenAI chat turns only: reuse the MCP tool listing OpenAI returned on an earlier turn of this page, so OpenAI does not fetch it again (about 0.6 s per turn). Off unless `true`. Each reused turn's request and stored history row is about 31 to 34 KB larger. See `reuseMcpToolList` under `configureChatEngine`. |
|
|
163
172
|
| `liveStreaming` | `boolean` | `false` | Deliver the streamed reply over skapi's websocket as well as the poll, so each piece lands the moment the server relays it instead of on the next one-second poll tick. Streaming itself is not an option: the widget streams every reply whenever the page's `skapi-js` can carry skapi's half of the stream flag (it checks for `forwardRequestStream` and `forwardRequestFinalize`), and otherwise warns once and buffers. Off unless you ask for it: skapi's `joinRealtime` **replaces** the connection's group, so for the length of a turn it takes the room out from under whatever else your app uses realtime for. Purely an accelerator; with it off the reply still streams, on the poll's cadence. Before 1.16.0 this key meant "stream at all" and the socket was `liveStreamingRealtime`; that name is now ignored. |
|
|
173
|
+
| `statusPush` | `boolean` | `false` | Indexing status over skapi's websocket: each indexing pass asks the server for status messages, its poll then reads once a minute while they arrive and at once when one names it, and the chat re-reads its history when the socket reconnects. Off unless you ask for it, because it keeps a websocket open on your page's skapi instance (your own realtime callback never sees these messages). Needs skapi-js 2.5.0 or newer; with an older one it stays off. Purely an accelerator: every status on screen still comes from reading the request. |
|
|
164
174
|
|
|
165
175
|
### Rebranding the widget
|
|
166
176
|
|
|
@@ -369,7 +379,9 @@ Uploading over a file that already exists prompts for skip, "reindex only", or
|
|
|
369
379
|
overwrite. Choosing either of the latter two deletes the file's existing
|
|
370
380
|
`src::<path>` index record first, and the skapi backend cascades that delete to
|
|
371
381
|
the record's reference-linked children, so re-indexing **replaces** the file's
|
|
372
|
-
knowledge rather than duplicating it.
|
|
382
|
+
knowledge rather than duplicating it. That includes the file's contents list, its
|
|
383
|
+
search glossary and everything search has learned about it from people's
|
|
384
|
+
questions and corrections, which the dialog says.
|
|
373
385
|
|
|
374
386
|
### Filenames
|
|
375
387
|
|
|
@@ -492,7 +504,7 @@ configureChatEngine({
|
|
|
492
504
|
forwardRequest: (form, opts) => skapi.forwardRequest(form, opts),
|
|
493
505
|
forwardRequestHistory: (params, fetchOptions) =>
|
|
494
506
|
skapi.forwardRequestHistory(params, fetchOptions),
|
|
495
|
-
mcpBaseUrl: 'https://mcp.
|
|
507
|
+
mcpBaseUrl: 'https://mcp.skapi.com',
|
|
496
508
|
poll: 0, // see the note below
|
|
497
509
|
});
|
|
498
510
|
|
|
@@ -529,6 +541,9 @@ helpers. See the `.d.ts` shipped with `bunnyquery/engine`.
|
|
|
529
541
|
| `forwardRequestStream` | `function?` | `skapi.forwardRequestStream`, bound to your Skapi instance. The **second half of the durability guarantee**: a row that settles while no poll is attached (closed tab, discarded background tab, slept device) is never finalized, so its answer stays in the chunk store and its history row is terminal and empty. Given the request id this drains that turn's chunks in one pass; the engine parses them exactly as it parses a live stream and finalizes what it read, so each row is recovered at most once. Without it the engine mints no recovery marker at all, and without the pair the engine does not stream. |
|
|
530
542
|
| `onLiveStreamUpdate` | `function?` | Observation hook for a streaming turn (`{ serverItemId, ownerKey, phase, text, thinkingText, toolNames, complete, errored }`). The engine already paints the answer text itself, so this is only for affordances it does not decide the presentation of. Never throw from it. |
|
|
531
543
|
| `liveStreaming` | `boolean?` | Deliver streamed chunks over skapi's websocket as well. Off by default: `joinRealtime` replaces the connection's group for the length of a turn, so only a host that owns its skapi instance should opt in. Streaming itself has no key: the engine streams every chat turn whenever `forwardRequestFinalize` and `forwardRequestStream` are both handed over (`liveStreamingEnabled()`), and a host that wants buffered replies hands over neither. Before 1.16.0 this key meant "stream at all"; `liveStreamingRealtime` is now ignored. |
|
|
544
|
+
| `statusPush` | `boolean?` | Request status push (skapi-js 2.5.0+, with `onRequestStatus` below). Indexing passes are dispatched with `notify: true`, their polls idle at a once-a-minute heartbeat while status messages arrive, a message about a pass the page does not follow runs the queue check, and a reconnect runs `catchUpHistory()`. Off by default: it keeps a websocket open on the host's skapi instance. |
|
|
545
|
+
| `onRequestStatus` | `function?` | `skapi.onRequestStatus`, bound to the host's skapi instance (skapi-js 2.5.0+). Required for `statusPush`. |
|
|
546
|
+
| `isRequestStatusLive` | `function?` | `skapi.isRequestStatusLive`, bound to the host's skapi instance (skapi-js 2.5.0+). |
|
|
532
547
|
| `streamRecovery` | `boolean?` | Set `false` to force the read-back of already-streamed turns **off**, even though the chunk reader is injected. There is no need to set it to turn recovery on: injecting `forwardRequestStream` is what arms it. |
|
|
533
548
|
| `mintIndexDoneMarker` | `function?` | Write the durable "indexing finished" marker (`done::<path>`, reference `src::<path>`, table `__INDEXING__`) for the runs this client knows are complete. Best-effort, must never throw. Without it the engine falls back to inference. |
|
|
534
549
|
| `upsertIndexRunRecord` | `function?` | Create-or-update the per-file run record (`run::<path>`, reference `src::<path>`, table `__INDEXING__`), which is what lets chat rows and files-page badges paint without scanning background history. You implement the upsert (the records API has none) and the status precedence: `'working'` must never overwrite a terminal status. Without it the engine uses the legacy scan/probe path. |
|
|
@@ -599,6 +614,12 @@ widget rather than approximately:
|
|
|
599
614
|
handed the pending assistant bubble, it cancels the running request on the
|
|
600
615
|
server, marks the question cancelled and promotes the next queued message.
|
|
601
616
|
`cancelQueuedMessage` does the same for a message still in the queue.
|
|
617
|
+
- **`ChatSession.canReportWrongAnswer(msg)` / `reportWrongAnswer(msg, pinned?)`**
|
|
618
|
+
are the "Wrong answer?" button. The gate is a settled answer with a retrieval
|
|
619
|
+
note (not the no-source mark), not cancelled, and the latest answer; one that
|
|
620
|
+
was already reported keeps a disabled button (`wrongAnswerReported(msg)`).
|
|
621
|
+
`reportWrongAnswer` sends `wrongAnswerMessage` through `dispatchComposedMessage`,
|
|
622
|
+
so it is a normal visible turn; `wrongAnswerLabel` is the button's text.
|
|
602
623
|
- **`resetFileIndexOnServer({ service, owner?, storagePath })`** clears a file's index on the MCP (`/internal/index-reset`: the file record and everything that cascades from it, the agent's per-window records, and the `done::`, `run::` and `prog::` markers) before a Reindex or an Overwrite, through the host's `forwardRequest` with `$ACCESS_TOKEN`. Resolves to the server's answer (including the old record's `access_group`), or `null` when the MCP could not be reached, in which case the caller clears the index itself.
|
|
603
624
|
- **`findDuplicateUpload`** and the `configureProjectSettings` reader back the
|
|
604
625
|
`skipDuplicateFiles` and `webAccess` switches; see the `configureChatEngine`
|
|
@@ -617,7 +638,7 @@ never progress.
|
|
|
617
638
|
## OAuth & redirects
|
|
618
639
|
|
|
619
640
|
BunnyQuery connects to your AI agent through an MCP OAuth server
|
|
620
|
-
(`mcp.
|
|
641
|
+
(`mcp.skapi.com` in production, `mcp-dev.broadwayinc.computer` when
|
|
621
642
|
`dev: true`). After authorization, the OAuth server redirects back to **the current
|
|
622
643
|
host page**: BunnyQuery reads the `?code=…&state=…` parameters, completes the
|
|
623
644
|
exchange, and cleans them from the URL automatically. No dedicated callback page is
|
package/bunnyquery.css
CHANGED
|
@@ -1289,6 +1289,27 @@
|
|
|
1289
1289
|
color: var(--bq-muted);
|
|
1290
1290
|
clear: both;
|
|
1291
1291
|
}
|
|
1292
|
+
/* "Wrong answer?" under an answer that read data: a small muted text button, no
|
|
1293
|
+
box and no hover colour (the hover is an underline). Disabled once sent. */
|
|
1294
|
+
.bq-wrong-answer-btn {
|
|
1295
|
+
display: block;
|
|
1296
|
+
margin-top: 0.3rem;
|
|
1297
|
+
padding: 0;
|
|
1298
|
+
min-height: 0;
|
|
1299
|
+
border: 0;
|
|
1300
|
+
background: transparent;
|
|
1301
|
+
color: var(--bq-muted);
|
|
1302
|
+
font: inherit;
|
|
1303
|
+
font-size: 0.68rem;
|
|
1304
|
+
line-height: 1.3;
|
|
1305
|
+
text-align: left;
|
|
1306
|
+
cursor: pointer;
|
|
1307
|
+
box-shadow: none;
|
|
1308
|
+
border-radius: 0;
|
|
1309
|
+
clear: both;
|
|
1310
|
+
}
|
|
1311
|
+
.bq-wrong-answer-btn:hover:not(:disabled) { text-decoration: underline; }
|
|
1312
|
+
.bq-wrong-answer-btn:disabled { cursor: default; opacity: 0.6; }
|
|
1292
1313
|
/* Timestamp under a settled bubble (created for a user turn, response time for an
|
|
1293
1314
|
assistant turn). Muted and small so it never competes with the message. */
|
|
1294
1315
|
.bq-msg-time {
|