bunnyquery 1.19.3 → 1.20.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 +23 -2
- package/bunnyquery.css +21 -0
- package/bunnyquery.js +291 -12
- package/dist/engine.cjs +262 -8
- package/dist/engine.cjs.map +1 -1
- package/dist/engine.d.mts +96 -1
- package/dist/engine.d.ts +96 -1
- package/dist/engine.mjs +261 -9
- package/dist/engine.mjs.map +1 -1
- package/package.json +1 -1
- package/src/engine/config.ts +36 -0
- package/src/engine/index.ts +4 -0
- package/src/engine/prompts/chat_system_prompt.ts +10 -1
- package/src/engine/requests.ts +8 -2
- package/src/engine/session.ts +268 -10
- package/styles/chat.css +21 -0
package/dist/engine.cjs
CHANGED
|
@@ -257,6 +257,17 @@ function resolveForwardRequestStream() {
|
|
|
257
257
|
function windowedIndexingEnabled() {
|
|
258
258
|
return _config?.windowedIndexing === true;
|
|
259
259
|
}
|
|
260
|
+
function statusPushEnabled() {
|
|
261
|
+
return _config?.statusPush === true && typeof _config?.onRequestStatus === "function";
|
|
262
|
+
}
|
|
263
|
+
function statusPushLive() {
|
|
264
|
+
if (!statusPushEnabled() || typeof _config?.isRequestStatusLive !== "function") return false;
|
|
265
|
+
try {
|
|
266
|
+
return !!_config.isRequestStatusLive();
|
|
267
|
+
} catch (e) {
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
260
271
|
function liveStreamingSocketEnabled() {
|
|
261
272
|
return liveStreamingEnabled() && _config?.liveStreaming === true;
|
|
262
273
|
}
|
|
@@ -841,7 +852,8 @@ WHEN THE DATA DOES NOT HAVE IT, SAY SO. Once you have searched the way these rul
|
|
|
841
852
|
KEEP WHAT THE DATA SAYS APART FROM WHAT YOU WORKED OUT. A total you computed, a comparison, a trend, an interpretation or a recommendation is yours, not the data's: label it as such ("calculated from...", "this suggests...") and name the rows or files it was made from. Never present an estimate, an assumption or an inference as something the data states.
|
|
842
853
|
These three rules govern every claim about the project's data. They do not limit the About BunnyQuery section (answer product questions from it), a greeting, or text the user explicitly asks you to write.`;
|
|
843
854
|
const webRule = webAccess ? `WEB ACCESS IS ON for this project: when the user asks for something that is not in the project's data, you may search the web for it, but every such fact must be marked as coming from the web (name the site), kept apart from what the project's data says, and never used to fill in or complete a document's content or a record. This is the one exception to the four sources named above.` : `This chat has no web tool: the web is never a source here.`;
|
|
844
|
-
const documentRules = `DOCUMENTS (a contract, a report, a manual, a letter, any uploaded file the user asks about the content of): FIRST FIND THE FILE, with getFileOutline when you know its storage path, otherwise by its "src::" record (see WHERE INDEXED CONTENT LIVES) using the name the user used. THEN FIND THE PAGE with searchText: with the file's path when the user named a file, without a path when they did not ("find a file that contains X"), and follow its description's steps to the end, including asking the user once, after quick results, before it searches all files. QUOTE THE EXACT TEXT it returned and CITE THE FILE AND THE PAGE ("report.pdf, page 7"); never present a paraphrase as a quote. A file with no page text is read with readFileContent instead and cited by its file name
|
|
855
|
+
const documentRules = `DOCUMENTS (a contract, a report, a manual, a letter, any uploaded file the user asks about the content of): FIRST FIND THE FILE, with getFileOutline when you know its storage path, otherwise by its "src::" record (see WHERE INDEXED CONTENT LIVES) using the name the user used. THEN FIND THE PAGE with searchText: with the file's path when the user named a file, without a path when they did not ("find a file that contains X"), and follow its description's steps to the end, including asking the user once, after quick results, before it searches all files. QUOTE THE EXACT TEXT it returned and CITE THE FILE AND THE PAGE ("report.pdf, page 7"); never present a paraphrase as a quote. A file with no page text is read with readFileContent instead and cited by its file name. For a long file (a manual, a book), call getFileOutline first and search the chapter that fits with searchText page_from and page_to. When the user asks about the content of the documents, pass searchText "question": that question in the user's own words, without names or personal details that are not about the documents. Leave "question" out for anything else.
|
|
856
|
+
WRONG ANSWER: when the user says an answer is wrong (or sends "This answer seems wrong. Please check it again against the documents."), re-read the pages you cited and search again, passing searchText "question" = the user's ORIGINAL question that the disputed answer answered, never the complaint message itself. Then do exactly one of: correct the answer only; correct the answer and call correctSearchLink (when it is among your tools); or keep the answer and quote the text that supports it. Call correctSearchLink only with the page and an exact quote that prove it, and never change data on the user's word alone.`;
|
|
845
857
|
const groupIsPublic = indexGroupLiteral === '"public"' || indexGroupLiteral === "0";
|
|
846
858
|
const accessGroupRule = `THIS PROJECT INDEXES AT access_group ${indexGroupLiteral}: pass access_group ${indexGroupLiteral} EXPLICITLY on EVERY query that names a table_name, whether it filters by index, by tag or by nothing, and never rely on a default: a group left off is NOT "all groups", and any user but the project's owner is then answered from access_group 0 (public) alone${groupIsPublic ? "" : `, so a table indexed at ${indexGroupLiteral} would look empty with its records sitting right there`}. Files uploaded before the project's setting changed may sit at another group, so when a table query comes back empty, retry it in the other groups among 0, 1 and "private" before concluding there is nothing. Reference is the exception: reference ALONE spans EVERY table and EVERY access group, so getRecords with reference "src::<the file's storage path>" is the one call that returns a whole file's records wherever the indexer put them; adding table_name narrows it to that table, and access_group WITHOUT table_name fails.`;
|
|
847
859
|
let systemPrompt = `
|
|
@@ -2640,6 +2652,9 @@ async function notifyAgentSaveAttachment(info) {
|
|
|
2640
2652
|
service,
|
|
2641
2653
|
owner,
|
|
2642
2654
|
...pollOpt(),
|
|
2655
|
+
// Status push for this pass and the continuations the worker queues from it
|
|
2656
|
+
// (see ChatEngineConfig.statusPush). Absent unless the host turned it on.
|
|
2657
|
+
...statusPushEnabled() ? { notify: true } : {},
|
|
2643
2658
|
url: OPENAI_RESPONSES_API_URL,
|
|
2644
2659
|
method: "POST",
|
|
2645
2660
|
headers: {
|
|
@@ -2684,6 +2699,9 @@ async function notifyAgentSaveAttachment(info) {
|
|
|
2684
2699
|
service,
|
|
2685
2700
|
owner,
|
|
2686
2701
|
...pollOpt(),
|
|
2702
|
+
// Status push for this pass and the continuations the worker queues from it
|
|
2703
|
+
// (see ChatEngineConfig.statusPush). Absent unless the host turned it on.
|
|
2704
|
+
...statusPushEnabled() ? { notify: true } : {},
|
|
2687
2705
|
url: ANTHROPIC_MESSAGES_API_URL,
|
|
2688
2706
|
method: "POST",
|
|
2689
2707
|
headers: {
|
|
@@ -5323,6 +5341,11 @@ var INDEX_DISPATCH_CLAIM_MS = 2 * 60 * 1e3;
|
|
|
5323
5341
|
var WORKER_PASS_ADOPT_ATTEMPTS = [0, 2e3, 6e3];
|
|
5324
5342
|
var RECENT_INDEX_PASS_EVIDENCE_MS = 10 * 60 * 1e3;
|
|
5325
5343
|
var ADOPT_TICK_MS = 10 * 1e3;
|
|
5344
|
+
var STATUS_PUSH_ADOPT_TICK_MS = 60 * 1e3;
|
|
5345
|
+
var CATCH_UP_MIN_GAP_MS = 2e3;
|
|
5346
|
+
var RETURN_WATCH_MS = 15 * 1e3;
|
|
5347
|
+
var RETURN_WATCH_SLEEP_GAP_MS = 45 * 1e3;
|
|
5348
|
+
var STATUS_NUDGE_MIN_GAP_MS = 2e3;
|
|
5326
5349
|
var EARLY_PROBE_SCHEDULE_MS = [400, 900, 1700];
|
|
5327
5350
|
var INDEXING_DRAIN_BUSY_POLL_MS = 8e3;
|
|
5328
5351
|
var INDEXING_DRAIN_CONFIRM_POLL_MS = 3e3;
|
|
@@ -5464,6 +5487,12 @@ function requestIdTimeMs(rid) {
|
|
|
5464
5487
|
}
|
|
5465
5488
|
return Math.floor(v / 2 / 1e6);
|
|
5466
5489
|
}
|
|
5490
|
+
var WRONG_ANSWER_MESSAGE = "This answer seems wrong. Please check it again against the documents.";
|
|
5491
|
+
var WRONG_ANSWER_LABEL = "Wrong answer?";
|
|
5492
|
+
function canReportWrongAnswer(msg) {
|
|
5493
|
+
var note = retrievalNoteOfAnswer(msg);
|
|
5494
|
+
return !!note && !answerUsedNoDataTool(note) && !msg.isCancelled;
|
|
5495
|
+
}
|
|
5467
5496
|
var _ChatSession = class _ChatSession {
|
|
5468
5497
|
constructor(host) {
|
|
5469
5498
|
// --- live streaming ----------------------------------------------------
|
|
@@ -5513,6 +5542,10 @@ var _ChatSession = class _ChatSession {
|
|
|
5513
5542
|
// bubble can never silently revert to its 200-char head.
|
|
5514
5543
|
this._hydratedBodies = {};
|
|
5515
5544
|
this._hydratingItems = {};
|
|
5545
|
+
/** The button's label and the message it sends, read off the session so the
|
|
5546
|
+
* clients need no extra import. */
|
|
5547
|
+
this.wrongAnswerLabel = WRONG_ANSWER_LABEL;
|
|
5548
|
+
this.wrongAnswerMessage = WRONG_ANSWER_MESSAGE;
|
|
5516
5549
|
this.typewriterQueue = Promise.resolve();
|
|
5517
5550
|
/**
|
|
5518
5551
|
* Pick up indexing passes the WORKER minted, which no client ever dispatched.
|
|
@@ -5549,6 +5582,27 @@ var _ChatSession = class _ChatSession {
|
|
|
5549
5582
|
* a reload starts without it and asks once, as before. */
|
|
5550
5583
|
this._idleVerdictAt = {};
|
|
5551
5584
|
this._adoptTickTimer = null;
|
|
5585
|
+
/** Start the ADOPT_TICK_MS follow-up if this page is tracking live indexing work and
|
|
5586
|
+
* is visible. Idempotent; each tick re-checks and stops when the work is gone, the tab
|
|
5587
|
+
* is hidden (resume restarts it through refreshLiveIndexState) or the view closed. */
|
|
5588
|
+
// ── RETURN CATCH-UP + REQUEST STATUS PUSH (owner, 2026-11-23) ──────────────
|
|
5589
|
+
// The rule: when the user comes back to the chat (the tab shown again, the computer
|
|
5590
|
+
// awake again, the network or the websocket back), the chat is re-read from the
|
|
5591
|
+
// server, so nothing that happened while they were away is missing. The re-read is
|
|
5592
|
+
// loadHistory's own first-page refresh, the one every mount runs: it keeps older pages
|
|
5593
|
+
// the user loaded, keeps a send still in flight, never lets an empty answer replace a
|
|
5594
|
+
// known one, re-attaches polls to whatever is still waiting, and reads back a streamed
|
|
5595
|
+
// answer nobody finalized. Status frames (statusPush) only make things faster; they
|
|
5596
|
+
// never decide anything on screen.
|
|
5597
|
+
this._catchUpAt = 0;
|
|
5598
|
+
this._catchUpTimer = null;
|
|
5599
|
+
this._returnWatchTimer = null;
|
|
5600
|
+
this._returnWatchAt = 0;
|
|
5601
|
+
this._returnListeners = false;
|
|
5602
|
+
this._statusUnsub = null;
|
|
5603
|
+
this._statusNudgeTimer = null;
|
|
5604
|
+
this._statusNudgeAt = 0;
|
|
5605
|
+
this._statusSeenConnect = false;
|
|
5552
5606
|
/** The last COMPLETE running+pending look at this user's bg queue: which pass ids were
|
|
5553
5607
|
* live. Complete means both lists came back shorter than their limit, so a tracked pass
|
|
5554
5608
|
* missing from it really has left the queue. */
|
|
@@ -5593,6 +5647,7 @@ var _ChatSession = class _ChatSession {
|
|
|
5593
5647
|
this.historyItemPolls = /* @__PURE__ */ new Map();
|
|
5594
5648
|
this._pauseReasons = /* @__PURE__ */ new Set();
|
|
5595
5649
|
this._resuming = false;
|
|
5650
|
+
this._wrongReported = {};
|
|
5596
5651
|
this._lidSeq = 0;
|
|
5597
5652
|
this._stageSeq = 0;
|
|
5598
5653
|
this._uploadBatches = 0;
|
|
@@ -6987,8 +7042,7 @@ var _ChatSession = class _ChatSession {
|
|
|
6987
7042
|
this._resuming = true;
|
|
6988
7043
|
return Promise.resolve().then(function() {
|
|
6989
7044
|
self.drainBgTaskQueue();
|
|
6990
|
-
|
|
6991
|
-
self.refreshLiveIndexState();
|
|
7045
|
+
return self.catchUpHistory();
|
|
6992
7046
|
}).catch(function(e) {
|
|
6993
7047
|
console.error("[chat-engine] resume polling failed", e);
|
|
6994
7048
|
}).then(function() {
|
|
@@ -8219,6 +8273,54 @@ var _ChatSession = class _ChatSession {
|
|
|
8219
8273
|
}
|
|
8220
8274
|
});
|
|
8221
8275
|
}
|
|
8276
|
+
/**
|
|
8277
|
+
* Does this bubble get the "Wrong answer?" button: the free function's gate,
|
|
8278
|
+
* and only on the latest answer, because the message it sends names no answer
|
|
8279
|
+
* and the model reads it right after the last one. An answer already reported
|
|
8280
|
+
* keeps its (disabled) button after the complaint turn lands below it.
|
|
8281
|
+
*/
|
|
8282
|
+
canReportWrongAnswer(msg) {
|
|
8283
|
+
if (!canReportWrongAnswer(msg)) return false;
|
|
8284
|
+
return this.wrongAnswerReported(msg) || this._isLatestAnswer(msg);
|
|
8285
|
+
}
|
|
8286
|
+
/** True when no chat turn follows `msg` in state.messages. Indexing rows and
|
|
8287
|
+
* cancelled turns do not count (neither reaches the model's history). Matched
|
|
8288
|
+
* by identity or by item id, since agent.vue hands in reactive proxies. */
|
|
8289
|
+
_isLatestAnswer(msg) {
|
|
8290
|
+
var list = this.state.messages || [];
|
|
8291
|
+
var sid = msg._serverItemId, lid = msg._localId;
|
|
8292
|
+
for (var i = list.length - 1; i >= 0; i--) {
|
|
8293
|
+
var m = list[i];
|
|
8294
|
+
if (!m) continue;
|
|
8295
|
+
if (m === msg || m.role === "assistant" && (sid && m._serverItemId === sid || lid && m._localId === lid)) return true;
|
|
8296
|
+
if (m.isBackgroundTask || m.isCancelled) continue;
|
|
8297
|
+
return false;
|
|
8298
|
+
}
|
|
8299
|
+
return false;
|
|
8300
|
+
}
|
|
8301
|
+
/** True once this answer's "Wrong answer?" was sent (one click per answer). */
|
|
8302
|
+
wrongAnswerReported(msg) {
|
|
8303
|
+
if (!msg) return false;
|
|
8304
|
+
if (msg._wrongReported) return true;
|
|
8305
|
+
var key = msg._serverItemId || msg._localId;
|
|
8306
|
+
return !!key && !!this._wrongReported[key];
|
|
8307
|
+
}
|
|
8308
|
+
/**
|
|
8309
|
+
* The "Wrong answer?" button: sends WRONG_ANSWER_MESSAGE as an ordinary visible
|
|
8310
|
+
* user turn through dispatchComposedMessage, so it reads the same after a reload
|
|
8311
|
+
* and both clients behave alike. The answer is marked first, so the button goes
|
|
8312
|
+
* disabled at once. False when the bubble does not qualify or was already used.
|
|
8313
|
+
* `pinned` is the caller's usual pinned identity and prompt (agent.vue pins them).
|
|
8314
|
+
*/
|
|
8315
|
+
reportWrongAnswer(msg, pinned) {
|
|
8316
|
+
if (this.wrongAnswerReported(msg) || !this.canReportWrongAnswer(msg)) return false;
|
|
8317
|
+
msg._wrongReported = true;
|
|
8318
|
+
var key = msg._serverItemId || msg._localId;
|
|
8319
|
+
if (key) this._wrongReported[key] = true;
|
|
8320
|
+
this.host.notify();
|
|
8321
|
+
this.dispatchComposedMessage(WRONG_ANSWER_MESSAGE, false, void 0, void 0, void 0, pinned);
|
|
8322
|
+
return true;
|
|
8323
|
+
}
|
|
8222
8324
|
/**
|
|
8223
8325
|
* Stop waiting for the reply to the chat turn that is running now, and move on.
|
|
8224
8326
|
*
|
|
@@ -9059,9 +9161,153 @@ var _ChatSession = class _ChatSession {
|
|
|
9059
9161
|
});
|
|
9060
9162
|
return found;
|
|
9061
9163
|
}
|
|
9062
|
-
/**
|
|
9063
|
-
*
|
|
9064
|
-
*
|
|
9164
|
+
/**
|
|
9165
|
+
* Re-read the chat from the server now (see the rule above). Safe to call from any
|
|
9166
|
+
* number of triggers at once: calls within CATCH_UP_MIN_GAP_MS of the last one run
|
|
9167
|
+
* once, at the end of the gap. Nothing happens while no chat view is mounted (the
|
|
9168
|
+
* mount loads the chat anyway) or while background polling is paused (the tab is
|
|
9169
|
+
* hidden: showing it calls this again).
|
|
9170
|
+
*/
|
|
9171
|
+
catchUpHistory() {
|
|
9172
|
+
var self = this;
|
|
9173
|
+
var id = this.host.getIdentity();
|
|
9174
|
+
if (!id.projectId || id.platform === "none") return Promise.resolve();
|
|
9175
|
+
if (!this.host.isViewMounted || !this.host.isViewMounted() || this.isPollingPaused()) return Promise.resolve();
|
|
9176
|
+
this._ensureReturnWatch();
|
|
9177
|
+
var wait = this._catchUpAt + CATCH_UP_MIN_GAP_MS - Date.now();
|
|
9178
|
+
if (wait > 0) {
|
|
9179
|
+
if (!this._catchUpTimer) {
|
|
9180
|
+
this._catchUpTimer = setTimeout(function() {
|
|
9181
|
+
self._catchUpTimer = null;
|
|
9182
|
+
self.catchUpHistory();
|
|
9183
|
+
}, wait);
|
|
9184
|
+
}
|
|
9185
|
+
return Promise.resolve();
|
|
9186
|
+
}
|
|
9187
|
+
this._catchUpAt = Date.now();
|
|
9188
|
+
return this.loadHistory(false, this.state.gateRefreshToken).catch(function(e) {
|
|
9189
|
+
console.error("[chat-engine] catch-up failed", e);
|
|
9190
|
+
});
|
|
9191
|
+
}
|
|
9192
|
+
/**
|
|
9193
|
+
* Watch for the moments the user comes back without the tab being hidden first: the
|
|
9194
|
+
* computer waking from sleep (the timer finds a gap far longer than its interval),
|
|
9195
|
+
* the network coming back, a page restored from the back-forward cache. Also starts
|
|
9196
|
+
* the status push listener. Runs while a chat view is mounted and stops itself when
|
|
9197
|
+
* none is.
|
|
9198
|
+
*/
|
|
9199
|
+
_ensureReturnWatch() {
|
|
9200
|
+
var self = this;
|
|
9201
|
+
if (typeof window === "undefined") return;
|
|
9202
|
+
if (!this._returnListeners) {
|
|
9203
|
+
this._returnListeners = true;
|
|
9204
|
+
var onBack = function() {
|
|
9205
|
+
if (typeof document !== "undefined" && document.visibilityState === "hidden") return;
|
|
9206
|
+
self.catchUpHistory();
|
|
9207
|
+
};
|
|
9208
|
+
window.addEventListener("online", onBack);
|
|
9209
|
+
window.addEventListener("pageshow", function(ev) {
|
|
9210
|
+
if (ev && ev.persisted) onBack();
|
|
9211
|
+
});
|
|
9212
|
+
}
|
|
9213
|
+
this._startStatusPush();
|
|
9214
|
+
if (this._returnWatchTimer) return;
|
|
9215
|
+
this._returnWatchAt = Date.now();
|
|
9216
|
+
var look = function() {
|
|
9217
|
+
self._returnWatchTimer = null;
|
|
9218
|
+
if (!self.host.isViewMounted || !self.host.isViewMounted()) {
|
|
9219
|
+
self._stopStatusPush();
|
|
9220
|
+
return;
|
|
9221
|
+
}
|
|
9222
|
+
var now = Date.now();
|
|
9223
|
+
var gap = now - self._returnWatchAt;
|
|
9224
|
+
self._returnWatchAt = now;
|
|
9225
|
+
if (gap > RETURN_WATCH_SLEEP_GAP_MS && (typeof document === "undefined" || document.visibilityState !== "hidden")) {
|
|
9226
|
+
self.catchUpHistory();
|
|
9227
|
+
}
|
|
9228
|
+
self._returnWatchTimer = setTimeout(look, RETURN_WATCH_MS);
|
|
9229
|
+
};
|
|
9230
|
+
this._returnWatchTimer = setTimeout(look, RETURN_WATCH_MS);
|
|
9231
|
+
}
|
|
9232
|
+
/** Listen to request status frames while a chat view is mounted (statusPush on). */
|
|
9233
|
+
_startStatusPush() {
|
|
9234
|
+
if (this._statusUnsub || !statusPushEnabled()) return;
|
|
9235
|
+
var self = this;
|
|
9236
|
+
this._statusSeenConnect = false;
|
|
9237
|
+
try {
|
|
9238
|
+
var unsub = chatEngineConfig().onRequestStatus(function(ev) {
|
|
9239
|
+
self._onRequestStatus(ev);
|
|
9240
|
+
});
|
|
9241
|
+
this._statusUnsub = typeof unsub === "function" ? unsub : function() {
|
|
9242
|
+
};
|
|
9243
|
+
} catch (e) {
|
|
9244
|
+
this._statusUnsub = null;
|
|
9245
|
+
}
|
|
9246
|
+
}
|
|
9247
|
+
_stopStatusPush() {
|
|
9248
|
+
var unsub = this._statusUnsub;
|
|
9249
|
+
this._statusUnsub = null;
|
|
9250
|
+
if (this._statusNudgeTimer) {
|
|
9251
|
+
clearTimeout(this._statusNudgeTimer);
|
|
9252
|
+
this._statusNudgeTimer = null;
|
|
9253
|
+
}
|
|
9254
|
+
if (unsub) {
|
|
9255
|
+
try {
|
|
9256
|
+
unsub();
|
|
9257
|
+
} catch (e) {
|
|
9258
|
+
}
|
|
9259
|
+
}
|
|
9260
|
+
}
|
|
9261
|
+
/**
|
|
9262
|
+
* One status frame event. 'connected' (first connection, and every reconnect after a
|
|
9263
|
+
* drop, a sleep or the planned renewal) catches up, because frames sent while the
|
|
9264
|
+
* socket was down are lost. A status change of an indexing pass this page does not
|
|
9265
|
+
* poll runs the queue check now instead of at its next heartbeat; a pass that IS polled
|
|
9266
|
+
* was already woken by skapi-js itself. Chat turns are left to their own polls.
|
|
9267
|
+
*/
|
|
9268
|
+
_onRequestStatus(ev) {
|
|
9269
|
+
if (!ev || !this.host.isViewMounted()) return;
|
|
9270
|
+
if (ev.type === "connected") {
|
|
9271
|
+
if (!this._statusSeenConnect) {
|
|
9272
|
+
this._statusSeenConnect = true;
|
|
9273
|
+
return;
|
|
9274
|
+
}
|
|
9275
|
+
if (typeof document !== "undefined" && document.visibilityState === "hidden") return;
|
|
9276
|
+
this.catchUpHistory();
|
|
9277
|
+
return;
|
|
9278
|
+
}
|
|
9279
|
+
if (ev.type !== "status" || typeof ev.id !== "string") return;
|
|
9280
|
+
if (!ev.queue || !isBgIndexingQueue(ev.queue)) return;
|
|
9281
|
+
if (this.historyItemPolls.has(ev.id)) return;
|
|
9282
|
+
var tracked = false;
|
|
9283
|
+
for (var i = 0; i < this.bgTaskQueue.length; i++) {
|
|
9284
|
+
var e = this.bgTaskQueue[i];
|
|
9285
|
+
if (e && e.id === ev.id) {
|
|
9286
|
+
tracked = !e.byListing;
|
|
9287
|
+
break;
|
|
9288
|
+
}
|
|
9289
|
+
}
|
|
9290
|
+
if (tracked) return;
|
|
9291
|
+
this._nudgeQueueCheck();
|
|
9292
|
+
}
|
|
9293
|
+
/** Run the queue check (adopt, settle by listing, page progress) now, at most once per
|
|
9294
|
+
* STATUS_NUDGE_MIN_GAP_MS, then let the heartbeat carry on. */
|
|
9295
|
+
_nudgeQueueCheck() {
|
|
9296
|
+
var self = this;
|
|
9297
|
+
if (this._statusNudgeTimer) return;
|
|
9298
|
+
var wait = Math.max(0, this._statusNudgeAt + STATUS_NUDGE_MIN_GAP_MS - Date.now());
|
|
9299
|
+
this._statusNudgeTimer = setTimeout(function() {
|
|
9300
|
+
self._statusNudgeTimer = null;
|
|
9301
|
+
self._statusNudgeAt = Date.now();
|
|
9302
|
+
var id = self.host.getIdentity();
|
|
9303
|
+
if (!id.projectId || id.platform !== "claude" && id.platform !== "openai") return;
|
|
9304
|
+
if (self.isPollingPaused() || !self.host.isViewMounted()) return;
|
|
9305
|
+
self._adoptWorkerIndexingPasses(0, false, true);
|
|
9306
|
+
self._settleByListing();
|
|
9307
|
+
self._refreshPageProgress();
|
|
9308
|
+
self._ensureAdoptTick();
|
|
9309
|
+
}, wait);
|
|
9310
|
+
}
|
|
9065
9311
|
_ensureAdoptTick() {
|
|
9066
9312
|
if (this._adoptTickTimer) return;
|
|
9067
9313
|
var self = this;
|
|
@@ -9082,7 +9328,7 @@ var _ChatSession = class _ChatSession {
|
|
|
9082
9328
|
self._settleByListing();
|
|
9083
9329
|
self._refreshPageProgress();
|
|
9084
9330
|
self._ensureAdoptTick();
|
|
9085
|
-
}, ADOPT_TICK_MS);
|
|
9331
|
+
}, statusPushLive() ? STATUS_PUSH_ADOPT_TICK_MS : ADOPT_TICK_MS);
|
|
9086
9332
|
}
|
|
9087
9333
|
/**
|
|
9088
9334
|
* Follow an indexing pass found in a loaded history page through the queue check
|
|
@@ -9698,6 +9944,7 @@ var _ChatSession = class _ChatSession {
|
|
|
9698
9944
|
var id = this.host.getIdentity();
|
|
9699
9945
|
var svcId = id.projectId, plat = id.platform;
|
|
9700
9946
|
if (!svcId || plat === "none" || !this.host.isViewMounted()) return;
|
|
9947
|
+
this._ensureReturnWatch();
|
|
9701
9948
|
this._applyIndexCancellations();
|
|
9702
9949
|
this._sweepCancelledIndexing();
|
|
9703
9950
|
this._ensureAdoptTick();
|
|
@@ -9766,6 +10013,11 @@ var _ChatSession = class _ChatSession {
|
|
|
9766
10013
|
var executedAt;
|
|
9767
10014
|
var bp = entry2.poll({
|
|
9768
10015
|
latency: POLL_INTERVAL,
|
|
10016
|
+
// Status push (statusPushEnabled): a pass adopted from a listing is polled
|
|
10017
|
+
// slowly while frames arrive, like one this page dispatched. A dispatch
|
|
10018
|
+
// reply's poll decides that from the server's acknowledgement and
|
|
10019
|
+
// ignores this key.
|
|
10020
|
+
notify: statusPushEnabled(),
|
|
9769
10021
|
onResponse: function(_res, meta) {
|
|
9770
10022
|
if (meta && typeof meta.executed === "number" && meta.executed > 0) executedAt = meta.executed;
|
|
9771
10023
|
}
|
|
@@ -10414,7 +10666,7 @@ var _ChatSession = class _ChatSession {
|
|
|
10414
10666
|
}
|
|
10415
10667
|
}
|
|
10416
10668
|
};
|
|
10417
|
-
var pp = isBg ? item.poll(Object.assign({ latency: POLL_INTERVAL }, pollOpts)) : self._fgPollWithEarlyProbe(item, capturedId, pollOpts, {
|
|
10669
|
+
var pp = isBg ? item.poll(Object.assign({ latency: POLL_INTERVAL, notify: statusPushEnabled() }, pollOpts)) : self._fgPollWithEarlyProbe(item, capturedId, pollOpts, {
|
|
10418
10670
|
platform,
|
|
10419
10671
|
projectId,
|
|
10420
10672
|
owner,
|
|
@@ -11028,6 +11280,8 @@ exports.shouldRescueInFlightMessage = shouldRescueInFlightMessage;
|
|
|
11028
11280
|
exports.skapiSupportsStreaming = skapiSupportsStreaming;
|
|
11029
11281
|
exports.skipDuplicateFilesEnabled = skipDuplicateFilesEnabled;
|
|
11030
11282
|
exports.skipDuplicateFilesFrom = skipDuplicateFilesFrom;
|
|
11283
|
+
exports.statusPushEnabled = statusPushEnabled;
|
|
11284
|
+
exports.statusPushLive = statusPushLive;
|
|
11031
11285
|
exports.streamRecoveryEnabled = streamRecoveryEnabled;
|
|
11032
11286
|
exports.streamRecoveryLabels = streamRecoveryLabels;
|
|
11033
11287
|
exports.streamRecoveryPhase = streamRecoveryPhase;
|