bunnyquery 1.20.0 → 1.21.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
@@ -545,11 +545,15 @@ helpers. See the `.d.ts` shipped with `bunnyquery/engine`.
545
545
  | `onRequestStatus` | `function?` | `skapi.onRequestStatus`, bound to the host's skapi instance (skapi-js 2.5.0+). Required for `statusPush`. |
546
546
  | `isRequestStatusLive` | `function?` | `skapi.isRequestStatusLive`, bound to the host's skapi instance (skapi-js 2.5.0+). |
547
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. |
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. |
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. |
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. May return a promise that rejects when the write failed (not when the marker is already there): the engine then writes it again, up to 5 times. Without it the engine falls back to inference. |
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. May return a promise that rejects when the write failed: the engine then writes it again, up to 5 times. Without it the engine uses the legacy scan/probe path. |
550
550
  | `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. |
551
551
  | `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. |
552
552
  | `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. |
553
+ | `forwardRequestStatus` | `function?` | `skapi.forwardRequestStatus`, bound to the host's skapi instance (skapi-js 2.7.0+). With it and `forwardRequestRead`, the engine's reconciler follows every waiting chat turn and indexing pass with one batch status read per look (100 ids a call) instead of one poll each, and shows a queued turn running when the server says so. Without them the engine keeps its polls. |
554
+ | `forwardRequestRead` | `function?` | `skapi.forwardRequestRead` (skapi-js 2.7.0+): one request as an envelope that always carries its status. Read once per item that turned terminal; a streamed turn is read from its chunk cursor until `final_seq`, then finalized with `ifAbsent`. |
555
+ | `forwardRequestQueueCounters` | `function?` | `skapi.forwardRequestQueueCounters` (skapi-js 2.7.0+): the tiny counter rows of the queues with waiting items, read on every look; the batch status read runs only when a counter moved, on a trigger (tab shown, wake, online, socket back), or once a minute. Without it every look reads the statuses. |
556
+ | `refreshRecords` | `function?` | `(projectId) => void`: indexing of that project settled and none is left in the page's queue, so a records view should refresh. Called with no chat view too, in one tab only. |
553
557
  | `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. |
554
558
 
555
559
  **Removed config keys.** `clientSecretRequest`, `clientSecretRequestHistory`,
@@ -635,6 +639,41 @@ the user is waiting on keep polling deliberately, so their results still land in
635
639
  the cache. Server-side work is untouched either way, so pausing drops traffic,
636
640
  never progress.
637
641
 
642
+ **The reconciler.** Everything the chat shows as unfinished (chat turns, indexing
643
+ passes, by request id) is followed by one timer chain per page: every 3 seconds while
644
+ the tab is visible and anything is waiting (once a minute while status messages
645
+ arrive), once a minute while hidden only for an indexing chain the browser drives, and
646
+ at once when the user comes back (tab shown, the computer awake, the network or the
647
+ socket back, the chat reopened). A look that fails on the way changes nothing on screen
648
+ and sets `state.reconnecting` (retried after 1, 2, 4 ... 30 seconds); a lost sign-in sets
649
+ `state.signInNeeded` until `ChatSession.noteSignedIn()`. A send whose answer was lost is
650
+ found by its client reference and never sent twice; one the server never received reads
651
+ "Not sent. Retry?" and `ChatSession.retryNotSent(msg)` sends it again on the user's
652
+ click. Side effects (the next pass of a file, run:: and done:: records, finalize) run in
653
+ one tab (`navigator.locks`), and count as done only when they worked: a failed write is
654
+ tried again (up to 5 times), so `mintIndexDoneMarker` and `upsertIndexRunRecord` should
655
+ return a promise that rejects when the write failed. Opening the chat view is a return:
656
+ the host reads the first page every time the view opens (`loadHistory`), merged by id.
657
+ An indexing chain the browser drives is kept in localStorage until it ends, so a reload
658
+ carries on with its next pass. Hosts tell the engine about a view opening
659
+ (`noteViewOpened()`), passes they push to `bgTaskQueue` (`noteBgQueueChanged()`, right
660
+ after the push) and the files whose run:: record says working
661
+ (`syncFileRuns(projectId, paths, info)`, `info[path] = { owner, filename }` from the
662
+ record, with the optional `ChatHost.recheckFileRuns(projectId, paths)` to re-read those
663
+ records). A run of the signed-in user's own whose browser chain was lost is closed as an
664
+ error once its queue is idle. With
665
+ the batch reads the engine follows `bgTaskQueue` with or without a chat view, so a host's
666
+ own poller of that queue stands down while `ChatSession.followsBackgroundQueue()` is true.
667
+ Items sent under another identity (signed out, another account) are left as they are
668
+ until that user signs in again. Both chat views show those two states in the same words,
669
+ "Reconnecting..." and "Sign in to see the latest answers." (class `bq-chat-status`).
670
+ A page that draws indexing state from the background queue without a chat view (a
671
+ files page) watches it on the same chain: `ChatSession.watchIndexQueue({ identity,
672
+ wantsConfirm, runsOpen, recheckRuns })` reads it at once, on every return, on a status
673
+ message about it, every 8 seconds while it holds work and every 2.5 seconds while the
674
+ page waits for a second look, and puts the answer in `state.indexQueues[projectId]`
675
+ (`stop()` when the page goes). `awaitIndexingDrained` reads the queue the same way.
676
+
638
677
  ## OAuth & redirects
639
678
 
640
679
  BunnyQuery connects to your AI agent through an MCP OAuth server
@@ -647,8 +686,10 @@ needed; just make sure the page that hosts the widget is a stable, reachable URL
647
686
  Once granted, the connection is kept alive **silently**. When the stored grant
648
687
  ages out, BunnyQuery refreshes it through the OAuth `refresh_token` flow with no
649
688
  redirect, so an embedded widget never yanks the host page away mid-chat. It also
650
- refreshes on tab focus, because returning to a backgrounded tab after the grant
651
- expired would otherwise disconnect the next message. The full redirect is only a
689
+ refreshes on tab focus when the grant has aged out, because returning to a
690
+ backgrounded tab after the grant expired would otherwise disconnect the next
691
+ message. Nothing on return waits for that refresh: the chat reads its answers with
692
+ the skapi sign-in alone. The full redirect is only a
652
693
  boot-time fallback for when the silent path cannot refresh.
653
694
 
654
695
  ## Notes
package/bunnyquery.css CHANGED
@@ -696,6 +696,39 @@
696
696
  padding: 0;
697
697
  }
698
698
 
699
+ /* "Reconnecting..." / "Sign in to see the latest answers." between the list and
700
+ the composer. The shared look (text size and colour) is .bq-chat-status in
701
+ styles/chat.css, which comes later in bunnyquery.css and wins over the plain
702
+ fallback here. Widget-only layout: zero height in flow, like the history bar
703
+ above, so the note coming and going never moves the list; its strip overlays
704
+ the bottom of the list instead. */
705
+ .bq-chat-status {
706
+ font-size: 0.75rem;
707
+ color: var(--bq-muted);
708
+ }
709
+ .bq-chat > .bq-chat-status {
710
+ position: relative;
711
+ z-index: 2;
712
+ flex-shrink: 0;
713
+ height: 0;
714
+ margin: 0;
715
+ padding: 0;
716
+ border: 0;
717
+ background: none;
718
+ overflow: visible;
719
+ pointer-events: none;
720
+ }
721
+ .bq-chat > .bq-chat-status[hidden] { display: none; }
722
+ .bq-chat-status-inner {
723
+ position: absolute;
724
+ left: 0;
725
+ right: 0;
726
+ bottom: 0;
727
+ padding: 0.9rem 1.25rem 0.3rem;
728
+ text-align: center;
729
+ background: linear-gradient(to top, color-mix(in srgb, var(--bq-paper) 85%, transparent) 60%, transparent);
730
+ }
731
+
699
732
  /* "admin hasn't set up the agent" / disabled overlay */
700
733
  .bq-disabled-overlay {
701
734
  position: absolute;
@@ -1084,6 +1117,7 @@
1084
1117
  @media (max-width: 600px) {
1085
1118
  /* .bq-meta { padding: 0.75rem; } */
1086
1119
  .bq-input-row { flex-direction: column; padding: 0.65rem 0.75rem 0.75rem; }
1120
+ .bq-chat-status-inner { padding-left: 0.75rem; padding-right: 0.75rem; }
1087
1121
  .bq-input-wrap { width: 100%; flex: 0 0 auto; }
1088
1122
  .bq-input-row .btn { width: 100%; }
1089
1123
  /* `flex-basis: 100%` on these two means FULL WIDTH only while the row is a
@@ -1258,6 +1292,21 @@
1258
1292
  font-style: italic;
1259
1293
  clear: both;
1260
1294
  }
1295
+ /* ---- connection note ----------------------------------------------------*/
1296
+ /* The reconciler's two flags (engine state.reconnecting, state.signInNeeded) as one
1297
+ short line by the composer: "Reconnecting..." or "Sign in to see the latest
1298
+ answers.". The LOOK only, shared by both chat clients; where it sits is each
1299
+ client's own layout (agent.vue: a line of the composer row; the widget: a
1300
+ zero-height strip over the bottom of the list, widget.css). Never a colour that
1301
+ reads as an error: nothing on screen is wrong, it is only not being refreshed
1302
+ right now. */
1303
+ .bq-chat-status {
1304
+ font-size: 0.7rem;
1305
+ font-style: italic;
1306
+ line-height: 1.3;
1307
+ text-align: center;
1308
+ color: var(--bq-muted);
1309
+ }
1261
1310
  /* ---- citations + the no-source mark -------------------------------------*/
1262
1311
  /* Under an answer that read something: one chip per cited file (and page, in
1263
1312
  the label only). The chips are the ordinary stored-file link chips