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.mjs
CHANGED
|
@@ -255,6 +255,17 @@ function resolveForwardRequestStream() {
|
|
|
255
255
|
function windowedIndexingEnabled() {
|
|
256
256
|
return _config?.windowedIndexing === true;
|
|
257
257
|
}
|
|
258
|
+
function statusPushEnabled() {
|
|
259
|
+
return _config?.statusPush === true && typeof _config?.onRequestStatus === "function";
|
|
260
|
+
}
|
|
261
|
+
function statusPushLive() {
|
|
262
|
+
if (!statusPushEnabled() || typeof _config?.isRequestStatusLive !== "function") return false;
|
|
263
|
+
try {
|
|
264
|
+
return !!_config.isRequestStatusLive();
|
|
265
|
+
} catch (e) {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
258
269
|
function liveStreamingSocketEnabled() {
|
|
259
270
|
return liveStreamingEnabled() && _config?.liveStreaming === true;
|
|
260
271
|
}
|
|
@@ -839,7 +850,8 @@ WHEN THE DATA DOES NOT HAVE IT, SAY SO. Once you have searched the way these rul
|
|
|
839
850
|
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.
|
|
840
851
|
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.`;
|
|
841
852
|
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.`;
|
|
842
|
-
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
|
|
853
|
+
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.
|
|
854
|
+
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.`;
|
|
843
855
|
const groupIsPublic = indexGroupLiteral === '"public"' || indexGroupLiteral === "0";
|
|
844
856
|
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.`;
|
|
845
857
|
let systemPrompt = `
|
|
@@ -2638,6 +2650,9 @@ async function notifyAgentSaveAttachment(info) {
|
|
|
2638
2650
|
service,
|
|
2639
2651
|
owner,
|
|
2640
2652
|
...pollOpt(),
|
|
2653
|
+
// Status push for this pass and the continuations the worker queues from it
|
|
2654
|
+
// (see ChatEngineConfig.statusPush). Absent unless the host turned it on.
|
|
2655
|
+
...statusPushEnabled() ? { notify: true } : {},
|
|
2641
2656
|
url: OPENAI_RESPONSES_API_URL,
|
|
2642
2657
|
method: "POST",
|
|
2643
2658
|
headers: {
|
|
@@ -2682,6 +2697,9 @@ async function notifyAgentSaveAttachment(info) {
|
|
|
2682
2697
|
service,
|
|
2683
2698
|
owner,
|
|
2684
2699
|
...pollOpt(),
|
|
2700
|
+
// Status push for this pass and the continuations the worker queues from it
|
|
2701
|
+
// (see ChatEngineConfig.statusPush). Absent unless the host turned it on.
|
|
2702
|
+
...statusPushEnabled() ? { notify: true } : {},
|
|
2685
2703
|
url: ANTHROPIC_MESSAGES_API_URL,
|
|
2686
2704
|
method: "POST",
|
|
2687
2705
|
headers: {
|
|
@@ -5321,6 +5339,11 @@ var INDEX_DISPATCH_CLAIM_MS = 2 * 60 * 1e3;
|
|
|
5321
5339
|
var WORKER_PASS_ADOPT_ATTEMPTS = [0, 2e3, 6e3];
|
|
5322
5340
|
var RECENT_INDEX_PASS_EVIDENCE_MS = 10 * 60 * 1e3;
|
|
5323
5341
|
var ADOPT_TICK_MS = 10 * 1e3;
|
|
5342
|
+
var STATUS_PUSH_ADOPT_TICK_MS = 60 * 1e3;
|
|
5343
|
+
var CATCH_UP_MIN_GAP_MS = 2e3;
|
|
5344
|
+
var RETURN_WATCH_MS = 15 * 1e3;
|
|
5345
|
+
var RETURN_WATCH_SLEEP_GAP_MS = 45 * 1e3;
|
|
5346
|
+
var STATUS_NUDGE_MIN_GAP_MS = 2e3;
|
|
5324
5347
|
var EARLY_PROBE_SCHEDULE_MS = [400, 900, 1700];
|
|
5325
5348
|
var INDEXING_DRAIN_BUSY_POLL_MS = 8e3;
|
|
5326
5349
|
var INDEXING_DRAIN_CONFIRM_POLL_MS = 3e3;
|
|
@@ -5462,6 +5485,12 @@ function requestIdTimeMs(rid) {
|
|
|
5462
5485
|
}
|
|
5463
5486
|
return Math.floor(v / 2 / 1e6);
|
|
5464
5487
|
}
|
|
5488
|
+
var WRONG_ANSWER_MESSAGE = "This answer seems wrong. Please check it again against the documents.";
|
|
5489
|
+
var WRONG_ANSWER_LABEL = "Wrong answer?";
|
|
5490
|
+
function canReportWrongAnswer(msg) {
|
|
5491
|
+
var note = retrievalNoteOfAnswer(msg);
|
|
5492
|
+
return !!note && !answerUsedNoDataTool(note) && !msg.isCancelled;
|
|
5493
|
+
}
|
|
5465
5494
|
var _ChatSession = class _ChatSession {
|
|
5466
5495
|
constructor(host) {
|
|
5467
5496
|
// --- live streaming ----------------------------------------------------
|
|
@@ -5511,6 +5540,10 @@ var _ChatSession = class _ChatSession {
|
|
|
5511
5540
|
// bubble can never silently revert to its 200-char head.
|
|
5512
5541
|
this._hydratedBodies = {};
|
|
5513
5542
|
this._hydratingItems = {};
|
|
5543
|
+
/** The button's label and the message it sends, read off the session so the
|
|
5544
|
+
* clients need no extra import. */
|
|
5545
|
+
this.wrongAnswerLabel = WRONG_ANSWER_LABEL;
|
|
5546
|
+
this.wrongAnswerMessage = WRONG_ANSWER_MESSAGE;
|
|
5514
5547
|
this.typewriterQueue = Promise.resolve();
|
|
5515
5548
|
/**
|
|
5516
5549
|
* Pick up indexing passes the WORKER minted, which no client ever dispatched.
|
|
@@ -5547,6 +5580,27 @@ var _ChatSession = class _ChatSession {
|
|
|
5547
5580
|
* a reload starts without it and asks once, as before. */
|
|
5548
5581
|
this._idleVerdictAt = {};
|
|
5549
5582
|
this._adoptTickTimer = null;
|
|
5583
|
+
/** Start the ADOPT_TICK_MS follow-up if this page is tracking live indexing work and
|
|
5584
|
+
* is visible. Idempotent; each tick re-checks and stops when the work is gone, the tab
|
|
5585
|
+
* is hidden (resume restarts it through refreshLiveIndexState) or the view closed. */
|
|
5586
|
+
// ── RETURN CATCH-UP + REQUEST STATUS PUSH (owner, 2026-11-23) ──────────────
|
|
5587
|
+
// The rule: when the user comes back to the chat (the tab shown again, the computer
|
|
5588
|
+
// awake again, the network or the websocket back), the chat is re-read from the
|
|
5589
|
+
// server, so nothing that happened while they were away is missing. The re-read is
|
|
5590
|
+
// loadHistory's own first-page refresh, the one every mount runs: it keeps older pages
|
|
5591
|
+
// the user loaded, keeps a send still in flight, never lets an empty answer replace a
|
|
5592
|
+
// known one, re-attaches polls to whatever is still waiting, and reads back a streamed
|
|
5593
|
+
// answer nobody finalized. Status frames (statusPush) only make things faster; they
|
|
5594
|
+
// never decide anything on screen.
|
|
5595
|
+
this._catchUpAt = 0;
|
|
5596
|
+
this._catchUpTimer = null;
|
|
5597
|
+
this._returnWatchTimer = null;
|
|
5598
|
+
this._returnWatchAt = 0;
|
|
5599
|
+
this._returnListeners = false;
|
|
5600
|
+
this._statusUnsub = null;
|
|
5601
|
+
this._statusNudgeTimer = null;
|
|
5602
|
+
this._statusNudgeAt = 0;
|
|
5603
|
+
this._statusSeenConnect = false;
|
|
5550
5604
|
/** The last COMPLETE running+pending look at this user's bg queue: which pass ids were
|
|
5551
5605
|
* live. Complete means both lists came back shorter than their limit, so a tracked pass
|
|
5552
5606
|
* missing from it really has left the queue. */
|
|
@@ -5591,6 +5645,7 @@ var _ChatSession = class _ChatSession {
|
|
|
5591
5645
|
this.historyItemPolls = /* @__PURE__ */ new Map();
|
|
5592
5646
|
this._pauseReasons = /* @__PURE__ */ new Set();
|
|
5593
5647
|
this._resuming = false;
|
|
5648
|
+
this._wrongReported = {};
|
|
5594
5649
|
this._lidSeq = 0;
|
|
5595
5650
|
this._stageSeq = 0;
|
|
5596
5651
|
this._uploadBatches = 0;
|
|
@@ -6985,8 +7040,7 @@ var _ChatSession = class _ChatSession {
|
|
|
6985
7040
|
this._resuming = true;
|
|
6986
7041
|
return Promise.resolve().then(function() {
|
|
6987
7042
|
self.drainBgTaskQueue();
|
|
6988
|
-
|
|
6989
|
-
self.refreshLiveIndexState();
|
|
7043
|
+
return self.catchUpHistory();
|
|
6990
7044
|
}).catch(function(e) {
|
|
6991
7045
|
console.error("[chat-engine] resume polling failed", e);
|
|
6992
7046
|
}).then(function() {
|
|
@@ -8217,6 +8271,54 @@ var _ChatSession = class _ChatSession {
|
|
|
8217
8271
|
}
|
|
8218
8272
|
});
|
|
8219
8273
|
}
|
|
8274
|
+
/**
|
|
8275
|
+
* Does this bubble get the "Wrong answer?" button: the free function's gate,
|
|
8276
|
+
* and only on the latest answer, because the message it sends names no answer
|
|
8277
|
+
* and the model reads it right after the last one. An answer already reported
|
|
8278
|
+
* keeps its (disabled) button after the complaint turn lands below it.
|
|
8279
|
+
*/
|
|
8280
|
+
canReportWrongAnswer(msg) {
|
|
8281
|
+
if (!canReportWrongAnswer(msg)) return false;
|
|
8282
|
+
return this.wrongAnswerReported(msg) || this._isLatestAnswer(msg);
|
|
8283
|
+
}
|
|
8284
|
+
/** True when no chat turn follows `msg` in state.messages. Indexing rows and
|
|
8285
|
+
* cancelled turns do not count (neither reaches the model's history). Matched
|
|
8286
|
+
* by identity or by item id, since agent.vue hands in reactive proxies. */
|
|
8287
|
+
_isLatestAnswer(msg) {
|
|
8288
|
+
var list = this.state.messages || [];
|
|
8289
|
+
var sid = msg._serverItemId, lid = msg._localId;
|
|
8290
|
+
for (var i = list.length - 1; i >= 0; i--) {
|
|
8291
|
+
var m = list[i];
|
|
8292
|
+
if (!m) continue;
|
|
8293
|
+
if (m === msg || m.role === "assistant" && (sid && m._serverItemId === sid || lid && m._localId === lid)) return true;
|
|
8294
|
+
if (m.isBackgroundTask || m.isCancelled) continue;
|
|
8295
|
+
return false;
|
|
8296
|
+
}
|
|
8297
|
+
return false;
|
|
8298
|
+
}
|
|
8299
|
+
/** True once this answer's "Wrong answer?" was sent (one click per answer). */
|
|
8300
|
+
wrongAnswerReported(msg) {
|
|
8301
|
+
if (!msg) return false;
|
|
8302
|
+
if (msg._wrongReported) return true;
|
|
8303
|
+
var key = msg._serverItemId || msg._localId;
|
|
8304
|
+
return !!key && !!this._wrongReported[key];
|
|
8305
|
+
}
|
|
8306
|
+
/**
|
|
8307
|
+
* The "Wrong answer?" button: sends WRONG_ANSWER_MESSAGE as an ordinary visible
|
|
8308
|
+
* user turn through dispatchComposedMessage, so it reads the same after a reload
|
|
8309
|
+
* and both clients behave alike. The answer is marked first, so the button goes
|
|
8310
|
+
* disabled at once. False when the bubble does not qualify or was already used.
|
|
8311
|
+
* `pinned` is the caller's usual pinned identity and prompt (agent.vue pins them).
|
|
8312
|
+
*/
|
|
8313
|
+
reportWrongAnswer(msg, pinned) {
|
|
8314
|
+
if (this.wrongAnswerReported(msg) || !this.canReportWrongAnswer(msg)) return false;
|
|
8315
|
+
msg._wrongReported = true;
|
|
8316
|
+
var key = msg._serverItemId || msg._localId;
|
|
8317
|
+
if (key) this._wrongReported[key] = true;
|
|
8318
|
+
this.host.notify();
|
|
8319
|
+
this.dispatchComposedMessage(WRONG_ANSWER_MESSAGE, false, void 0, void 0, void 0, pinned);
|
|
8320
|
+
return true;
|
|
8321
|
+
}
|
|
8220
8322
|
/**
|
|
8221
8323
|
* Stop waiting for the reply to the chat turn that is running now, and move on.
|
|
8222
8324
|
*
|
|
@@ -9057,9 +9159,153 @@ var _ChatSession = class _ChatSession {
|
|
|
9057
9159
|
});
|
|
9058
9160
|
return found;
|
|
9059
9161
|
}
|
|
9060
|
-
/**
|
|
9061
|
-
*
|
|
9062
|
-
*
|
|
9162
|
+
/**
|
|
9163
|
+
* Re-read the chat from the server now (see the rule above). Safe to call from any
|
|
9164
|
+
* number of triggers at once: calls within CATCH_UP_MIN_GAP_MS of the last one run
|
|
9165
|
+
* once, at the end of the gap. Nothing happens while no chat view is mounted (the
|
|
9166
|
+
* mount loads the chat anyway) or while background polling is paused (the tab is
|
|
9167
|
+
* hidden: showing it calls this again).
|
|
9168
|
+
*/
|
|
9169
|
+
catchUpHistory() {
|
|
9170
|
+
var self = this;
|
|
9171
|
+
var id = this.host.getIdentity();
|
|
9172
|
+
if (!id.projectId || id.platform === "none") return Promise.resolve();
|
|
9173
|
+
if (!this.host.isViewMounted || !this.host.isViewMounted() || this.isPollingPaused()) return Promise.resolve();
|
|
9174
|
+
this._ensureReturnWatch();
|
|
9175
|
+
var wait = this._catchUpAt + CATCH_UP_MIN_GAP_MS - Date.now();
|
|
9176
|
+
if (wait > 0) {
|
|
9177
|
+
if (!this._catchUpTimer) {
|
|
9178
|
+
this._catchUpTimer = setTimeout(function() {
|
|
9179
|
+
self._catchUpTimer = null;
|
|
9180
|
+
self.catchUpHistory();
|
|
9181
|
+
}, wait);
|
|
9182
|
+
}
|
|
9183
|
+
return Promise.resolve();
|
|
9184
|
+
}
|
|
9185
|
+
this._catchUpAt = Date.now();
|
|
9186
|
+
return this.loadHistory(false, this.state.gateRefreshToken).catch(function(e) {
|
|
9187
|
+
console.error("[chat-engine] catch-up failed", e);
|
|
9188
|
+
});
|
|
9189
|
+
}
|
|
9190
|
+
/**
|
|
9191
|
+
* Watch for the moments the user comes back without the tab being hidden first: the
|
|
9192
|
+
* computer waking from sleep (the timer finds a gap far longer than its interval),
|
|
9193
|
+
* the network coming back, a page restored from the back-forward cache. Also starts
|
|
9194
|
+
* the status push listener. Runs while a chat view is mounted and stops itself when
|
|
9195
|
+
* none is.
|
|
9196
|
+
*/
|
|
9197
|
+
_ensureReturnWatch() {
|
|
9198
|
+
var self = this;
|
|
9199
|
+
if (typeof window === "undefined") return;
|
|
9200
|
+
if (!this._returnListeners) {
|
|
9201
|
+
this._returnListeners = true;
|
|
9202
|
+
var onBack = function() {
|
|
9203
|
+
if (typeof document !== "undefined" && document.visibilityState === "hidden") return;
|
|
9204
|
+
self.catchUpHistory();
|
|
9205
|
+
};
|
|
9206
|
+
window.addEventListener("online", onBack);
|
|
9207
|
+
window.addEventListener("pageshow", function(ev) {
|
|
9208
|
+
if (ev && ev.persisted) onBack();
|
|
9209
|
+
});
|
|
9210
|
+
}
|
|
9211
|
+
this._startStatusPush();
|
|
9212
|
+
if (this._returnWatchTimer) return;
|
|
9213
|
+
this._returnWatchAt = Date.now();
|
|
9214
|
+
var look = function() {
|
|
9215
|
+
self._returnWatchTimer = null;
|
|
9216
|
+
if (!self.host.isViewMounted || !self.host.isViewMounted()) {
|
|
9217
|
+
self._stopStatusPush();
|
|
9218
|
+
return;
|
|
9219
|
+
}
|
|
9220
|
+
var now = Date.now();
|
|
9221
|
+
var gap = now - self._returnWatchAt;
|
|
9222
|
+
self._returnWatchAt = now;
|
|
9223
|
+
if (gap > RETURN_WATCH_SLEEP_GAP_MS && (typeof document === "undefined" || document.visibilityState !== "hidden")) {
|
|
9224
|
+
self.catchUpHistory();
|
|
9225
|
+
}
|
|
9226
|
+
self._returnWatchTimer = setTimeout(look, RETURN_WATCH_MS);
|
|
9227
|
+
};
|
|
9228
|
+
this._returnWatchTimer = setTimeout(look, RETURN_WATCH_MS);
|
|
9229
|
+
}
|
|
9230
|
+
/** Listen to request status frames while a chat view is mounted (statusPush on). */
|
|
9231
|
+
_startStatusPush() {
|
|
9232
|
+
if (this._statusUnsub || !statusPushEnabled()) return;
|
|
9233
|
+
var self = this;
|
|
9234
|
+
this._statusSeenConnect = false;
|
|
9235
|
+
try {
|
|
9236
|
+
var unsub = chatEngineConfig().onRequestStatus(function(ev) {
|
|
9237
|
+
self._onRequestStatus(ev);
|
|
9238
|
+
});
|
|
9239
|
+
this._statusUnsub = typeof unsub === "function" ? unsub : function() {
|
|
9240
|
+
};
|
|
9241
|
+
} catch (e) {
|
|
9242
|
+
this._statusUnsub = null;
|
|
9243
|
+
}
|
|
9244
|
+
}
|
|
9245
|
+
_stopStatusPush() {
|
|
9246
|
+
var unsub = this._statusUnsub;
|
|
9247
|
+
this._statusUnsub = null;
|
|
9248
|
+
if (this._statusNudgeTimer) {
|
|
9249
|
+
clearTimeout(this._statusNudgeTimer);
|
|
9250
|
+
this._statusNudgeTimer = null;
|
|
9251
|
+
}
|
|
9252
|
+
if (unsub) {
|
|
9253
|
+
try {
|
|
9254
|
+
unsub();
|
|
9255
|
+
} catch (e) {
|
|
9256
|
+
}
|
|
9257
|
+
}
|
|
9258
|
+
}
|
|
9259
|
+
/**
|
|
9260
|
+
* One status frame event. 'connected' (first connection, and every reconnect after a
|
|
9261
|
+
* drop, a sleep or the planned renewal) catches up, because frames sent while the
|
|
9262
|
+
* socket was down are lost. A status change of an indexing pass this page does not
|
|
9263
|
+
* poll runs the queue check now instead of at its next heartbeat; a pass that IS polled
|
|
9264
|
+
* was already woken by skapi-js itself. Chat turns are left to their own polls.
|
|
9265
|
+
*/
|
|
9266
|
+
_onRequestStatus(ev) {
|
|
9267
|
+
if (!ev || !this.host.isViewMounted()) return;
|
|
9268
|
+
if (ev.type === "connected") {
|
|
9269
|
+
if (!this._statusSeenConnect) {
|
|
9270
|
+
this._statusSeenConnect = true;
|
|
9271
|
+
return;
|
|
9272
|
+
}
|
|
9273
|
+
if (typeof document !== "undefined" && document.visibilityState === "hidden") return;
|
|
9274
|
+
this.catchUpHistory();
|
|
9275
|
+
return;
|
|
9276
|
+
}
|
|
9277
|
+
if (ev.type !== "status" || typeof ev.id !== "string") return;
|
|
9278
|
+
if (!ev.queue || !isBgIndexingQueue(ev.queue)) return;
|
|
9279
|
+
if (this.historyItemPolls.has(ev.id)) return;
|
|
9280
|
+
var tracked = false;
|
|
9281
|
+
for (var i = 0; i < this.bgTaskQueue.length; i++) {
|
|
9282
|
+
var e = this.bgTaskQueue[i];
|
|
9283
|
+
if (e && e.id === ev.id) {
|
|
9284
|
+
tracked = !e.byListing;
|
|
9285
|
+
break;
|
|
9286
|
+
}
|
|
9287
|
+
}
|
|
9288
|
+
if (tracked) return;
|
|
9289
|
+
this._nudgeQueueCheck();
|
|
9290
|
+
}
|
|
9291
|
+
/** Run the queue check (adopt, settle by listing, page progress) now, at most once per
|
|
9292
|
+
* STATUS_NUDGE_MIN_GAP_MS, then let the heartbeat carry on. */
|
|
9293
|
+
_nudgeQueueCheck() {
|
|
9294
|
+
var self = this;
|
|
9295
|
+
if (this._statusNudgeTimer) return;
|
|
9296
|
+
var wait = Math.max(0, this._statusNudgeAt + STATUS_NUDGE_MIN_GAP_MS - Date.now());
|
|
9297
|
+
this._statusNudgeTimer = setTimeout(function() {
|
|
9298
|
+
self._statusNudgeTimer = null;
|
|
9299
|
+
self._statusNudgeAt = Date.now();
|
|
9300
|
+
var id = self.host.getIdentity();
|
|
9301
|
+
if (!id.projectId || id.platform !== "claude" && id.platform !== "openai") return;
|
|
9302
|
+
if (self.isPollingPaused() || !self.host.isViewMounted()) return;
|
|
9303
|
+
self._adoptWorkerIndexingPasses(0, false, true);
|
|
9304
|
+
self._settleByListing();
|
|
9305
|
+
self._refreshPageProgress();
|
|
9306
|
+
self._ensureAdoptTick();
|
|
9307
|
+
}, wait);
|
|
9308
|
+
}
|
|
9063
9309
|
_ensureAdoptTick() {
|
|
9064
9310
|
if (this._adoptTickTimer) return;
|
|
9065
9311
|
var self = this;
|
|
@@ -9080,7 +9326,7 @@ var _ChatSession = class _ChatSession {
|
|
|
9080
9326
|
self._settleByListing();
|
|
9081
9327
|
self._refreshPageProgress();
|
|
9082
9328
|
self._ensureAdoptTick();
|
|
9083
|
-
}, ADOPT_TICK_MS);
|
|
9329
|
+
}, statusPushLive() ? STATUS_PUSH_ADOPT_TICK_MS : ADOPT_TICK_MS);
|
|
9084
9330
|
}
|
|
9085
9331
|
/**
|
|
9086
9332
|
* Follow an indexing pass found in a loaded history page through the queue check
|
|
@@ -9696,6 +9942,7 @@ var _ChatSession = class _ChatSession {
|
|
|
9696
9942
|
var id = this.host.getIdentity();
|
|
9697
9943
|
var svcId = id.projectId, plat = id.platform;
|
|
9698
9944
|
if (!svcId || plat === "none" || !this.host.isViewMounted()) return;
|
|
9945
|
+
this._ensureReturnWatch();
|
|
9699
9946
|
this._applyIndexCancellations();
|
|
9700
9947
|
this._sweepCancelledIndexing();
|
|
9701
9948
|
this._ensureAdoptTick();
|
|
@@ -9764,6 +10011,11 @@ var _ChatSession = class _ChatSession {
|
|
|
9764
10011
|
var executedAt;
|
|
9765
10012
|
var bp = entry2.poll({
|
|
9766
10013
|
latency: POLL_INTERVAL,
|
|
10014
|
+
// Status push (statusPushEnabled): a pass adopted from a listing is polled
|
|
10015
|
+
// slowly while frames arrive, like one this page dispatched. A dispatch
|
|
10016
|
+
// reply's poll decides that from the server's acknowledgement and
|
|
10017
|
+
// ignores this key.
|
|
10018
|
+
notify: statusPushEnabled(),
|
|
9767
10019
|
onResponse: function(_res, meta) {
|
|
9768
10020
|
if (meta && typeof meta.executed === "number" && meta.executed > 0) executedAt = meta.executed;
|
|
9769
10021
|
}
|
|
@@ -10412,7 +10664,7 @@ var _ChatSession = class _ChatSession {
|
|
|
10412
10664
|
}
|
|
10413
10665
|
}
|
|
10414
10666
|
};
|
|
10415
|
-
var pp = isBg ? item.poll(Object.assign({ latency: POLL_INTERVAL }, pollOpts)) : self._fgPollWithEarlyProbe(item, capturedId, pollOpts, {
|
|
10667
|
+
var pp = isBg ? item.poll(Object.assign({ latency: POLL_INTERVAL, notify: statusPushEnabled() }, pollOpts)) : self._fgPollWithEarlyProbe(item, capturedId, pollOpts, {
|
|
10416
10668
|
platform,
|
|
10417
10669
|
projectId,
|
|
10418
10670
|
owner,
|
|
@@ -10763,6 +11015,6 @@ var _ChatSession = class _ChatSession {
|
|
|
10763
11015
|
_ChatSession.RUN_PASS_PAGE = 10;
|
|
10764
11016
|
var ChatSession = _ChatSession;
|
|
10765
11017
|
|
|
10766
|
-
export { ANSWER_MODES, ANSWER_MODE_HINTS, ANSWER_MODE_LABELS, ANSWER_MODE_OPTIONS, ANSWER_MODE_SETTING_LABEL, BG_INDEXING_QUEUE_SUFFIX, BOM, BOM_EXTS, CHAT_GREETING_MAX_LENGTH, CLAUDE_INPUT_CAP_RATIO, CLAUDE_PER_REQUEST_INPUT_CAP, CONTEXT_WINDOW_BY_MODEL, CONTEXT_WINDOW_DEFAULT, ChatSession, DATA_TOOL_NAMES, DEFAULT_ANSWER_MODE, DEFAULT_CLAUDE_MODEL, DEFAULT_CONTEXT_WINDOW, DEFAULT_OPENAI_MODEL, DEFAULT_SKIP_DUPLICATE_FILES, DEFAULT_UPLOAD_ACCESS_GROUP, DEFAULT_WEB_ACCESS, DUPLICATE_LOOKUP_LIMIT, DUPLICATE_LOOKUP_MAX_CANDIDATES, DUPLICATE_LOOKUP_TIMEOUT_MS, EMPTY_INDEXING_REPLY, EXPIRED_ATTACHMENT_URL_HOST, EXPIRED_ATTACHMENT_URL_ORIGIN, EXPIRED_LINK_REFRESH_EXPIRES_SECONDS, EXT_CONTENT_TYPES, FINDINGS_TABLE, FINDING_ID_PREFIX, HISTORY_BUDGET_RATIO, HISTORY_FILL_SLACK_PX, HISTORY_TOKEN_BUDGET, HTML_EXTS, HTML_HEAD_WINDOW, IMAGE_PREVIEWS_PER_MESSAGE, INDEXING_COMPLETE_MARKER, INDEXING_MAX_OUTPUT_TOKENS, INLINE_LINK_GLYPH, INLINE_LINK_UNAVAILABLE_GLYPH, INLINE_LINK_UNAVAILABLE_SUFFIX, INPUT_CAP_RATIO, LINK_LABEL_MAX_DISPLAY_CHARS, LINK_REFRESH_WINDOW_MS, MAX_CONCURRENT_BG_POLLS, MAX_HISTORY_FILL_PAGES, MAX_HISTORY_MESSAGES, MAX_OUTPUT_BY_MODEL, MAX_OUTPUT_TOKENS, MAX_PARSED_CONTENT_CHARS, MCP_NAME, MINT_CACHE_GENERATION, MIN_INPUT_TOKEN_BUDGET, MIN_PER_REQUEST_INPUT_CAP, NO_DATA_TOOL_MARK, OUTPUT_TOKEN_RESERVE, PAGE_TEXT_TABLE, POLL_INTERVAL, PRESIGN_SAFETY_MARGIN_MS, PREVIEWABLE_IMAGE_CONTENT_TYPES, PREVIEW_BROWSER_CACHE_SECONDS, PREVIEW_LAYOUT_BOX_SELECTOR, PREVIEW_URL_EXPIRES_SECONDS, PROJECT_SETTINGS_ACCESS_GROUP, PROJECT_SETTINGS_TABLE, PROJECT_SETTINGS_UNIQUE_ID, RENDER_FROM_TOKEN, RETRIEVAL_NOTES_MAX, RETRIEVAL_NOTES_TOKEN_BUDGET, RETRIEVAL_NOTE_MAX_CHARS, RETRIEVAL_NOTE_MAX_ITEMS, RETRIEVAL_NOTE_PREFIX, RTF_EXTS, RUN_RECORD_WORKING_STALE_MS, STREAM_POLL_INTERVAL, TOOL_AND_RESPONSE_BUFFER, UPLOAD_ACCESS_GROUPS, UPLOAD_ACCESS_HINTS, UPLOAD_ACCESS_LABELS, UPLOAD_ACCESS_OPTIONS, XML_EXTS, __resetSplitHistoryState, accessSettingFrom, adoptLocalAnswerIntoPage, answerModeFrom, answerUsedNoDataTool, applyEncodingDeclaration, applyRetrievalNotes, asksUploadAccessFrom, bgIndexingQueueName, buildAiAgentValue, buildBoundedChatMessages, buildChatDisplayList, buildChatGreeting, buildChatSystemPrompt, buildDisplayExpiredAttachmentHref, buildHistoryItemFullId, buildIndexingContinueMessage, buildIndexingRenderContinueTemplate, buildIndexingRenderMessage, buildIndexingSystemPrompt, buildIndexingUserMessage, buildIndexingWindowMessage, cachedProjectSettings, callClaudeWithMcp, callClaudeWithPublicMcp, callOpenAIWithPublicMcp, canonicalizePathForm, chatCacheKey, chatEffortFields, chatEngineConfig, chatGreetingFrom, chatStreamWiring, citationFileName, citationLinkPart, citationsFor, classifyInlineLink, clearAttachmentParsers, clearImagePreviewCache, clearProjectSettings, composeUserMessage, configureChatEngine, configureProjectSettings, contentTypeForExt, createHistoryFiller, createInlineLinkRegex, createScrollAnchor, createSseParser, csrEnvelopeError, encodePathSegments, encodingClassForExt, ensureHtmlCharset, ensureXmlEncoding, escapeInlineHtml, escapeRtfNonAscii, estimateMessageTokens, estimateTextTokens, extOf, extractClaudeText, extractLastUserTextFromRequest, extractOpenAIText, extractRemotePathFromAttachmentHref, extractRetrievalNote, fetchLiveIndexingKeys, fillHistoryViewport, filterListByClearHorizon, findAttachmentParser, findDuplicateUpload, keyWords as findingKeyWords, findingsForTurn, formatChatTimestamp, formatDuration, formatRetrievalNote, getAttachmentParsers, getChatHistory, getContextWindow, getErrorMessage, getExpiredAttachmentVisiblePath, getInputTokenBudget, getMaxOutputTokens, getModelContextWindow, getProjectContextWindow, getSplitChatHistory, getVisionProfile, groupAttachmentFailures, hasBom, hydrateImagePreviews, indexDoneUniqueId, indexScopeKey, indexingAccessGroup, isAuthExpiredError, isBgIndexingQueue, isCsrStatusEnvelope, isDataToolName, isDuplicateCandidateId, isErrorResponseBody, isHttpUrlLike, isImageVisionFile, isIndexingRequestText, isLinkUnavailable, isNonRetryableRequestError, isOfficeFile, isPagedReadFile, isPreviewableImagePath, isProviderApiKeyError, isRetriedFailure, isRetrievalNote, isServerExtractable, isServiceDbAttachmentHref, isWindowedReadFile, linkUnavailableKeyForHref, linkUnavailableKeyForPath, linkUnavailableKeysForPath, listClaudeModels, listOpenAIModels, liveSafePrefix, loadProjectSettings, looksLikeRtf, makeExtractPlaceholder, mapHistoryListToMessages, markImagePreviewStale, mayKeepStreamedAnswer, mintCacheBustStamp, needsBomForExt, normalizeAnswerMode, normalizeAttachmentPathCandidate, normalizeChatGreeting, normalizeExt, normalizeProjectAccessSetting, normalizeSkipDuplicateFiles, normalizeStoredPathTarget, normalizeTextContent, normalizeTrailingInlineToken, normalizeUploadAccessGroup, normalizeWebAccess, notifyAgentSaveAttachment, parseAiAgentValue, parseAttachmentContent, parseIndexingLabel, parseIndexingRequestText, patchProjectSettings, peekImagePreviewUrl, prepareDownloadText, presignExpiryEpochMs, previewImageContentType, previewLayoutBox, previewMintCacheToken, previewableExtOf, primeProjectSettings, projectAccessSetting, projectAnswerMode, projectAsksUploadAccess, projectChatGreeting, projectSettingsSettled, projectSkipDuplicateFiles, projectUploadAccessGroup, projectWebAccess, providerBodyWasRead, readExpiredAttachmentHref, readyProjectSettings, registerAttachmentParser, registerModelContextWindows, renderInlineLinkHtml, repairUrlEntities, repairUrlWhitespace, resetFileIndexOnServer, resolveAnswerMode, resolveImagePreviewUrl, resolveSkipDuplicateFiles, resolveWebAccess, retrievalNoteFromText, retrievalNoteOfAnswer, runIndexUniqueId, safeDecodeURIComponent, sanitizeAttachmentLinksForHistory, setProjectContextWindow, setProjectSettings, shouldRescueInFlightMessage, skapiSupportsStreaming, skipDuplicateFilesEnabled, skipDuplicateFilesFrom, streamRecoveryEnabled, streamRecoveryLabels, streamRecoveryPhase, stripFileBlocksFromHistory, transformContentWithImages, transformContentWithOpenAIImages, truncateLabelForDisplay, typewriterResumeIndex, uploadAccessGroupFrom, upsertIndexRunRecordSafe, wallClockNow, webAccessEnabled, webAccessFrom };
|
|
11018
|
+
export { ANSWER_MODES, ANSWER_MODE_HINTS, ANSWER_MODE_LABELS, ANSWER_MODE_OPTIONS, ANSWER_MODE_SETTING_LABEL, BG_INDEXING_QUEUE_SUFFIX, BOM, BOM_EXTS, CHAT_GREETING_MAX_LENGTH, CLAUDE_INPUT_CAP_RATIO, CLAUDE_PER_REQUEST_INPUT_CAP, CONTEXT_WINDOW_BY_MODEL, CONTEXT_WINDOW_DEFAULT, ChatSession, DATA_TOOL_NAMES, DEFAULT_ANSWER_MODE, DEFAULT_CLAUDE_MODEL, DEFAULT_CONTEXT_WINDOW, DEFAULT_OPENAI_MODEL, DEFAULT_SKIP_DUPLICATE_FILES, DEFAULT_UPLOAD_ACCESS_GROUP, DEFAULT_WEB_ACCESS, DUPLICATE_LOOKUP_LIMIT, DUPLICATE_LOOKUP_MAX_CANDIDATES, DUPLICATE_LOOKUP_TIMEOUT_MS, EMPTY_INDEXING_REPLY, EXPIRED_ATTACHMENT_URL_HOST, EXPIRED_ATTACHMENT_URL_ORIGIN, EXPIRED_LINK_REFRESH_EXPIRES_SECONDS, EXT_CONTENT_TYPES, FINDINGS_TABLE, FINDING_ID_PREFIX, HISTORY_BUDGET_RATIO, HISTORY_FILL_SLACK_PX, HISTORY_TOKEN_BUDGET, HTML_EXTS, HTML_HEAD_WINDOW, IMAGE_PREVIEWS_PER_MESSAGE, INDEXING_COMPLETE_MARKER, INDEXING_MAX_OUTPUT_TOKENS, INLINE_LINK_GLYPH, INLINE_LINK_UNAVAILABLE_GLYPH, INLINE_LINK_UNAVAILABLE_SUFFIX, INPUT_CAP_RATIO, LINK_LABEL_MAX_DISPLAY_CHARS, LINK_REFRESH_WINDOW_MS, MAX_CONCURRENT_BG_POLLS, MAX_HISTORY_FILL_PAGES, MAX_HISTORY_MESSAGES, MAX_OUTPUT_BY_MODEL, MAX_OUTPUT_TOKENS, MAX_PARSED_CONTENT_CHARS, MCP_NAME, MINT_CACHE_GENERATION, MIN_INPUT_TOKEN_BUDGET, MIN_PER_REQUEST_INPUT_CAP, NO_DATA_TOOL_MARK, OUTPUT_TOKEN_RESERVE, PAGE_TEXT_TABLE, POLL_INTERVAL, PRESIGN_SAFETY_MARGIN_MS, PREVIEWABLE_IMAGE_CONTENT_TYPES, PREVIEW_BROWSER_CACHE_SECONDS, PREVIEW_LAYOUT_BOX_SELECTOR, PREVIEW_URL_EXPIRES_SECONDS, PROJECT_SETTINGS_ACCESS_GROUP, PROJECT_SETTINGS_TABLE, PROJECT_SETTINGS_UNIQUE_ID, RENDER_FROM_TOKEN, RETRIEVAL_NOTES_MAX, RETRIEVAL_NOTES_TOKEN_BUDGET, RETRIEVAL_NOTE_MAX_CHARS, RETRIEVAL_NOTE_MAX_ITEMS, RETRIEVAL_NOTE_PREFIX, RTF_EXTS, RUN_RECORD_WORKING_STALE_MS, STREAM_POLL_INTERVAL, TOOL_AND_RESPONSE_BUFFER, UPLOAD_ACCESS_GROUPS, UPLOAD_ACCESS_HINTS, UPLOAD_ACCESS_LABELS, UPLOAD_ACCESS_OPTIONS, XML_EXTS, __resetSplitHistoryState, accessSettingFrom, adoptLocalAnswerIntoPage, answerModeFrom, answerUsedNoDataTool, applyEncodingDeclaration, applyRetrievalNotes, asksUploadAccessFrom, bgIndexingQueueName, buildAiAgentValue, buildBoundedChatMessages, buildChatDisplayList, buildChatGreeting, buildChatSystemPrompt, buildDisplayExpiredAttachmentHref, buildHistoryItemFullId, buildIndexingContinueMessage, buildIndexingRenderContinueTemplate, buildIndexingRenderMessage, buildIndexingSystemPrompt, buildIndexingUserMessage, buildIndexingWindowMessage, cachedProjectSettings, callClaudeWithMcp, callClaudeWithPublicMcp, callOpenAIWithPublicMcp, canonicalizePathForm, chatCacheKey, chatEffortFields, chatEngineConfig, chatGreetingFrom, chatStreamWiring, citationFileName, citationLinkPart, citationsFor, classifyInlineLink, clearAttachmentParsers, clearImagePreviewCache, clearProjectSettings, composeUserMessage, configureChatEngine, configureProjectSettings, contentTypeForExt, createHistoryFiller, createInlineLinkRegex, createScrollAnchor, createSseParser, csrEnvelopeError, encodePathSegments, encodingClassForExt, ensureHtmlCharset, ensureXmlEncoding, escapeInlineHtml, escapeRtfNonAscii, estimateMessageTokens, estimateTextTokens, extOf, extractClaudeText, extractLastUserTextFromRequest, extractOpenAIText, extractRemotePathFromAttachmentHref, extractRetrievalNote, fetchLiveIndexingKeys, fillHistoryViewport, filterListByClearHorizon, findAttachmentParser, findDuplicateUpload, keyWords as findingKeyWords, findingsForTurn, formatChatTimestamp, formatDuration, formatRetrievalNote, getAttachmentParsers, getChatHistory, getContextWindow, getErrorMessage, getExpiredAttachmentVisiblePath, getInputTokenBudget, getMaxOutputTokens, getModelContextWindow, getProjectContextWindow, getSplitChatHistory, getVisionProfile, groupAttachmentFailures, hasBom, hydrateImagePreviews, indexDoneUniqueId, indexScopeKey, indexingAccessGroup, isAuthExpiredError, isBgIndexingQueue, isCsrStatusEnvelope, isDataToolName, isDuplicateCandidateId, isErrorResponseBody, isHttpUrlLike, isImageVisionFile, isIndexingRequestText, isLinkUnavailable, isNonRetryableRequestError, isOfficeFile, isPagedReadFile, isPreviewableImagePath, isProviderApiKeyError, isRetriedFailure, isRetrievalNote, isServerExtractable, isServiceDbAttachmentHref, isWindowedReadFile, linkUnavailableKeyForHref, linkUnavailableKeyForPath, linkUnavailableKeysForPath, listClaudeModels, listOpenAIModels, liveSafePrefix, loadProjectSettings, looksLikeRtf, makeExtractPlaceholder, mapHistoryListToMessages, markImagePreviewStale, mayKeepStreamedAnswer, mintCacheBustStamp, needsBomForExt, normalizeAnswerMode, normalizeAttachmentPathCandidate, normalizeChatGreeting, normalizeExt, normalizeProjectAccessSetting, normalizeSkipDuplicateFiles, normalizeStoredPathTarget, normalizeTextContent, normalizeTrailingInlineToken, normalizeUploadAccessGroup, normalizeWebAccess, notifyAgentSaveAttachment, parseAiAgentValue, parseAttachmentContent, parseIndexingLabel, parseIndexingRequestText, patchProjectSettings, peekImagePreviewUrl, prepareDownloadText, presignExpiryEpochMs, previewImageContentType, previewLayoutBox, previewMintCacheToken, previewableExtOf, primeProjectSettings, projectAccessSetting, projectAnswerMode, projectAsksUploadAccess, projectChatGreeting, projectSettingsSettled, projectSkipDuplicateFiles, projectUploadAccessGroup, projectWebAccess, providerBodyWasRead, readExpiredAttachmentHref, readyProjectSettings, registerAttachmentParser, registerModelContextWindows, renderInlineLinkHtml, repairUrlEntities, repairUrlWhitespace, resetFileIndexOnServer, resolveAnswerMode, resolveImagePreviewUrl, resolveSkipDuplicateFiles, resolveWebAccess, retrievalNoteFromText, retrievalNoteOfAnswer, runIndexUniqueId, safeDecodeURIComponent, sanitizeAttachmentLinksForHistory, setProjectContextWindow, setProjectSettings, shouldRescueInFlightMessage, skapiSupportsStreaming, skipDuplicateFilesEnabled, skipDuplicateFilesFrom, statusPushEnabled, statusPushLive, streamRecoveryEnabled, streamRecoveryLabels, streamRecoveryPhase, stripFileBlocksFromHistory, transformContentWithImages, transformContentWithOpenAIImages, truncateLabelForDisplay, typewriterResumeIndex, uploadAccessGroupFrom, upsertIndexRunRecordSafe, wallClockNow, webAccessEnabled, webAccessFrom };
|
|
10767
11019
|
//# sourceMappingURL=engine.mjs.map
|
|
10768
11020
|
//# sourceMappingURL=engine.mjs.map
|