bunnyquery 1.10.7 → 1.10.10
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 +48 -6
- package/dist/engine.cjs +47 -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 +47 -5
- package/dist/engine.mjs.map +1 -1
- package/package.json +1 -1
- package/src/engine/history.ts +7 -0
- package/src/engine/requests.ts +5 -1
- package/src/engine/session.ts +80 -4
package/bunnyquery.js
CHANGED
|
@@ -3102,6 +3102,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
3102
3102
|
if (item._isBgTask) em.isBackgroundTask = true;
|
|
3103
3103
|
if (serverItemId !== void 0) em._serverItemId = serverItemId;
|
|
3104
3104
|
if (replyTs !== void 0) em._ts = replyTs;
|
|
3105
|
+
if (indexFile && isFinite(executedTs) && executedTs > 0) em._tsStart = executedTs;
|
|
3105
3106
|
mapped.push(em);
|
|
3106
3107
|
} else if (isStreamPending) {
|
|
3107
3108
|
var sp = { role: "assistant", content: "", _streamPending: true };
|
|
@@ -6405,9 +6406,39 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
6405
6406
|
});
|
|
6406
6407
|
}
|
|
6407
6408
|
// --- background-task resolution + drain -------------------------------
|
|
6408
|
-
|
|
6409
|
+
/** Record how long a background indexing pass took, on the bubble that just
|
|
6410
|
+
* settled, so the duration shows immediately instead of waiting for whatever
|
|
6411
|
+
* next refetches history.
|
|
6412
|
+
*
|
|
6413
|
+
* `_tsStart` is otherwise written only by the history mapper, which reads the
|
|
6414
|
+
* row's `executed`; a live settle never sees the row at all (the poll resolves
|
|
6415
|
+
* with the destination's body). This is the same value by the other route.
|
|
6416
|
+
*
|
|
6417
|
+
* `_ts` is stamped too when the branch that built the bubble left it without
|
|
6418
|
+
* one: it is the END of the pass, and the pass ended now. A later history load
|
|
6419
|
+
* replaces both with the server's own numbers.
|
|
6420
|
+
*
|
|
6421
|
+
* Indexing passes only: an ordinary turn has no duration to show, and
|
|
6422
|
+
* `_tsStart`'s presence is what both views read to decide. */
|
|
6423
|
+
_stampPassDuration(itemId, executedAt) {
|
|
6424
|
+
if (!itemId) return;
|
|
6425
|
+
if (!this._indexRefOfItem(itemId)) return;
|
|
6426
|
+
var hasStart = typeof executedAt === "number" && executedAt > 0;
|
|
6427
|
+
for (var i = this.state.messages.length - 1; i >= 0; i--) {
|
|
6428
|
+
var m = this.state.messages[i];
|
|
6429
|
+
if (!m || m.role !== "assistant" || m._serverItemId !== itemId) continue;
|
|
6430
|
+
if (m.isPending) continue;
|
|
6431
|
+
if (typeof m._ts !== "number") m._ts = Date.now();
|
|
6432
|
+
if (hasStart) m._tsStart = executedAt;
|
|
6433
|
+
this.host.notify();
|
|
6434
|
+
this.updateHistoryCache();
|
|
6435
|
+
break;
|
|
6436
|
+
}
|
|
6437
|
+
}
|
|
6438
|
+
handleHistoryItemResolution(itemId, response, platform, executedAt) {
|
|
6409
6439
|
var indexRef = this._indexRefOfItem(itemId);
|
|
6410
6440
|
this.applyHistoryItemResolution(itemId, response, platform);
|
|
6441
|
+
this._stampPassDuration(itemId, executedAt);
|
|
6411
6442
|
this.promoteNextBgQueuedToRunning();
|
|
6412
6443
|
this.drainBgTaskQueue();
|
|
6413
6444
|
if (indexRef) this._followWorkerIndexingChain(indexRef.name, indexRef.mime);
|
|
@@ -6854,14 +6885,20 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
6854
6885
|
var capturedId = entry2.id, capturedPlat = plat;
|
|
6855
6886
|
var capturedEntry = entry2;
|
|
6856
6887
|
var wasStopped = false;
|
|
6857
|
-
var
|
|
6888
|
+
var executedAt;
|
|
6889
|
+
var bp = entry2.poll({
|
|
6890
|
+
latency: POLL_INTERVAL,
|
|
6891
|
+
onResponse: function(_res, meta) {
|
|
6892
|
+
if (meta && typeof meta.executed === "number" && meta.executed > 0) executedAt = meta.executed;
|
|
6893
|
+
}
|
|
6894
|
+
});
|
|
6858
6895
|
self._trackPoll(entry2.id, "bg", bp);
|
|
6859
6896
|
bp.then(function(response) {
|
|
6860
6897
|
if (isPollStopped(response)) {
|
|
6861
6898
|
wasStopped = true;
|
|
6862
6899
|
return;
|
|
6863
6900
|
}
|
|
6864
|
-
self.handleHistoryItemResolution(capturedId, response, capturedPlat);
|
|
6901
|
+
self.handleHistoryItemResolution(capturedId, response, capturedPlat, executedAt);
|
|
6865
6902
|
self.maybeResumeIndexing(capturedEntry, response, capturedPlat);
|
|
6866
6903
|
}).catch(function(err) {
|
|
6867
6904
|
self.historyItemPolls.delete(capturedId);
|
|
@@ -7430,9 +7467,14 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
7430
7467
|
var capturedId = item.id;
|
|
7431
7468
|
var isBg = !!(item._isBgTask || item._isOnBgQueue);
|
|
7432
7469
|
var pollOpts = {
|
|
7433
|
-
|
|
7470
|
+
// `meta.executed` rides on the poll's running ticks, so a pass this
|
|
7471
|
+
// path re-attached to (a reload or a remount while its chain was
|
|
7472
|
+
// still going) shows its duration at settle exactly as one polled
|
|
7473
|
+
// from the drain does. Without it, only passes started in this page
|
|
7474
|
+
// life would be stamped.
|
|
7475
|
+
onResponse: function(response, meta) {
|
|
7434
7476
|
if (isPollStopped(response)) return;
|
|
7435
|
-
self.handleHistoryItemResolution(capturedId, response, platform);
|
|
7477
|
+
self.handleHistoryItemResolution(capturedId, response, platform, meta && meta.executed);
|
|
7436
7478
|
},
|
|
7437
7479
|
onError: function(err) {
|
|
7438
7480
|
self.historyItemPolls.delete(capturedId);
|
|
@@ -8277,7 +8319,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
|
|
|
8277
8319
|
(function() {
|
|
8278
8320
|
var MCP_PROD = "https://mcp.broadwayinc.computer";
|
|
8279
8321
|
var MCP_DEV = "https://mcp-dev.broadwayinc.computer";
|
|
8280
|
-
var BQ_VERSION = "1.10.
|
|
8322
|
+
var BQ_VERSION = "1.10.10" ;
|
|
8281
8323
|
var ATTACHMENT_URL_EXPIRES_SECONDS = 600;
|
|
8282
8324
|
var GOOGLE_AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth";
|
|
8283
8325
|
var GOOGLE_TOKEN_URL = "https://oauth2.googleapis.com/token";
|
package/dist/engine.cjs
CHANGED
|
@@ -3246,6 +3246,7 @@ function mapHistoryListToMessages(list, platform, opts) {
|
|
|
3246
3246
|
if (item._isBgTask) em.isBackgroundTask = true;
|
|
3247
3247
|
if (serverItemId !== void 0) em._serverItemId = serverItemId;
|
|
3248
3248
|
if (replyTs !== void 0) em._ts = replyTs;
|
|
3249
|
+
if (indexFile && isFinite(executedTs) && executedTs > 0) em._tsStart = executedTs;
|
|
3249
3250
|
mapped.push(em);
|
|
3250
3251
|
} else if (isStreamPending) {
|
|
3251
3252
|
var sp = { role: "assistant", content: "", _streamPending: true };
|
|
@@ -6549,9 +6550,39 @@ var ChatSession = class {
|
|
|
6549
6550
|
});
|
|
6550
6551
|
}
|
|
6551
6552
|
// --- background-task resolution + drain -------------------------------
|
|
6552
|
-
|
|
6553
|
+
/** Record how long a background indexing pass took, on the bubble that just
|
|
6554
|
+
* settled, so the duration shows immediately instead of waiting for whatever
|
|
6555
|
+
* next refetches history.
|
|
6556
|
+
*
|
|
6557
|
+
* `_tsStart` is otherwise written only by the history mapper, which reads the
|
|
6558
|
+
* row's `executed`; a live settle never sees the row at all (the poll resolves
|
|
6559
|
+
* with the destination's body). This is the same value by the other route.
|
|
6560
|
+
*
|
|
6561
|
+
* `_ts` is stamped too when the branch that built the bubble left it without
|
|
6562
|
+
* one: it is the END of the pass, and the pass ended now. A later history load
|
|
6563
|
+
* replaces both with the server's own numbers.
|
|
6564
|
+
*
|
|
6565
|
+
* Indexing passes only: an ordinary turn has no duration to show, and
|
|
6566
|
+
* `_tsStart`'s presence is what both views read to decide. */
|
|
6567
|
+
_stampPassDuration(itemId, executedAt) {
|
|
6568
|
+
if (!itemId) return;
|
|
6569
|
+
if (!this._indexRefOfItem(itemId)) return;
|
|
6570
|
+
var hasStart = typeof executedAt === "number" && executedAt > 0;
|
|
6571
|
+
for (var i = this.state.messages.length - 1; i >= 0; i--) {
|
|
6572
|
+
var m = this.state.messages[i];
|
|
6573
|
+
if (!m || m.role !== "assistant" || m._serverItemId !== itemId) continue;
|
|
6574
|
+
if (m.isPending) continue;
|
|
6575
|
+
if (typeof m._ts !== "number") m._ts = Date.now();
|
|
6576
|
+
if (hasStart) m._tsStart = executedAt;
|
|
6577
|
+
this.host.notify();
|
|
6578
|
+
this.updateHistoryCache();
|
|
6579
|
+
break;
|
|
6580
|
+
}
|
|
6581
|
+
}
|
|
6582
|
+
handleHistoryItemResolution(itemId, response, platform, executedAt) {
|
|
6553
6583
|
var indexRef = this._indexRefOfItem(itemId);
|
|
6554
6584
|
this.applyHistoryItemResolution(itemId, response, platform);
|
|
6585
|
+
this._stampPassDuration(itemId, executedAt);
|
|
6555
6586
|
this.promoteNextBgQueuedToRunning();
|
|
6556
6587
|
this.drainBgTaskQueue();
|
|
6557
6588
|
if (indexRef) this._followWorkerIndexingChain(indexRef.name, indexRef.mime);
|
|
@@ -6998,14 +7029,20 @@ var ChatSession = class {
|
|
|
6998
7029
|
var capturedId = entry2.id, capturedPlat = plat;
|
|
6999
7030
|
var capturedEntry = entry2;
|
|
7000
7031
|
var wasStopped = false;
|
|
7001
|
-
var
|
|
7032
|
+
var executedAt;
|
|
7033
|
+
var bp = entry2.poll({
|
|
7034
|
+
latency: POLL_INTERVAL,
|
|
7035
|
+
onResponse: function(_res, meta) {
|
|
7036
|
+
if (meta && typeof meta.executed === "number" && meta.executed > 0) executedAt = meta.executed;
|
|
7037
|
+
}
|
|
7038
|
+
});
|
|
7002
7039
|
self._trackPoll(entry2.id, "bg", bp);
|
|
7003
7040
|
bp.then(function(response) {
|
|
7004
7041
|
if (isPollStopped(response)) {
|
|
7005
7042
|
wasStopped = true;
|
|
7006
7043
|
return;
|
|
7007
7044
|
}
|
|
7008
|
-
self.handleHistoryItemResolution(capturedId, response, capturedPlat);
|
|
7045
|
+
self.handleHistoryItemResolution(capturedId, response, capturedPlat, executedAt);
|
|
7009
7046
|
self.maybeResumeIndexing(capturedEntry, response, capturedPlat);
|
|
7010
7047
|
}).catch(function(err) {
|
|
7011
7048
|
self.historyItemPolls.delete(capturedId);
|
|
@@ -7574,9 +7611,14 @@ var ChatSession = class {
|
|
|
7574
7611
|
var capturedId = item.id;
|
|
7575
7612
|
var isBg = !!(item._isBgTask || item._isOnBgQueue);
|
|
7576
7613
|
var pollOpts = {
|
|
7577
|
-
|
|
7614
|
+
// `meta.executed` rides on the poll's running ticks, so a pass this
|
|
7615
|
+
// path re-attached to (a reload or a remount while its chain was
|
|
7616
|
+
// still going) shows its duration at settle exactly as one polled
|
|
7617
|
+
// from the drain does. Without it, only passes started in this page
|
|
7618
|
+
// life would be stamped.
|
|
7619
|
+
onResponse: function(response, meta) {
|
|
7578
7620
|
if (isPollStopped(response)) return;
|
|
7579
|
-
self.handleHistoryItemResolution(capturedId, response, platform);
|
|
7621
|
+
self.handleHistoryItemResolution(capturedId, response, platform, meta && meta.executed);
|
|
7580
7622
|
},
|
|
7581
7623
|
onError: function(err) {
|
|
7582
7624
|
self.historyItemPolls.delete(capturedId);
|