bunnyquery 1.15.1 → 1.15.2
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 -7
- package/dist/engine.cjs +47 -6
- package/dist/engine.cjs.map +1 -1
- package/dist/engine.d.mts +32 -0
- package/dist/engine.d.ts +32 -0
- package/dist/engine.mjs +47 -6
- package/dist/engine.mjs.map +1 -1
- package/package.json +1 -1
- package/src/engine/session.ts +63 -6
package/dist/engine.d.mts
CHANGED
|
@@ -4055,6 +4055,17 @@ declare class ChatSession {
|
|
|
4055
4055
|
/** Files this client has an index dispatch in flight for, by scoped path ->
|
|
4056
4056
|
* wall clock. See claimIndexRun. */
|
|
4057
4057
|
private _indexClaims;
|
|
4058
|
+
/** bgTaskQueue by the SAME scoped path the claims use -> how many entries
|
|
4059
|
+
* name that file. Derived from the array, never written to directly: see
|
|
4060
|
+
* _bgQueueIndex for when it is rebuilt and why that is exact. */
|
|
4061
|
+
private _bgQueueByFile;
|
|
4062
|
+
/** What _bgQueueByFile was built from: the array itself, its length and its
|
|
4063
|
+
* first and last entries. Equal stamp = equal contents (see _bgQueueIndex). */
|
|
4064
|
+
private _bgQueueStamp;
|
|
4065
|
+
/** How many times the index was rebuilt. Diagnostics and tests only: a
|
|
4066
|
+
* 3,000-file batch should build it a few thousand times at most (once per
|
|
4067
|
+
* push or settle), never once per claim. */
|
|
4068
|
+
_bgQueueIndexRebuilds: number;
|
|
4058
4069
|
constructor(host: ChatHost);
|
|
4059
4070
|
/** What the display layer needs to decide whether a run is finished. `keys` holds
|
|
4060
4071
|
* every file the server still has indexing work for; `checked` is false until the
|
|
@@ -4096,6 +4107,27 @@ declare class ChatSession {
|
|
|
4096
4107
|
/** Storage paths are project-relative, and one ChatSession serves every
|
|
4097
4108
|
* project, so a claim has to be scoped the way a stop is (_indexKeyOf). */
|
|
4098
4109
|
private _indexClaimKey;
|
|
4110
|
+
/**
|
|
4111
|
+
* bgTaskQueue as a map: scoped path (indexScopeKey(projectId, platform) +
|
|
4112
|
+
* '|' + storagePath, the key the claims and the stops use) -> entries.
|
|
4113
|
+
*
|
|
4114
|
+
* The array stays the source of truth because the engine does not own every
|
|
4115
|
+
* write to it: both hosts hand in their own array (the dashboard a Vue
|
|
4116
|
+
* reactive one it pushes to from the Files page and splices from its
|
|
4117
|
+
* fallback poller), and tests push to it directly. So the map is DERIVED, and
|
|
4118
|
+
* rebuilt when a cheap stamp says the array changed: its identity, its length,
|
|
4119
|
+
* its first and its last entry.
|
|
4120
|
+
*
|
|
4121
|
+
* Why that stamp is exact for this array: every write to bgTaskQueue is either
|
|
4122
|
+
* a push of a NEW entry object or a splice that removes one (nothing inserts
|
|
4123
|
+
* in the middle, replaces in place or re-pushes a removed entry). Under those
|
|
4124
|
+
* two operations, same length plus same last entry means the same contents:
|
|
4125
|
+
* a push changes the last entry unless that same push is removed again, and a
|
|
4126
|
+
* removal changes the length unless a push restores it, which changes the
|
|
4127
|
+
* last entry. The first entry is in the stamp as margin. A rebuild is one
|
|
4128
|
+
* pass over the array, paid once per change instead of once per claim.
|
|
4129
|
+
*/
|
|
4130
|
+
private _bgQueueIndex;
|
|
4099
4131
|
/**
|
|
4100
4132
|
* Take this file's indexing slot, or report that someone already has it.
|
|
4101
4133
|
*
|
package/dist/engine.d.ts
CHANGED
|
@@ -4055,6 +4055,17 @@ declare class ChatSession {
|
|
|
4055
4055
|
/** Files this client has an index dispatch in flight for, by scoped path ->
|
|
4056
4056
|
* wall clock. See claimIndexRun. */
|
|
4057
4057
|
private _indexClaims;
|
|
4058
|
+
/** bgTaskQueue by the SAME scoped path the claims use -> how many entries
|
|
4059
|
+
* name that file. Derived from the array, never written to directly: see
|
|
4060
|
+
* _bgQueueIndex for when it is rebuilt and why that is exact. */
|
|
4061
|
+
private _bgQueueByFile;
|
|
4062
|
+
/** What _bgQueueByFile was built from: the array itself, its length and its
|
|
4063
|
+
* first and last entries. Equal stamp = equal contents (see _bgQueueIndex). */
|
|
4064
|
+
private _bgQueueStamp;
|
|
4065
|
+
/** How many times the index was rebuilt. Diagnostics and tests only: a
|
|
4066
|
+
* 3,000-file batch should build it a few thousand times at most (once per
|
|
4067
|
+
* push or settle), never once per claim. */
|
|
4068
|
+
_bgQueueIndexRebuilds: number;
|
|
4058
4069
|
constructor(host: ChatHost);
|
|
4059
4070
|
/** What the display layer needs to decide whether a run is finished. `keys` holds
|
|
4060
4071
|
* every file the server still has indexing work for; `checked` is false until the
|
|
@@ -4096,6 +4107,27 @@ declare class ChatSession {
|
|
|
4096
4107
|
/** Storage paths are project-relative, and one ChatSession serves every
|
|
4097
4108
|
* project, so a claim has to be scoped the way a stop is (_indexKeyOf). */
|
|
4098
4109
|
private _indexClaimKey;
|
|
4110
|
+
/**
|
|
4111
|
+
* bgTaskQueue as a map: scoped path (indexScopeKey(projectId, platform) +
|
|
4112
|
+
* '|' + storagePath, the key the claims and the stops use) -> entries.
|
|
4113
|
+
*
|
|
4114
|
+
* The array stays the source of truth because the engine does not own every
|
|
4115
|
+
* write to it: both hosts hand in their own array (the dashboard a Vue
|
|
4116
|
+
* reactive one it pushes to from the Files page and splices from its
|
|
4117
|
+
* fallback poller), and tests push to it directly. So the map is DERIVED, and
|
|
4118
|
+
* rebuilt when a cheap stamp says the array changed: its identity, its length,
|
|
4119
|
+
* its first and its last entry.
|
|
4120
|
+
*
|
|
4121
|
+
* Why that stamp is exact for this array: every write to bgTaskQueue is either
|
|
4122
|
+
* a push of a NEW entry object or a splice that removes one (nothing inserts
|
|
4123
|
+
* in the middle, replaces in place or re-pushes a removed entry). Under those
|
|
4124
|
+
* two operations, same length plus same last entry means the same contents:
|
|
4125
|
+
* a push changes the last entry unless that same push is removed again, and a
|
|
4126
|
+
* removal changes the length unless a push restores it, which changes the
|
|
4127
|
+
* last entry. The first entry is in the stamp as margin. A rebuild is one
|
|
4128
|
+
* pass over the array, paid once per change instead of once per claim.
|
|
4129
|
+
*/
|
|
4130
|
+
private _bgQueueIndex;
|
|
4099
4131
|
/**
|
|
4100
4132
|
* Take this file's indexing slot, or report that someone already has it.
|
|
4101
4133
|
*
|
package/dist/engine.mjs
CHANGED
|
@@ -4536,6 +4536,9 @@ var ChatSession = class {
|
|
|
4536
4536
|
this._liveIndexKey = "";
|
|
4537
4537
|
this._liveIndexAt = 0;
|
|
4538
4538
|
this._indexClaims = {};
|
|
4539
|
+
this._bgQueueByFile = null;
|
|
4540
|
+
this._bgQueueStamp = { arr: null, length: 0, first: void 0, last: void 0 };
|
|
4541
|
+
this._bgQueueIndexRebuilds = 0;
|
|
4539
4542
|
}
|
|
4540
4543
|
/** What the display layer needs to decide whether a run is finished. `keys` holds
|
|
4541
4544
|
* every file the server still has indexing work for; `checked` is false until the
|
|
@@ -4572,13 +4575,10 @@ var ChatSession = class {
|
|
|
4572
4575
|
*/
|
|
4573
4576
|
hasLiveIndexRun(storagePath) {
|
|
4574
4577
|
if (!storagePath) return false;
|
|
4575
|
-
var
|
|
4578
|
+
var scoped = this._indexClaimKey(storagePath);
|
|
4579
|
+
var claimed = this._indexClaims[scoped];
|
|
4576
4580
|
if (claimed && nowMs() - claimed < INDEX_DISPATCH_CLAIM_MS) return true;
|
|
4577
|
-
|
|
4578
|
-
for (var i = 0; i < this.bgTaskQueue.length; i++) {
|
|
4579
|
-
var e = this.bgTaskQueue[i];
|
|
4580
|
-
if (e && e.storagePath === storagePath && e.projectId === id.projectId && e.platform === id.platform) return true;
|
|
4581
|
-
}
|
|
4581
|
+
if (this._bgQueueIndex()[scoped] > 0) return true;
|
|
4582
4582
|
return this.state.messages.some(function(m) {
|
|
4583
4583
|
if (!m.isBackgroundTask || m.role !== "user" || m.isCancelled) return false;
|
|
4584
4584
|
if (!(m.isPendingQueued || m.isPendingInProcess || m.isSendingToServer)) return false;
|
|
@@ -4591,6 +4591,47 @@ var ChatSession = class {
|
|
|
4591
4591
|
var id = this.host.getIdentity();
|
|
4592
4592
|
return indexScopeKey(id.projectId, id.platform) + "|" + storagePath;
|
|
4593
4593
|
}
|
|
4594
|
+
/**
|
|
4595
|
+
* bgTaskQueue as a map: scoped path (indexScopeKey(projectId, platform) +
|
|
4596
|
+
* '|' + storagePath, the key the claims and the stops use) -> entries.
|
|
4597
|
+
*
|
|
4598
|
+
* The array stays the source of truth because the engine does not own every
|
|
4599
|
+
* write to it: both hosts hand in their own array (the dashboard a Vue
|
|
4600
|
+
* reactive one it pushes to from the Files page and splices from its
|
|
4601
|
+
* fallback poller), and tests push to it directly. So the map is DERIVED, and
|
|
4602
|
+
* rebuilt when a cheap stamp says the array changed: its identity, its length,
|
|
4603
|
+
* its first and its last entry.
|
|
4604
|
+
*
|
|
4605
|
+
* Why that stamp is exact for this array: every write to bgTaskQueue is either
|
|
4606
|
+
* a push of a NEW entry object or a splice that removes one (nothing inserts
|
|
4607
|
+
* in the middle, replaces in place or re-pushes a removed entry). Under those
|
|
4608
|
+
* two operations, same length plus same last entry means the same contents:
|
|
4609
|
+
* a push changes the last entry unless that same push is removed again, and a
|
|
4610
|
+
* removal changes the length unless a push restores it, which changes the
|
|
4611
|
+
* last entry. The first entry is in the stamp as margin. A rebuild is one
|
|
4612
|
+
* pass over the array, paid once per change instead of once per claim.
|
|
4613
|
+
*/
|
|
4614
|
+
_bgQueueIndex() {
|
|
4615
|
+
var q = this.bgTaskQueue;
|
|
4616
|
+
var n = q ? q.length : 0;
|
|
4617
|
+
var first = n ? q[0] : void 0;
|
|
4618
|
+
var last = n ? q[n - 1] : void 0;
|
|
4619
|
+
var st = this._bgQueueStamp;
|
|
4620
|
+
if (this._bgQueueByFile && st.arr === q && st.length === n && st.first === first && st.last === last) {
|
|
4621
|
+
return this._bgQueueByFile;
|
|
4622
|
+
}
|
|
4623
|
+
var idx = {};
|
|
4624
|
+
for (var i = 0; i < n; i++) {
|
|
4625
|
+
var e = q[i];
|
|
4626
|
+
if (!e || !e.storagePath) continue;
|
|
4627
|
+
var k = indexScopeKey(e.projectId, e.platform) + "|" + e.storagePath;
|
|
4628
|
+
idx[k] = (idx[k] || 0) + 1;
|
|
4629
|
+
}
|
|
4630
|
+
this._bgQueueByFile = idx;
|
|
4631
|
+
this._bgQueueStamp = { arr: q, length: n, first, last };
|
|
4632
|
+
this._bgQueueIndexRebuilds++;
|
|
4633
|
+
return idx;
|
|
4634
|
+
}
|
|
4594
4635
|
/**
|
|
4595
4636
|
* Take this file's indexing slot, or report that someone already has it.
|
|
4596
4637
|
*
|