bunnyquery 1.17.1 → 1.19.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 CHANGED
@@ -42,7 +42,9 @@ release-by-release changelog is [HISTORY.md](HISTORY.md).
42
42
  a text layer and rendered to page images where they do not, emails are read as
43
43
  their headers, body and attachment text, and everything else extractable is
44
44
  inlined as text. A file the signed-in user already uploaded (same name, same
45
- size) is not uploaded or indexed again (`skipDuplicateFiles`). See
45
+ size) that is indexed or still being indexed is not uploaded or indexed again
46
+ (`skipDuplicateFiles`); a copy whose indexing failed or was cancelled is not
47
+ skipped. See
46
48
  [Supported file types](#supported-file-types).
47
49
  - **Background indexing**: an uploaded file is indexed in the background,
48
50
  across as many passes as it takes. A file's passes collapse into a single
@@ -106,10 +108,10 @@ call `BunnyQuery.init()`:
106
108
  That's it. BunnyQuery takes over the `#chatbox` element and renders the login or
107
109
  chat view depending on the user's session.
108
110
 
109
- The widget works with whichever `skapi-js` your page loads. On a current SDK it calls the
110
- `forwardRequest` family, and on an earlier one it falls back to the `clientSecretRequest` family,
111
- deciding by whether the SDK has `forwardRequestHistory`. It never decides by `forwardRequest` alone,
112
- because on an earlier SDK that name belongs to a different, retired method.
111
+ The widget needs `skapi-js` **2.1.0 or newer**, the release that added the `forwardRequest`
112
+ family. `init()` throws on an older SDK, which it recognises by a missing `forwardRequestHistory`
113
+ (not by `forwardRequest` alone: on an earlier SDK that name belongs to a different, retired method).
114
+ Loading `skapi-js@latest` as above always qualifies.
113
115
 
114
116
  ## What's in the package
115
117
 
@@ -156,8 +158,8 @@ Mounts the widget. Returns the `BunnyQuery` object.
156
158
  | `windowedIndexing` | `boolean` | `true` | Server-driven windowed indexing for text and grid files (see [file types](#supported-file-types)). Pass `false` to fall back to agent-driven paging, which keeps the traversal inside the model's turn budget and the tab open. |
157
159
  | `allowAnonymous` | `boolean` | `null` | Open the chat with no login for visitors without an account. `null` follows the project's own "Allow anonymous users" setting (`getConnectionInfo().conf.require_login`); `true`/`false` pins it. |
158
160
  | `webAccess` | `boolean` | `null` | Whether the chat's answers may reach the open web (Claude `web_fetch`, OpenAI `web_search`). The project's own **Web access for answers** switch on its Project Settings page (the `web_access` key of the project's `bq::settings` record, **off** unless the owner turned it on) is the **ceiling**, and this option may only restrict below it: `effective = projectSetting && webAccess !== false`. `null` or `true` follows the project; `false` turns the web off for this page whatever the project says; a value above the project setting has no effect. With the web off, answers come only from the project's files and database. Indexing is not affected. |
159
- | `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) 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. The check never blocks an upload: a failed lookup uploads as usual. |
160
- | `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`, or their older `clientSecretRequestStream` and `clientSecretRequestFinalize` names), 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. |
161
+ | `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
+ | `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. |
161
163
 
162
164
  ### Rebranding the widget
163
165
 
@@ -520,7 +522,7 @@ helpers. See the `.d.ts` shipped with `bunnyquery/engine`.
520
522
  | `attachmentParsers` | `array?` | Client-side attachment parsers, registered at configure time. More can be added later with `registerAttachmentParser()`. See [Attachment parser plugins](#attachment-parser-plugins). |
521
523
  | `windowedIndexing` | `boolean?` | Opt in to **server-driven** windowed indexing for text and grid files (see [file types](#supported-file-types)). Off by default in the engine; the widget passes it as `true`. The deployed skapi workers support it; only leave it off against a self-hosted worker that does not yet strip the `_skapi_window` directive, where it would reach the provider as an unknown body field and fail the call terminally with no retry. |
522
524
  | `webAccess` | `boolean?` | Whether a chat turn may reach the open web: Claude's `web_fetch` and OpenAI's `web_search` are attached to a chat request only when this resolves to `true`. The project's own `web_access` setting (the `bq::settings` record, read through `configureProjectSettings`; **off** unless the project owner turned it on) is the **ceiling** and this option may only restrict below it: `effective = projectSetting && webAccess !== false`. Leave it out or pass `true` to follow the project; `false` turns the web off for your host; a value above the project setting has no effect. `webAccessEnabled(serviceId)` and `resolveWebAccess(serviceId, override?)` answer the resolved switch (sync from the cache, or awaiting the settings fetch; `override` is a per-call host value that restricts the same way). Indexing passes keep their tools regardless. Pass the same value to `buildChatSystemPrompt({ webAccess })` so the prompt matches the tool list. |
523
- | `skipDuplicateFiles` | `boolean?` | Whether an attachment the signed-in user already uploaded to the project (same stored name, same size, same uploader) is skipped by `ChatSession`'s upload path: not uploaded, not indexed, the turn using the stored copy's url. The project's `skip_duplicate_files` setting (**on** unless the owner turned it off) is the **ceiling** and this option may only restrict: `effective = projectSetting && skipDuplicateFiles !== false`. The check runs only when the host implements the optional `findDuplicateUpload(file)` hook; `findDuplicateUpload(skapi, { name, size }, userId, { service? })` from the barrel is the ready-made implementation (an ends-with `getUniqueId` lookup narrowed to `src::<name>` and `src::.../<name>`, then the first record whose `data.size_bytes` and `user_id` match; it never throws, a failed lookup answers `null` and the file uploads as usual). `skipDuplicateFilesEnabled(serviceId)` and `resolveSkipDuplicateFiles(serviceId)` answer the resolved switch. |
525
+ | `skipDuplicateFiles` | `boolean?` | Whether an attachment the signed-in user already uploaded to the project (same stored name, same size, same uploader) is skipped by `ChatSession`'s upload path: not uploaded, not indexed, the turn using the stored copy's url. The project's `skip_duplicate_files` setting (**on** unless the owner turned it off) is the **ceiling** and this option may only restrict: `effective = projectSetting && skipDuplicateFiles !== false`. The check runs only when the host implements the optional `findDuplicateUpload(file)` hook; `findDuplicateUpload(skapi, { name, size }, userId, { service?, timeoutMs? })` from the barrel is the ready-made implementation, and bunnyquery.com uses it too: an ends-with `getUniqueId` lookup narrowed to `src::<name>` and `src::.../<name>`, then the first record whose `data.size_bytes` and `user_id` match AND whose stored copy finished indexing (`done::<path>` exists) or is still being indexed (its `run::<path>` record is `working` and started less than `RUN_RECORD_WORKING_STALE_MS`, 6 hours, ago). The match carries `indexing: 'done' | 'running'`. A copy whose indexing failed or was cancelled is not a match. It never throws and answers within `timeoutMs` (default `DUPLICATE_LOOKUP_TIMEOUT_MS`, 15 seconds): a failed or slow lookup answers `null` and the file uploads as usual. `skipDuplicateFilesEnabled(serviceId)` and `resolveSkipDuplicateFiles(serviceId)` answer the resolved switch. |
524
526
  | `forwardRequestFinalize` | `function?` | `skapi.forwardRequestFinalize`, bound to your Skapi instance. Stores the version of a streamed turn that history keeps (the engine sends the assembled provider body, so it reads back exactly like a buffered turn) and releases that request's chunks. Without it a streamed turn is never finalized and its row stays empty. Together with `forwardRequestStream` it is what turns streaming on. |
525
527
  | `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. |
526
528
  | `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. |
@@ -528,14 +530,17 @@ helpers. See the `.d.ts` shipped with `bunnyquery/engine`.
528
530
  | `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. |
529
531
  | `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. |
530
532
  | `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. |
531
- | `csrHistoryItemLookup` | `function?` | Single-item `csr-poll` point lookup, used by `ChatSession.hydrateCompactItems` to fetch a compact history stub's real body when an indexing row is expanded. Without it stubs keep their server-extracted heads. |
532
-
533
- **Deprecated config keys.** `clientSecretRequest`, `clientSecretRequestHistory`,
534
- `clientSecretRequestFinalize` and `clientSecretRequestStream` are still accepted, so a host written
535
- against an earlier release keeps working unchanged. When both spellings are given the new one wins.
536
- Through the old `clientSecretRequest` key the engine sends the secret's name as `clientSecretName`,
537
- exactly as before, and through `forwardRequest` it sends `secretName`. Every request also names the
538
- project it runs against in `service` and `owner`, and both keys pass those through.
533
+ | `csrHistoryItemLookup` | `function?` | Single-item `csr-poll` point lookup. Used by `ChatSession.hydrateCompactItems` to fetch a compact history stub's real body when an indexing row is expanded, and to settle every indexing pass (each file's first pass and the passes the worker runs in parallel): with it, each 10-second check of the indexing queue lists the finished passes and reads each one once by id, so a pass shows within about 10 seconds of finishing instead of waiting for the passes ahead of it to be polled one at a time. Without it stubs keep their server-extracted heads and indexing passes are polled as before. |
534
+ | `listIndexPasses` | `function?` | `(service, storagePath) => Promise<string[]>`: the request ids of one file's indexing passes, read from the `pass::<storagePath>#<request id>` records the indexing worker writes as each pass starts (`getUniqueId` with the prefix `pass::<storagePath>#`, every page). With it and `csrHistoryItemLookup`, the chat history fetches the conversation only: a file's row comes from its `run::` record, says "Fetching status" until the indexing queue has answered and then Indexing, Queued, Indexed, Indexing failed or Indexing cancelled, and opening the row loads its steps ten at a time with a Load more button. Without it the history pages the indexing queue as before. |
535
+ | `readIndexProgress` | `function?` | `(service, storagePath) => Promise<{ pages_saved, pages_total } \| null>`: reads a document's `prog::<storagePath>` record, which the MCP keeps up to date while the document's pages are saved. Asked by the 10-second check of the indexing queue for files still being indexed; a row then shows "175 of 530 pages" beside its passes. Without it a row shows passes only. |
536
+ | `saveSearchFinding` | `function?` | `(finding) => Promise`: saves where a hard chat search found its answer (3+ tool calls, a cited file page) as a record in table `search_findings`: `unique_id` `find::<path>#p<page>`, `reference` `src::<path>` (a re-index removes it), the source file's own access group, and normalized tags from the question's key words and the search terms; when the page already has one, merge the new tags into it. The chat prompt checks these first and then reads the page itself, so a finding is a pointer, never a cached answer. Without it nothing is saved. |
537
+
538
+ **Removed config keys.** `clientSecretRequest`, `clientSecretRequestHistory`,
539
+ `clientSecretRequestFinalize` and `clientSecretRequestStream` are no longer read. Inject
540
+ `forwardRequest`, `forwardRequestHistory`, `forwardRequestFinalize` and `forwardRequestStream`
541
+ from skapi-js 2.1.0 or newer instead. A host that injects only the old keys gets a
542
+ "No request transport" error naming the keys to use. The engine sends the secret's name as
543
+ `secretName`, and every request names the project it runs against in `service` and `owner`.
539
544
 
540
545
  ### Display and paging helpers
541
546
 
@@ -563,6 +568,7 @@ widget rather than approximately:
563
568
  handed the pending assistant bubble, it cancels the running request on the
564
569
  server, marks the question cancelled and promotes the next queued message.
565
570
  `cancelQueuedMessage` does the same for a message still in the queue.
571
+ - **`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.
566
572
  - **`findDuplicateUpload`** and the `configureProjectSettings` reader back the
567
573
  `skipDuplicateFiles` and `webAccess` switches; see the `configureChatEngine`
568
574
  table above.
package/bunnyquery.css CHANGED
@@ -1567,6 +1567,20 @@
1567
1567
  }
1568
1568
  /* A cancel that the server refused (the pass had already finished). */
1569
1569
  .bq-index-note.is-error { color: var(--bq-danger); }
1570
+ /* "Load more" inside an opened file row: the next page of that run's steps. */
1571
+ .bq-index-more {
1572
+ display: inline-block;
1573
+ margin: 0 0.6rem 0.45rem;
1574
+ padding: 0.15rem 0.55rem;
1575
+ font: inherit;
1576
+ font-size: 0.7rem;
1577
+ color: var(--bq-main);
1578
+ background: transparent;
1579
+ border: 1px solid currentColor;
1580
+ border-radius: 999px;
1581
+ cursor: pointer;
1582
+ }
1583
+ .bq-index-more:disabled { opacity: 0.5; cursor: default; }
1570
1584
 
1571
1585
  /* ---- in-bubble file / link anchors --------------------------------------*/
1572
1586
  .bq-file-download,