bunnyquery 1.10.8 → 1.10.11
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/bunnyquery.js +47 -6
- package/dist/engine.cjs +46 -5
- package/dist/engine.cjs.map +1 -1
- package/dist/engine.d.mts +19 -1
- package/dist/engine.d.ts +19 -1
- package/dist/engine.mjs +46 -5
- package/dist/engine.mjs.map +1 -1
- package/package.json +1 -1
- package/src/engine/requests.ts +5 -1
- package/src/engine/session.ts +80 -4
package/dist/engine.d.mts
CHANGED
|
@@ -2082,6 +2082,9 @@ type BgTaskEntry = {
|
|
|
2082
2082
|
status: 'running' | 'pending';
|
|
2083
2083
|
poll: ((opts: {
|
|
2084
2084
|
latency: number;
|
|
2085
|
+
onResponse?: (res: any, meta?: {
|
|
2086
|
+
executed?: number;
|
|
2087
|
+
}) => void;
|
|
2085
2088
|
}) => Promise<any>) | undefined;
|
|
2086
2089
|
/** How many CONTINUE passes have already run for this file (resume-across-passes). */
|
|
2087
2090
|
resumePass?: number;
|
|
@@ -4309,7 +4312,22 @@ declare class ChatSession {
|
|
|
4309
4312
|
private _isOwnPlaceholderOf;
|
|
4310
4313
|
_clearPendingUserBubble(itemId: string): void;
|
|
4311
4314
|
resumePendingRequest(token: number): Promise<void>;
|
|
4312
|
-
|
|
4315
|
+
/** Record how long a background indexing pass took, on the bubble that just
|
|
4316
|
+
* settled, so the duration shows immediately instead of waiting for whatever
|
|
4317
|
+
* next refetches history.
|
|
4318
|
+
*
|
|
4319
|
+
* `_tsStart` is otherwise written only by the history mapper, which reads the
|
|
4320
|
+
* row's `executed`; a live settle never sees the row at all (the poll resolves
|
|
4321
|
+
* with the destination's body). This is the same value by the other route.
|
|
4322
|
+
*
|
|
4323
|
+
* `_ts` is stamped too when the branch that built the bubble left it without
|
|
4324
|
+
* one: it is the END of the pass, and the pass ended now. A later history load
|
|
4325
|
+
* replaces both with the server's own numbers.
|
|
4326
|
+
*
|
|
4327
|
+
* Indexing passes only: an ordinary turn has no duration to show, and
|
|
4328
|
+
* `_tsStart`'s presence is what both views read to decide. */
|
|
4329
|
+
private _stampPassDuration;
|
|
4330
|
+
handleHistoryItemResolution(itemId: string, response: any, platform: string, executedAt?: number): void;
|
|
4313
4331
|
/** The file an already-rendered background pass is about, off its request
|
|
4314
4332
|
* bubble. Null for an ordinary turn, which is most of them. */
|
|
4315
4333
|
private _indexRefOfItem;
|
package/dist/engine.d.ts
CHANGED
|
@@ -2082,6 +2082,9 @@ type BgTaskEntry = {
|
|
|
2082
2082
|
status: 'running' | 'pending';
|
|
2083
2083
|
poll: ((opts: {
|
|
2084
2084
|
latency: number;
|
|
2085
|
+
onResponse?: (res: any, meta?: {
|
|
2086
|
+
executed?: number;
|
|
2087
|
+
}) => void;
|
|
2085
2088
|
}) => Promise<any>) | undefined;
|
|
2086
2089
|
/** How many CONTINUE passes have already run for this file (resume-across-passes). */
|
|
2087
2090
|
resumePass?: number;
|
|
@@ -4309,7 +4312,22 @@ declare class ChatSession {
|
|
|
4309
4312
|
private _isOwnPlaceholderOf;
|
|
4310
4313
|
_clearPendingUserBubble(itemId: string): void;
|
|
4311
4314
|
resumePendingRequest(token: number): Promise<void>;
|
|
4312
|
-
|
|
4315
|
+
/** Record how long a background indexing pass took, on the bubble that just
|
|
4316
|
+
* settled, so the duration shows immediately instead of waiting for whatever
|
|
4317
|
+
* next refetches history.
|
|
4318
|
+
*
|
|
4319
|
+
* `_tsStart` is otherwise written only by the history mapper, which reads the
|
|
4320
|
+
* row's `executed`; a live settle never sees the row at all (the poll resolves
|
|
4321
|
+
* with the destination's body). This is the same value by the other route.
|
|
4322
|
+
*
|
|
4323
|
+
* `_ts` is stamped too when the branch that built the bubble left it without
|
|
4324
|
+
* one: it is the END of the pass, and the pass ended now. A later history load
|
|
4325
|
+
* replaces both with the server's own numbers.
|
|
4326
|
+
*
|
|
4327
|
+
* Indexing passes only: an ordinary turn has no duration to show, and
|
|
4328
|
+
* `_tsStart`'s presence is what both views read to decide. */
|
|
4329
|
+
private _stampPassDuration;
|
|
4330
|
+
handleHistoryItemResolution(itemId: string, response: any, platform: string, executedAt?: number): void;
|
|
4313
4331
|
/** The file an already-rendered background pass is about, off its request
|
|
4314
4332
|
* bubble. Null for an ordinary turn, which is most of them. */
|
|
4315
4333
|
private _indexRefOfItem;
|
package/dist/engine.mjs
CHANGED
|
@@ -6548,9 +6548,39 @@ var ChatSession = class {
|
|
|
6548
6548
|
});
|
|
6549
6549
|
}
|
|
6550
6550
|
// --- background-task resolution + drain -------------------------------
|
|
6551
|
-
|
|
6551
|
+
/** Record how long a background indexing pass took, on the bubble that just
|
|
6552
|
+
* settled, so the duration shows immediately instead of waiting for whatever
|
|
6553
|
+
* next refetches history.
|
|
6554
|
+
*
|
|
6555
|
+
* `_tsStart` is otherwise written only by the history mapper, which reads the
|
|
6556
|
+
* row's `executed`; a live settle never sees the row at all (the poll resolves
|
|
6557
|
+
* with the destination's body). This is the same value by the other route.
|
|
6558
|
+
*
|
|
6559
|
+
* `_ts` is stamped too when the branch that built the bubble left it without
|
|
6560
|
+
* one: it is the END of the pass, and the pass ended now. A later history load
|
|
6561
|
+
* replaces both with the server's own numbers.
|
|
6562
|
+
*
|
|
6563
|
+
* Indexing passes only: an ordinary turn has no duration to show, and
|
|
6564
|
+
* `_tsStart`'s presence is what both views read to decide. */
|
|
6565
|
+
_stampPassDuration(itemId, executedAt) {
|
|
6566
|
+
if (!itemId) return;
|
|
6567
|
+
if (!this._indexRefOfItem(itemId)) return;
|
|
6568
|
+
var hasStart = typeof executedAt === "number" && executedAt > 0;
|
|
6569
|
+
for (var i = this.state.messages.length - 1; i >= 0; i--) {
|
|
6570
|
+
var m = this.state.messages[i];
|
|
6571
|
+
if (!m || m.role !== "assistant" || m._serverItemId !== itemId) continue;
|
|
6572
|
+
if (m.isPending) continue;
|
|
6573
|
+
if (typeof m._ts !== "number") m._ts = Date.now();
|
|
6574
|
+
if (hasStart) m._tsStart = executedAt;
|
|
6575
|
+
this.host.notify();
|
|
6576
|
+
this.updateHistoryCache();
|
|
6577
|
+
break;
|
|
6578
|
+
}
|
|
6579
|
+
}
|
|
6580
|
+
handleHistoryItemResolution(itemId, response, platform, executedAt) {
|
|
6552
6581
|
var indexRef = this._indexRefOfItem(itemId);
|
|
6553
6582
|
this.applyHistoryItemResolution(itemId, response, platform);
|
|
6583
|
+
this._stampPassDuration(itemId, executedAt);
|
|
6554
6584
|
this.promoteNextBgQueuedToRunning();
|
|
6555
6585
|
this.drainBgTaskQueue();
|
|
6556
6586
|
if (indexRef) this._followWorkerIndexingChain(indexRef.name, indexRef.mime);
|
|
@@ -6997,14 +7027,20 @@ var ChatSession = class {
|
|
|
6997
7027
|
var capturedId = entry2.id, capturedPlat = plat;
|
|
6998
7028
|
var capturedEntry = entry2;
|
|
6999
7029
|
var wasStopped = false;
|
|
7000
|
-
var
|
|
7030
|
+
var executedAt;
|
|
7031
|
+
var bp = entry2.poll({
|
|
7032
|
+
latency: POLL_INTERVAL,
|
|
7033
|
+
onResponse: function(_res, meta) {
|
|
7034
|
+
if (meta && typeof meta.executed === "number" && meta.executed > 0) executedAt = meta.executed;
|
|
7035
|
+
}
|
|
7036
|
+
});
|
|
7001
7037
|
self._trackPoll(entry2.id, "bg", bp);
|
|
7002
7038
|
bp.then(function(response) {
|
|
7003
7039
|
if (isPollStopped(response)) {
|
|
7004
7040
|
wasStopped = true;
|
|
7005
7041
|
return;
|
|
7006
7042
|
}
|
|
7007
|
-
self.handleHistoryItemResolution(capturedId, response, capturedPlat);
|
|
7043
|
+
self.handleHistoryItemResolution(capturedId, response, capturedPlat, executedAt);
|
|
7008
7044
|
self.maybeResumeIndexing(capturedEntry, response, capturedPlat);
|
|
7009
7045
|
}).catch(function(err) {
|
|
7010
7046
|
self.historyItemPolls.delete(capturedId);
|
|
@@ -7573,9 +7609,14 @@ var ChatSession = class {
|
|
|
7573
7609
|
var capturedId = item.id;
|
|
7574
7610
|
var isBg = !!(item._isBgTask || item._isOnBgQueue);
|
|
7575
7611
|
var pollOpts = {
|
|
7576
|
-
|
|
7612
|
+
// `meta.executed` rides on the poll's running ticks, so a pass this
|
|
7613
|
+
// path re-attached to (a reload or a remount while its chain was
|
|
7614
|
+
// still going) shows its duration at settle exactly as one polled
|
|
7615
|
+
// from the drain does. Without it, only passes started in this page
|
|
7616
|
+
// life would be stamped.
|
|
7617
|
+
onResponse: function(response, meta) {
|
|
7577
7618
|
if (isPollStopped(response)) return;
|
|
7578
|
-
self.handleHistoryItemResolution(capturedId, response, platform);
|
|
7619
|
+
self.handleHistoryItemResolution(capturedId, response, platform, meta && meta.executed);
|
|
7579
7620
|
},
|
|
7580
7621
|
onError: function(err) {
|
|
7581
7622
|
self.historyItemPolls.delete(capturedId);
|