bunnyquery 1.21.7 → 1.21.13
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 +35 -1
- package/bunnyquery.js +347 -22
- package/dist/engine.cjs +449 -11
- package/dist/engine.cjs.map +1 -1
- package/dist/engine.d.mts +280 -1
- package/dist/engine.d.ts +280 -1
- package/dist/engine.mjs +425 -12
- package/dist/engine.mjs.map +1 -1
- package/package.json +1 -1
- package/src/engine/host.ts +7 -0
- package/src/engine/identical.ts +448 -0
- package/src/engine/index.ts +41 -0
- package/src/engine/indexing_groups.ts +42 -1
- package/src/engine/office.ts +2 -0
- package/src/engine/project_settings.ts +37 -0
- package/src/engine/prompts/chat_system_prompt.ts +4 -2
- package/src/engine/requests.ts +38 -2
- package/src/engine/session.ts +74 -1
package/dist/engine.mjs
CHANGED
|
@@ -78,6 +78,14 @@ function normalizeSkipDuplicateFiles(value) {
|
|
|
78
78
|
function skipDuplicateFilesFrom(data) {
|
|
79
79
|
return data ? normalizeSkipDuplicateFiles(data.skip_duplicate_files) : DEFAULT_SKIP_DUPLICATE_FILES;
|
|
80
80
|
}
|
|
81
|
+
var SHARE_IDENTICAL_FILES_KEY = "share_identical_files";
|
|
82
|
+
var DEFAULT_SHARE_IDENTICAL_FILES = true;
|
|
83
|
+
function normalizeShareIdenticalFiles(value) {
|
|
84
|
+
return value !== false;
|
|
85
|
+
}
|
|
86
|
+
function shareIdenticalFilesFrom(data) {
|
|
87
|
+
return data ? normalizeShareIdenticalFiles(data.share_identical_files) : DEFAULT_SHARE_IDENTICAL_FILES;
|
|
88
|
+
}
|
|
81
89
|
var ANSWER_MODES = ["standard", "fast", "thorough"];
|
|
82
90
|
var DEFAULT_ANSWER_MODE = "standard";
|
|
83
91
|
var ANSWER_MODE_SETTING_LABEL = "Answer mode";
|
|
@@ -191,6 +199,9 @@ function projectWebAccess(service) {
|
|
|
191
199
|
function projectSkipDuplicateFiles(service) {
|
|
192
200
|
return skipDuplicateFilesFrom(cachedProjectSettings(service));
|
|
193
201
|
}
|
|
202
|
+
function projectShareIdenticalFiles(service) {
|
|
203
|
+
return shareIdenticalFilesFrom(cachedProjectSettings(service));
|
|
204
|
+
}
|
|
194
205
|
function projectAnswerMode(service) {
|
|
195
206
|
return answerModeFrom(cachedProjectSettings(service));
|
|
196
207
|
}
|
|
@@ -1063,8 +1074,9 @@ function buildChatSystemPrompt(params) {
|
|
|
1063
1074
|
const indexGroupLiteral = typeof g === "number" ? String(g) : g === "public" || g === "private" || g === "authorized" || g === "admin" ? `"${g}"` : '"authorized"';
|
|
1064
1075
|
const reindexHint = canUpload === false ? `asking the project's owner to re-index that file` : client === "console" ? `re-indexing that file (select it on the Files page and choose Reindex)` : `re-indexing that file (attach the same file again and choose to reindex it)`;
|
|
1065
1076
|
const groundingRules = `ANSWER ONLY FROM THE DATA. Every fact you state about this project's data - a name, a number, a date, a status, what a document says, whether something exists - must come from one of four places: a tool result returned in THIS conversation, a file or image attached to it (including one you read through its attachment link), the project description at the end of this prompt, or what the user told you themselves in this chat. Your general knowledge, the open internet and a plausible guess are NOT sources. Never use them to answer a question about the user's data, to fill a gap in it, or to complete a record that came back partial. A value that is not in what you retrieved is unknown: say it is not in the data instead of supplying a likely one.
|
|
1066
|
-
|
|
1067
|
-
|
|
1077
|
+
FILES IN ANOTHER LANGUAGE. The files may be written in another language than the question (a Russian or English manual asked about in Korean). When searches in the question's language find nothing, or searchText reports query_language_mismatch, search again with the question's key terms translated into the language the files are written in (their names, titles and earlier hits show it): one or two short queries of the main terms (e.g. "oil leak", "gearbox"), before concluding anything.
|
|
1078
|
+
WHEN THE DATA DOES NOT HAVE IT, SAY SO. Once you have searched the way these rules require (in the files' language too) and nothing answers the question, tell the user plainly, in their language, that this project's data does not contain it, and say what you searched (the tables, files or terms) so they can tell missing data from a missed search. Do not answer from memory instead, and do not turn a missing answer into a general explanation of the topic. Offer what would let you answer it: ${canUpload === false ? `another name or file to look under, or asking the project's owner to add it` : `the document to upload, or another name or file to look under`}.
|
|
1079
|
+
A CODE, NUMBER OR EXACT QUOTE THAT searchText DID NOT FIND (an identifier or a quote, not a topic or how-to question, which follows FILES IN ANOTHER LANGUAGE first): when it answers search_complete with no hit, and what its message says was NOT searched has been checked as it says (the skipped_without_page_text files; the records ONLY when the value could be a spreadsheet cell or a row, and then with ONE filtered getRecords on that value, never by paging through a whole table), keep the answer short. The text read from photos, scans and other images IS in the page text searchText covered, so a code, serial or phrase asked about a photo needs no records read: say plainly that it was not found, name what was searched (the file, and its pages when you searched only some of them, or files_searched files and total_pages_searched pages), and when a recently uploaded file or a photo should hold it, suggest ${reindexHint}, since small or handwritten characters can be misread at indexing. Never present a different file as the match, and never guess the value.
|
|
1068
1080
|
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.
|
|
1069
1081
|
These 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.`;
|
|
1070
1082
|
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.`;
|
|
@@ -1083,6 +1095,7 @@ NUMBERS FROM A SPREADSHEET are computed from the ROWS, never from one page and n
|
|
|
1083
1095
|
${documentRules}
|
|
1084
1096
|
${accessGroupRule}
|
|
1085
1097
|
COMPLETE ANSWERS: ONE file is routinely SPLIT ACROSS SEVERAL TABLES (a summary row in one, its page or row content in another, its extracted pictures in "__MEDIA__"), so for anything not scoped to a single file run the query in EVERY table that could hold the answer and combine the results. For any request that counts, sums, totals, lists every match, compares across records, finds which one, or asks whether something is present or ABSENT (for example "how many", "total spent", "which card", "is there any", "\uC5C6\uC5B4?", "\uD558\uB098\uB3C4 \uC5C6\uB098?"), read the COMPLETE matching set across every such table and file before answering. Never assert absence ("there is no X", "none", "not found", "\uC544\uB2C8\uC694, \uC5C6\uC2B5\uB2C8\uB2E4") until a complete scan has come back empty: a confident "no" that later turns out wrong is worse than telling the user you are still checking. If you answered from one table and then find another holds more, re-run the sweep and give the complete answer instead of only apologising.
|
|
1098
|
+
LINKED COPIES: files with the same content are indexed once. A file a tool reports as a linked copy (linked_copy, or listed in a hit's also_at) has no rows or pages of its own: its content is the original's, stored and tagged under the original's name. Cite the original file and say that the copy is the same file; never count the two as two documents.
|
|
1086
1099
|
Embedded values: a search term is often stored inside a larger string (a merchant "BAKSA" as "DNH*BAKSA#4070277042", a card as "5860****5173"), which no index or tag filter matches. When the value may be embedded, fetch the full set with fetch_all and match the substring yourself.
|
|
1087
1100
|
File attachments: an "Attached files:" section with markdown links in a user message points at short-lived signed URLs in this project's storage. Image files (.jpg, .jpeg, .png, .gif, .webp) are ALREADY in the message as image blocks: look at them directly. Every other attached file (office documents such as .docx/.xlsx/.pptx/.hwp/.hwpx/.ods, PDFs, email (.eml), text/data/code files such as .csv/.tsv/.json/.xml/.txt/.md) is ALREADY INDEXED: it was read end to end when it was uploaded, before this message reached you, so answer from its records (reference "src::<the storage path from the attachment link>"), and for its exact wording use searchText or readFileContent on that same path (see DOCUMENTS). Some turns instead carry the file text between "BEGIN FILE CONTENT" / "END FILE CONTENT" markers: read that block directly; a "[skapi: ...]" note inside it means that file could not be extracted. ${webAccess ? `Never web_fetch an attachment link (the picture is already in the message, everything else is in the database); a file the user gives as an outside web address may be fetched under the web rule above.` : `This chat has no web tool: never try to download or fetch an attachment link.`}
|
|
1088
1101
|
Stored files: a file already in this project's storage was read end to end at upload time, so its records come first. For its exact wording find the page with searchText (DOCUMENTS); readFileContent re-reads the raw file (an older file without page text, a data file), and you read it to the end before concluding anything is absent there. If its pictures do not reach you, say so plainly and fall back to the indexed records; never call a file unreadable when its content is in the database.
|
|
@@ -2893,12 +2906,14 @@ async function notifyAgentSaveAttachment(info) {
|
|
|
2893
2906
|
const singlePass = !visionFile && !windowedRead && !pagedRead && !continuing;
|
|
2894
2907
|
const imageFile = singlePass && !parsedContent && !serverExtract ? indexingImageFile(attachment) : void 0;
|
|
2895
2908
|
const fileUrlDetail = imageFile && platform === "openai" ? getOpenAIImageDetail(info.model || DEFAULT_OPENAI_MODEL) : void 0;
|
|
2909
|
+
const shareIdentical = !continuing && info.shareIdentical !== false && (info.shareIdentical === true || projectShareIdenticalFiles(service));
|
|
2896
2910
|
const skapiFileUrls = attachment.url && attachment.storagePath ? {
|
|
2897
2911
|
_skapi_file_urls: [{
|
|
2898
2912
|
path: attachment.storagePath,
|
|
2899
2913
|
url: attachment.url,
|
|
2900
2914
|
...singlePass ? { index_end: true } : {},
|
|
2901
|
-
...fileUrlDetail ? { detail: fileUrlDetail } : {}
|
|
2915
|
+
...fileUrlDetail ? { detail: fileUrlDetail } : {},
|
|
2916
|
+
...shareIdentical ? { share_identical: true } : {}
|
|
2902
2917
|
}]
|
|
2903
2918
|
} : {};
|
|
2904
2919
|
const userMessage = visionFile && renderPlaceholder ? buildIndexingRenderMessage(attachment, renderPlaceholder, renderFrom) : windowedRead && windowPlaceholder ? buildIndexingWindowMessage(attachment, windowPlaceholder, false) : continuing ? buildIndexingContinueMessage(attachment) : buildIndexingUserMessage(
|
|
@@ -3025,13 +3040,26 @@ async function notifyAgentSaveAttachment(info) {
|
|
|
3025
3040
|
}
|
|
3026
3041
|
}));
|
|
3027
3042
|
}
|
|
3043
|
+
function providerDocument(response) {
|
|
3044
|
+
if (typeof response !== "string") return response;
|
|
3045
|
+
var t = response.trim();
|
|
3046
|
+
if (t.charAt(0) !== "{" || t.charAt(t.length - 1) !== "}") return response;
|
|
3047
|
+
try {
|
|
3048
|
+
var doc = JSON.parse(t);
|
|
3049
|
+
return doc && typeof doc === "object" && !Array.isArray(doc) ? doc : response;
|
|
3050
|
+
} catch (e) {
|
|
3051
|
+
return response;
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3028
3054
|
function extractClaudeText(response) {
|
|
3055
|
+
response = providerDocument(response);
|
|
3029
3056
|
if (!Array.isArray(response?.content)) {
|
|
3030
3057
|
return "";
|
|
3031
3058
|
}
|
|
3032
3059
|
return response.content.filter((block) => block?.type === "text").map((block) => block.text).join("\n");
|
|
3033
3060
|
}
|
|
3034
3061
|
function extractOpenAIText(response) {
|
|
3062
|
+
response = providerDocument(response);
|
|
3035
3063
|
if (typeof response?.output_text === "string" && response.output_text.length) {
|
|
3036
3064
|
return response.output_text;
|
|
3037
3065
|
}
|
|
@@ -3233,6 +3261,311 @@ function messageTimeMs(m) {
|
|
|
3233
3261
|
return typeof m._ts === "number" && m._ts > 0 ? m._ts : 0;
|
|
3234
3262
|
}
|
|
3235
3263
|
|
|
3264
|
+
// src/engine/identical.ts
|
|
3265
|
+
var LINKED_COPY_TAG = "bq_linked";
|
|
3266
|
+
var CONTENT_CLAIM_PREFIX = "cas::";
|
|
3267
|
+
function linkedMarkerOf(data) {
|
|
3268
|
+
if (!data || typeof data !== "object" || data.linked !== true) return null;
|
|
3269
|
+
var original = typeof data.alias_of === "string" ? data.alias_of : "";
|
|
3270
|
+
if (!original) return null;
|
|
3271
|
+
var at = Number(data.completed_at || data.finished || data.linked_at);
|
|
3272
|
+
return {
|
|
3273
|
+
original,
|
|
3274
|
+
claim: typeof data.alias_claim === "string" && data.alias_claim ? data.alias_claim : void 0,
|
|
3275
|
+
linkedAt: isFinite(at) && at > 0 ? at : void 0,
|
|
3276
|
+
group: data.copy_group !== void 0 ? data.copy_group : void 0,
|
|
3277
|
+
owner: typeof data.copy_owner === "string" ? data.copy_owner : void 0,
|
|
3278
|
+
contentKey: typeof data.content_key === "string" && data.content_key ? data.content_key : void 0
|
|
3279
|
+
};
|
|
3280
|
+
}
|
|
3281
|
+
function fileNameOf(path) {
|
|
3282
|
+
var s = String(path || "");
|
|
3283
|
+
var at = s.lastIndexOf("/");
|
|
3284
|
+
return at === -1 ? s : s.slice(at + 1);
|
|
3285
|
+
}
|
|
3286
|
+
function copyStatusOf(marker, original, liveClaims) {
|
|
3287
|
+
var name = fileNameOf(marker.original);
|
|
3288
|
+
var mk = function(kind, label, title, broken) {
|
|
3289
|
+
return { kind, original: marker.original, label, title, broken };
|
|
3290
|
+
};
|
|
3291
|
+
var o = original || {};
|
|
3292
|
+
var claimGone = !!(liveClaims && marker.claim && !liveClaims.has(marker.claim));
|
|
3293
|
+
if (o.done && o.contentKey && marker.contentKey && o.contentKey !== marker.contentKey && o.run !== "working") {
|
|
3294
|
+
return mk(
|
|
3295
|
+
"original_removed",
|
|
3296
|
+
"Original removed or failed",
|
|
3297
|
+
'Linked to "' + name + '", which now holds other content. Reindex this file to index it on its own.',
|
|
3298
|
+
true
|
|
3299
|
+
);
|
|
3300
|
+
}
|
|
3301
|
+
if (claimGone && !(o.run === "working")) {
|
|
3302
|
+
return mk(
|
|
3303
|
+
"original_removed",
|
|
3304
|
+
"Original removed or failed",
|
|
3305
|
+
'Linked to "' + name + '", which is no longer indexed. Reindex this file to index it on its own.',
|
|
3306
|
+
true
|
|
3307
|
+
);
|
|
3308
|
+
}
|
|
3309
|
+
if (o.run === "error" || o.run === "cancelled") {
|
|
3310
|
+
return mk(
|
|
3311
|
+
"original_failed",
|
|
3312
|
+
"Original removed or failed",
|
|
3313
|
+
'Linked to "' + name + '", whose indexing did not finish. Reindex this file to index it on its own.',
|
|
3314
|
+
true
|
|
3315
|
+
);
|
|
3316
|
+
}
|
|
3317
|
+
if (o.run === "working" && !o.done) {
|
|
3318
|
+
return mk(
|
|
3319
|
+
"waiting",
|
|
3320
|
+
"Waiting for " + name,
|
|
3321
|
+
'Same content as "' + name + '", which is still being indexed. This file shares its index when it finishes.',
|
|
3322
|
+
false
|
|
3323
|
+
);
|
|
3324
|
+
}
|
|
3325
|
+
if (!o.done && o.run !== "done" && liveClaims && !marker.claim) {
|
|
3326
|
+
return mk(
|
|
3327
|
+
"original_removed",
|
|
3328
|
+
"Original removed or failed",
|
|
3329
|
+
'Linked to "' + name + '", which is no longer indexed. Reindex this file to index it on its own.',
|
|
3330
|
+
true
|
|
3331
|
+
);
|
|
3332
|
+
}
|
|
3333
|
+
return mk(
|
|
3334
|
+
"linked",
|
|
3335
|
+
"Indexed via " + name,
|
|
3336
|
+
'Same content as "' + name + '"; search and totals count it once.',
|
|
3337
|
+
false
|
|
3338
|
+
);
|
|
3339
|
+
}
|
|
3340
|
+
function copyCountLabel(n) {
|
|
3341
|
+
return n === 1 ? "1 copy" : n + " copies";
|
|
3342
|
+
}
|
|
3343
|
+
function copyCountTitle(copies) {
|
|
3344
|
+
var list = copies.slice(0, 10).map(function(p) {
|
|
3345
|
+
return "/" + p;
|
|
3346
|
+
}).join("\n");
|
|
3347
|
+
var more = copies.length > 10 ? "\n...and " + (copies.length - 10) + " more" : "";
|
|
3348
|
+
return "The same content is also stored as:\n" + list + more + "\nThey share this file's index; search and totals count it once.";
|
|
3349
|
+
}
|
|
3350
|
+
function copiesByOriginal(linked) {
|
|
3351
|
+
var entries = linked instanceof Map ? Array.from(linked.entries()) : Object.keys(linked).map(function(k) {
|
|
3352
|
+
return [k, linked[k]];
|
|
3353
|
+
});
|
|
3354
|
+
entries.sort(function(a, b) {
|
|
3355
|
+
return (a[1].linkedAt || 0) - (b[1].linkedAt || 0) || (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
|
|
3356
|
+
});
|
|
3357
|
+
var out = /* @__PURE__ */ new Map();
|
|
3358
|
+
for (var i = 0; i < entries.length; i++) {
|
|
3359
|
+
var o = entries[i][1].original;
|
|
3360
|
+
if (!out.has(o)) out.set(o, []);
|
|
3361
|
+
out.get(o).push(entries[i][0]);
|
|
3362
|
+
}
|
|
3363
|
+
return out;
|
|
3364
|
+
}
|
|
3365
|
+
function formatLinkDuration(ms) {
|
|
3366
|
+
if (typeof ms !== "number" || !isFinite(ms) || ms < 0) return "";
|
|
3367
|
+
if (ms < 1e4) return (Math.max(ms, 100) / 1e3).toFixed(1) + " s";
|
|
3368
|
+
return formatIndexDuration(ms);
|
|
3369
|
+
}
|
|
3370
|
+
function linkedRowLabel(original, ms) {
|
|
3371
|
+
var took = formatLinkDuration(ms);
|
|
3372
|
+
return "Same content as " + fileNameOf(original) + ": linked" + (took ? " in " + took : "") + ", no AI used";
|
|
3373
|
+
}
|
|
3374
|
+
function parseLinkedReply(text) {
|
|
3375
|
+
if (typeof text !== "string" || text.indexOf('[skapi] Same content as "') === -1) return null;
|
|
3376
|
+
var m = /\[skapi\] Same content as "([^"]+)": linked to its index(?: in ([0-9]+(?:\.[0-9]+)?) s)?/.exec(text);
|
|
3377
|
+
if (!m) return null;
|
|
3378
|
+
var secs = m[2] !== void 0 ? Number(m[2]) : NaN;
|
|
3379
|
+
return { original: m[1], ms: isFinite(secs) ? Math.round(secs * 1e3) : void 0 };
|
|
3380
|
+
}
|
|
3381
|
+
function promotableCopies(linked, actor) {
|
|
3382
|
+
var entries = linked instanceof Map ? Array.from(linked.entries()) : Object.keys(linked).map(function(k) {
|
|
3383
|
+
return [k, linked[k]];
|
|
3384
|
+
});
|
|
3385
|
+
var out = /* @__PURE__ */ new Map();
|
|
3386
|
+
for (var i = 0; i < entries.length; i++) {
|
|
3387
|
+
var m = entries[i][1];
|
|
3388
|
+
if (actor.isProjectOwner || !!actor.userId && !!m && m.owner === actor.userId) out.set(entries[i][0], m);
|
|
3389
|
+
}
|
|
3390
|
+
return out;
|
|
3391
|
+
}
|
|
3392
|
+
function copiesToPromote(linked, removed, removedFolders, actor) {
|
|
3393
|
+
if (actor) linked = promotableCopies(linked, actor);
|
|
3394
|
+
var gone = new Set(removed || []);
|
|
3395
|
+
var folders = (removedFolders || []).filter(Boolean).map(function(f) {
|
|
3396
|
+
return f.replace(/\/+$/, "") + "/";
|
|
3397
|
+
});
|
|
3398
|
+
var isGone = function(p) {
|
|
3399
|
+
if (gone.has(p)) return true;
|
|
3400
|
+
for (var i = 0; i < folders.length; i++) if (p.indexOf(folders[i]) === 0) return true;
|
|
3401
|
+
return false;
|
|
3402
|
+
};
|
|
3403
|
+
var out = [];
|
|
3404
|
+
copiesByOriginal(linked).forEach(function(copies, original) {
|
|
3405
|
+
if (!isGone(original)) return;
|
|
3406
|
+
var keep = copies.filter(function(c) {
|
|
3407
|
+
return !isGone(c);
|
|
3408
|
+
});
|
|
3409
|
+
if (keep.length) out.push({ original, copies: keep });
|
|
3410
|
+
});
|
|
3411
|
+
return out;
|
|
3412
|
+
}
|
|
3413
|
+
function listOf(res) {
|
|
3414
|
+
return res && Array.isArray(res.list) ? res.list : [];
|
|
3415
|
+
}
|
|
3416
|
+
async function listContentClaims(skapi, service, maxPages = 5) {
|
|
3417
|
+
if (!skapi || typeof skapi.getUniqueId !== "function" || !service) return null;
|
|
3418
|
+
try {
|
|
3419
|
+
var out = /* @__PURE__ */ new Set();
|
|
3420
|
+
var fetchMore = false;
|
|
3421
|
+
for (var page = 0; page < maxPages; page++) {
|
|
3422
|
+
var res = await skapi.getUniqueId(
|
|
3423
|
+
{ service, unique_id: CONTENT_CLAIM_PREFIX, condition: "gte" },
|
|
3424
|
+
{ limit: 1e3, fetchMore }
|
|
3425
|
+
);
|
|
3426
|
+
var list = listOf(res);
|
|
3427
|
+
for (var i = 0; i < list.length; i++) {
|
|
3428
|
+
var id = typeof list[i] === "string" ? list[i] : list[i] && list[i].unique_id;
|
|
3429
|
+
if (typeof id === "string" && id.indexOf(CONTENT_CLAIM_PREFIX) === 0) out.add(id);
|
|
3430
|
+
}
|
|
3431
|
+
if (!res || res.endOfList !== false) return out;
|
|
3432
|
+
fetchMore = true;
|
|
3433
|
+
}
|
|
3434
|
+
return null;
|
|
3435
|
+
} catch (err) {
|
|
3436
|
+
var msg = String(err && (err.code || err.message) || err || "");
|
|
3437
|
+
if (/NOT_EXISTS|not exist/i.test(msg)) return /* @__PURE__ */ new Set();
|
|
3438
|
+
return null;
|
|
3439
|
+
}
|
|
3440
|
+
}
|
|
3441
|
+
async function listLinkedCopies(skapi, service, maxPages = 10) {
|
|
3442
|
+
if (!skapi || typeof skapi.getRecords !== "function" || !service) return null;
|
|
3443
|
+
var out = /* @__PURE__ */ new Map();
|
|
3444
|
+
try {
|
|
3445
|
+
var fetchMore = false;
|
|
3446
|
+
for (var page = 0; page < maxPages; page++) {
|
|
3447
|
+
var res = await skapi.getRecords(
|
|
3448
|
+
{ service, table: { name: "__INDEXING__", access_group: "authorized" }, tag: LINKED_COPY_TAG },
|
|
3449
|
+
{ limit: 1e3, fetchMore }
|
|
3450
|
+
);
|
|
3451
|
+
var list = listOf(res);
|
|
3452
|
+
for (var i = 0; i < list.length; i++) {
|
|
3453
|
+
var r = list[i] || {};
|
|
3454
|
+
var uid = String(r.unique_id || "");
|
|
3455
|
+
if (uid.indexOf("done::") !== 0) continue;
|
|
3456
|
+
var mk = linkedMarkerOf(r.data);
|
|
3457
|
+
if (mk) out.set(uid.slice(6), mk);
|
|
3458
|
+
}
|
|
3459
|
+
if (!res || res.endOfList !== false) return out;
|
|
3460
|
+
fetchMore = true;
|
|
3461
|
+
}
|
|
3462
|
+
return out;
|
|
3463
|
+
} catch (err) {
|
|
3464
|
+
var msg = String(err && (err.code || err.message) || err || "");
|
|
3465
|
+
if (/NOT_EXISTS|not exist/i.test(msg)) return out;
|
|
3466
|
+
return null;
|
|
3467
|
+
}
|
|
3468
|
+
}
|
|
3469
|
+
function bodyOf(res) {
|
|
3470
|
+
if (typeof res === "string") {
|
|
3471
|
+
try {
|
|
3472
|
+
return JSON.parse(res);
|
|
3473
|
+
} catch (_) {
|
|
3474
|
+
return res;
|
|
3475
|
+
}
|
|
3476
|
+
}
|
|
3477
|
+
return res;
|
|
3478
|
+
}
|
|
3479
|
+
function errorText(err) {
|
|
3480
|
+
var b = err && (err.body || err.data || err.response);
|
|
3481
|
+
var bb = bodyOf(b);
|
|
3482
|
+
if (bb && typeof bb === "object") {
|
|
3483
|
+
if (typeof bb.reason === "string") return bb.reason;
|
|
3484
|
+
if (typeof bb.message === "string") return bb.message;
|
|
3485
|
+
}
|
|
3486
|
+
if (typeof bb === "string" && bb) return bb;
|
|
3487
|
+
return String(err && err.message || err || "The request failed.");
|
|
3488
|
+
}
|
|
3489
|
+
async function callMcpRoute(route, args, data) {
|
|
3490
|
+
var base = String(chatEngineConfig().mcpBaseUrl || "").replace(/\/+$/, "");
|
|
3491
|
+
if (!base) throw new Error("No BunnyQuery server is configured.");
|
|
3492
|
+
var res = await resolveForwardRequest()({
|
|
3493
|
+
service: args.service,
|
|
3494
|
+
...args.owner ? { owner: args.owner } : {},
|
|
3495
|
+
url: base + route,
|
|
3496
|
+
method: "POST",
|
|
3497
|
+
headers: { "content-type": "application/json", Authorization: "Bearer $ACCESS_TOKEN" },
|
|
3498
|
+
data: Object.assign({ project_id: args.service }, data)
|
|
3499
|
+
});
|
|
3500
|
+
return bodyOf(res);
|
|
3501
|
+
}
|
|
3502
|
+
async function findIdenticalFiles(args) {
|
|
3503
|
+
var calls = Math.max(1, args.maxCalls || 12);
|
|
3504
|
+
var last = null;
|
|
3505
|
+
for (var i = 0; i < calls; i++) {
|
|
3506
|
+
var body;
|
|
3507
|
+
try {
|
|
3508
|
+
body = await callMcpRoute("/internal/identical-files", args, { budget_s: args.budgetS || 8 });
|
|
3509
|
+
} catch (err) {
|
|
3510
|
+
var msg = errorText(err);
|
|
3511
|
+
if (/timed? ?out|timeout|504/i.test(msg) && i < calls - 1) continue;
|
|
3512
|
+
throw new Error(msg);
|
|
3513
|
+
}
|
|
3514
|
+
if (!body || typeof body !== "object" || !Array.isArray(body.groups)) {
|
|
3515
|
+
throw new Error(typeof body === "string" && body ? body : "The server did not answer the scan.");
|
|
3516
|
+
}
|
|
3517
|
+
last = { complete: !!body.complete, scanned: Number(body.scanned) || 0, total: Number(body.total) || 0, groups: body.groups, skipped: body.skipped };
|
|
3518
|
+
if (args.onProgress) args.onProgress(last);
|
|
3519
|
+
if (last.complete) return last;
|
|
3520
|
+
}
|
|
3521
|
+
return last;
|
|
3522
|
+
}
|
|
3523
|
+
async function linkIdenticalFile(args) {
|
|
3524
|
+
var last = "";
|
|
3525
|
+
for (var attempt = 0; attempt < 4; attempt++) {
|
|
3526
|
+
try {
|
|
3527
|
+
var body = await callMcpRoute("/internal/identical-link", args, { copy: args.copy, original: args.original });
|
|
3528
|
+
if (body && typeof body === "object" && typeof body.linked === "boolean") return body;
|
|
3529
|
+
return { linked: false, reason: typeof body === "string" && body ? body : "unexpected answer" };
|
|
3530
|
+
} catch (err) {
|
|
3531
|
+
last = errorText(err);
|
|
3532
|
+
if (!/timed? ?out|timeout|504/i.test(last)) return { linked: false, reason: last };
|
|
3533
|
+
await new Promise(function(r) {
|
|
3534
|
+
setTimeout(r, 8e3);
|
|
3535
|
+
});
|
|
3536
|
+
}
|
|
3537
|
+
}
|
|
3538
|
+
return { linked: false, reason: last || "timed out" };
|
|
3539
|
+
}
|
|
3540
|
+
function identicalLinkReasonText(reason) {
|
|
3541
|
+
switch (reason) {
|
|
3542
|
+
case "not_identical":
|
|
3543
|
+
return "the two files no longer have the same content";
|
|
3544
|
+
case "original_not_indexed":
|
|
3545
|
+
return "the original is not indexed";
|
|
3546
|
+
case "original_is_a_copy":
|
|
3547
|
+
return "the original is itself a linked copy";
|
|
3548
|
+
case "less_open_original":
|
|
3549
|
+
return "the original can be read by fewer people than the copy";
|
|
3550
|
+
case "private_original":
|
|
3551
|
+
return "the original is private";
|
|
3552
|
+
case "private_copy":
|
|
3553
|
+
return "the copy is another user's private file: it shares the index once that user indexes it again";
|
|
3554
|
+
case "content_claimed_by_another_file":
|
|
3555
|
+
return "another file already holds this content's index";
|
|
3556
|
+
case "not_readable":
|
|
3557
|
+
return "one of the files could not be read from storage";
|
|
3558
|
+
case "different_kind":
|
|
3559
|
+
return "the files are of different kinds";
|
|
3560
|
+
case "no_file_record":
|
|
3561
|
+
return "one of the files has no index record";
|
|
3562
|
+
case "unshared_access_group":
|
|
3563
|
+
return "the file's access group cannot share an index";
|
|
3564
|
+
default:
|
|
3565
|
+
return reason || "refused";
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
|
|
3236
3569
|
// src/engine/indexing_groups.ts
|
|
3237
3570
|
function canonIndexKey(s) {
|
|
3238
3571
|
return typeof s === "string" && s ? s.trim() : "";
|
|
@@ -3351,6 +3684,10 @@ function indexGroupDurationLabel(group) {
|
|
|
3351
3684
|
if (!group || group.status !== "done" || !group.finished || group.resolving || group.queued) return "";
|
|
3352
3685
|
return formatIndexDuration(group.durationMs);
|
|
3353
3686
|
}
|
|
3687
|
+
function indexGroupLinkedLabel(group) {
|
|
3688
|
+
if (!group || !group.linked || group.status !== "done") return "";
|
|
3689
|
+
return linkedRowLabel(group.linked.original, group.linked.ms);
|
|
3690
|
+
}
|
|
3354
3691
|
function buildChatDisplayList(messages, opts) {
|
|
3355
3692
|
var list = Array.isArray(messages) ? messages : [];
|
|
3356
3693
|
var liveIndexKeys = opts && opts.liveIndexKeys || {};
|
|
@@ -3546,6 +3883,14 @@ function buildChatDisplayList(messages, opts) {
|
|
|
3546
3883
|
var vm = grp.members[vi];
|
|
3547
3884
|
if (vm.msg._indexComplete) sawComplete = true;
|
|
3548
3885
|
if (!isHiddenPass(vm.msg)) grp.visibleMembers.push(vm);
|
|
3886
|
+
if (vm.msg.role === "assistant" && !vm.msg.isError && !grp.linked) {
|
|
3887
|
+
var linkedReply = parseLinkedReply(vm.msg.content);
|
|
3888
|
+
if (linkedReply) grp.linked = linkedReply;
|
|
3889
|
+
}
|
|
3890
|
+
}
|
|
3891
|
+
if (grp.linked && grp.status !== "active" && grp.status !== "cancelled") {
|
|
3892
|
+
grp.status = "done";
|
|
3893
|
+
sawComplete = true;
|
|
3549
3894
|
}
|
|
3550
3895
|
grp.driver = !isPagedReadFile(grp.name, grp.mime) ? "single" : isImageVisionFile(grp.name, grp.mime) ? "worker" : windowedIndexing ? "worker" : "client";
|
|
3551
3896
|
if (grp.status === "active") {
|
|
@@ -3557,7 +3902,7 @@ function buildChatDisplayList(messages, opts) {
|
|
|
3557
3902
|
} else if (grp.driver === "client") {
|
|
3558
3903
|
grp.finished = sawComplete || grp.status === "error" || grp.passCount >= MAX_INDEXING_RESUME_PASSES;
|
|
3559
3904
|
} else {
|
|
3560
|
-
grp.finished = !newestRunOfKey[order[oi]] || !!doneKeys[grp.key] && !liveIndexKeys[grp.key] || liveIndexChecked && !liveIndexKeys[grp.key];
|
|
3905
|
+
grp.finished = !newestRunOfKey[order[oi]] || !!grp.linked || !!doneKeys[grp.key] && !liveIndexKeys[grp.key] || liveIndexChecked && !liveIndexKeys[grp.key];
|
|
3561
3906
|
}
|
|
3562
3907
|
if (grp.status !== "done") {
|
|
3563
3908
|
grp.resolving = false;
|
|
@@ -3708,7 +4053,8 @@ function buildChatDisplayList(messages, opts) {
|
|
|
3708
4053
|
queued: waitingStub || live && !!runningKeys && !runningKeys[sp] && !runningKeys[canonIndexKey(sp)] && !runningKeys[fname] ? true : void 0,
|
|
3709
4054
|
stubError: rec.error || (st === "error" && !rec.error ? "Indexing did not finish." : void 0),
|
|
3710
4055
|
// The stub IS the record, so a 'done' record's span is this run's.
|
|
3711
|
-
durationMs: st === "done" ? runRecordDurationMs(rec) : void 0
|
|
4056
|
+
durationMs: st === "done" ? runRecordDurationMs(rec) : void 0,
|
|
4057
|
+
linked: st === "done" && rec.linked && rec.alias_of ? { original: rec.alias_of, ms: typeof rec.link_ms === "number" ? rec.link_ms : void 0 } : void 0
|
|
3712
4058
|
};
|
|
3713
4059
|
stubList.push({ started: typeof rec.started === "number" ? rec.started : Infinity, group: sg });
|
|
3714
4060
|
}
|
|
@@ -3728,6 +4074,9 @@ function buildChatDisplayList(messages, opts) {
|
|
|
3728
4074
|
stubList.push({ started: trec.started, group: tg });
|
|
3729
4075
|
overlayRunRecordVerdict(tg, trec, liveIndexKeys);
|
|
3730
4076
|
tg.durationMs = runRecordGroupDurationMs(tg, trec);
|
|
4077
|
+
if (trec.linked && trec.alias_of && trec.status === "done") {
|
|
4078
|
+
tg.linked = { original: trec.alias_of, ms: tg.linked && tg.linked.ms !== void 0 ? tg.linked.ms : typeof trec.link_ms === "number" ? trec.link_ms : void 0 };
|
|
4079
|
+
}
|
|
3731
4080
|
}
|
|
3732
4081
|
}
|
|
3733
4082
|
stubList.sort(function(a, b) {
|
|
@@ -3769,7 +4118,7 @@ function isDuplicateCandidateId(uniqueId, name) {
|
|
|
3769
4118
|
const tail = "/" + name;
|
|
3770
4119
|
return uniqueId.length > SRC_PREFIX2.length + tail.length && uniqueId.slice(-tail.length) === tail;
|
|
3771
4120
|
}
|
|
3772
|
-
function
|
|
4121
|
+
function listOf2(res) {
|
|
3773
4122
|
if (!res) return [];
|
|
3774
4123
|
if (Array.isArray(res)) return res;
|
|
3775
4124
|
return Array.isArray(res.list) ? res.list : [];
|
|
@@ -3786,14 +4135,14 @@ function nfc(text) {
|
|
|
3786
4135
|
async function storedCopyIndexing(skapi, storagePath, service) {
|
|
3787
4136
|
const doneId = "done::" + storagePath;
|
|
3788
4137
|
try {
|
|
3789
|
-
const done =
|
|
4138
|
+
const done = listOf2(await skapi.getUniqueId(Object.assign({ unique_id: doneId }, service), { fetchMore: false, limit: 1 }));
|
|
3790
4139
|
if (done.some(function(it) {
|
|
3791
4140
|
return (it && typeof it === "object" ? it.unique_id : it) === doneId;
|
|
3792
4141
|
})) return "done";
|
|
3793
4142
|
} catch {
|
|
3794
4143
|
}
|
|
3795
4144
|
try {
|
|
3796
|
-
const run =
|
|
4145
|
+
const run = listOf2(await skapi.getRecords(Object.assign({ unique_id: "run::" + storagePath }, service)))[0];
|
|
3797
4146
|
const data = run && run.data && typeof run.data === "object" ? run.data : null;
|
|
3798
4147
|
if (data && data.status === "working" && typeof data.started === "number" && Date.now() - data.started < RUN_RECORD_WORKING_STALE_MS) return "running";
|
|
3799
4148
|
} catch {
|
|
@@ -3822,7 +4171,7 @@ async function lookupDuplicate(skapi, file, userId, opts) {
|
|
|
3822
4171
|
const size = file && typeof file.size === "number" ? file.size : NaN;
|
|
3823
4172
|
if (!name || !(size >= 0) || !userId) return null;
|
|
3824
4173
|
const service = opts && opts.service ? { service: opts.service } : {};
|
|
3825
|
-
const found =
|
|
4174
|
+
const found = listOf2(await skapi.getUniqueId(
|
|
3826
4175
|
Object.assign({ unique_id: name, condition: "<=" }, service),
|
|
3827
4176
|
{ fetchMore: false, limit: DUPLICATE_LOOKUP_LIMIT }
|
|
3828
4177
|
));
|
|
@@ -3835,7 +4184,7 @@ async function lookupDuplicate(skapi, file, userId, opts) {
|
|
|
3835
4184
|
for (const uniqueId of ids) {
|
|
3836
4185
|
let record = null;
|
|
3837
4186
|
try {
|
|
3838
|
-
record =
|
|
4187
|
+
record = listOf2(await skapi.getRecords(Object.assign({ unique_id: uniqueId }, service)))[0] || null;
|
|
3839
4188
|
} catch {
|
|
3840
4189
|
continue;
|
|
3841
4190
|
}
|
|
@@ -6356,6 +6705,43 @@ var _ChatSession = class _ChatSession {
|
|
|
6356
6705
|
return queued;
|
|
6357
6706
|
});
|
|
6358
6707
|
}
|
|
6708
|
+
/**
|
|
6709
|
+
* ONE SHARED INDEX FOR IDENTICAL FILES: the linked copies that lose their original when
|
|
6710
|
+
* `removed` files (or every file under `folders`) go away, per original, oldest first
|
|
6711
|
+
* (identical.ts copiesToPromote). Read through host.findLinkedCopies, fresh, and it has
|
|
6712
|
+
* to be read BEFORE the delete or reset: those remove nothing from the copies' markers,
|
|
6713
|
+
* but a later sweep could no longer tell whose copies they were once a new original
|
|
6714
|
+
* exists. Never rejects; [] without the hook or on any failure.
|
|
6715
|
+
*/
|
|
6716
|
+
collectLinkedCopies(removed, folders) {
|
|
6717
|
+
if (typeof this.host.findLinkedCopies !== "function") return Promise.resolve([]);
|
|
6718
|
+
var id = this.host.getIdentity();
|
|
6719
|
+
var actor = { userId: id && !id.anonymous ? id.userId : null, isProjectOwner: !!(id && !id.anonymous && id.owner && id.userId === id.owner) };
|
|
6720
|
+
return Promise.resolve(this.host.findLinkedCopies()).then(function(map) {
|
|
6721
|
+
return map ? copiesToPromote(map, removed || [], folders, actor) : [];
|
|
6722
|
+
}).catch(function() {
|
|
6723
|
+
return [];
|
|
6724
|
+
});
|
|
6725
|
+
}
|
|
6726
|
+
/**
|
|
6727
|
+
* Send the copies of a removed or overwritten original again (owner decision
|
|
6728
|
+
* 2026-11-26): each list's oldest copy first, so its first pass claims the content and
|
|
6729
|
+
* is indexed for real (one AI run), then the others, which link to it with no AI call.
|
|
6730
|
+
* The share flag rides on every first pass while the project's switch is on (requests.ts
|
|
6731
|
+
* notifyAgentSaveAttachment). Through reindexStoredFiles, so each copy keeps its access
|
|
6732
|
+
* group and shows as a "Reindexing" row. Resolves to the number of files queued.
|
|
6733
|
+
*/
|
|
6734
|
+
promoteLinkedCopies(plan) {
|
|
6735
|
+
var list = [];
|
|
6736
|
+
(plan || []).forEach(function(g) {
|
|
6737
|
+
(g && g.copies || []).forEach(function(c) {
|
|
6738
|
+
if (c) list.push({ storagePath: c });
|
|
6739
|
+
});
|
|
6740
|
+
});
|
|
6741
|
+
if (!list.length) return Promise.resolve(0);
|
|
6742
|
+
console.log("[chat-engine] identical files: sending " + list.length + " linked cop" + (list.length === 1 ? "y" : "ies") + " again, their original is gone:", plan);
|
|
6743
|
+
return this.reindexStoredFiles(list);
|
|
6744
|
+
}
|
|
6359
6745
|
/**
|
|
6360
6746
|
* The same question, asked of the SERVER when this page cannot answer it.
|
|
6361
6747
|
*
|
|
@@ -13148,6 +13534,7 @@ var _ChatSession = class _ChatSession {
|
|
|
13148
13534
|
att._storedCount = 0;
|
|
13149
13535
|
att._indexQueuedCount = 0;
|
|
13150
13536
|
att._indexQueued = false;
|
|
13537
|
+
att._landedNew = [];
|
|
13151
13538
|
var cancelError = function() {
|
|
13152
13539
|
var e = new Error(UPLOAD_CANCELLED_MESSAGE);
|
|
13153
13540
|
e.code = "CANCELLED";
|
|
@@ -13175,10 +13562,13 @@ var _ChatSession = class _ChatSession {
|
|
|
13175
13562
|
checkCancel();
|
|
13176
13563
|
var hadExists = false;
|
|
13177
13564
|
var skipped = false;
|
|
13565
|
+
var promotion = null;
|
|
13178
13566
|
var duplicateOf = null;
|
|
13179
13567
|
var existedBefore = false;
|
|
13180
13568
|
var madeRecord = false;
|
|
13569
|
+
var sentAll = false;
|
|
13181
13570
|
var onProg = function(p) {
|
|
13571
|
+
if (p && p.total && p.loaded >= p.total) sentAll = true;
|
|
13182
13572
|
if (p && p.total) {
|
|
13183
13573
|
att.progress = Math.floor((idx + p.loaded / p.total) / total * 100);
|
|
13184
13574
|
self.host.renderAttachmentChips();
|
|
@@ -13186,6 +13576,7 @@ var _ChatSession = class _ChatSession {
|
|
|
13186
13576
|
};
|
|
13187
13577
|
var doMemberUpload = function(checkExistence) {
|
|
13188
13578
|
checkCancel();
|
|
13579
|
+
sentAll = false;
|
|
13189
13580
|
return self.host.uploadFile({
|
|
13190
13581
|
file: member.file,
|
|
13191
13582
|
storagePath: member.storagePath,
|
|
@@ -13207,10 +13598,14 @@ var _ChatSession = class _ChatSession {
|
|
|
13207
13598
|
}).then(function(r) {
|
|
13208
13599
|
att._abort = null;
|
|
13209
13600
|
att._storedCount = (att._storedCount || 0) + 1;
|
|
13601
|
+
if (checkExistence) att._landedNew.push(member.storagePath);
|
|
13210
13602
|
return r;
|
|
13211
13603
|
}, function(err) {
|
|
13212
13604
|
att._abort = null;
|
|
13213
|
-
if (att._cancelled)
|
|
13605
|
+
if (att._cancelled) {
|
|
13606
|
+
if (checkExistence && sentAll) att._landedNew.push(member.storagePath);
|
|
13607
|
+
throw cancelError();
|
|
13608
|
+
}
|
|
13214
13609
|
throw err;
|
|
13215
13610
|
});
|
|
13216
13611
|
};
|
|
@@ -13234,6 +13629,7 @@ var _ChatSession = class _ChatSession {
|
|
|
13234
13629
|
return self.host.promptOverwrite(member.file.name).then(function(choice) {
|
|
13235
13630
|
if (choice === "overwrite") {
|
|
13236
13631
|
existedBefore = true;
|
|
13632
|
+
promotion = self.collectLinkedCopies([member.storagePath]);
|
|
13237
13633
|
markImagePreviewStale(self.host.getIdentity().projectId || "default", member.storagePath);
|
|
13238
13634
|
return doMemberUpload(false);
|
|
13239
13635
|
}
|
|
@@ -13366,6 +13762,9 @@ var _ChatSession = class _ChatSession {
|
|
|
13366
13762
|
if (alreadyIndexing) return;
|
|
13367
13763
|
att._indexQueuedCount = (att._indexQueuedCount || 0) + 1;
|
|
13368
13764
|
if (att.kind !== "folder") att._indexQueued = true;
|
|
13765
|
+
att._landedNew = (att._landedNew || []).filter(function(p) {
|
|
13766
|
+
return p !== member.storagePath;
|
|
13767
|
+
});
|
|
13369
13768
|
self.host.renderAttachmentChips();
|
|
13370
13769
|
return self.trackIndexDispatch(notifyAgentSaveAttachment({
|
|
13371
13770
|
platform: id.platform,
|
|
@@ -13407,6 +13806,14 @@ var _ChatSession = class _ChatSession {
|
|
|
13407
13806
|
});
|
|
13408
13807
|
self.noteBgQueueChanged();
|
|
13409
13808
|
self.drainBgTaskQueue();
|
|
13809
|
+
if (promotion) {
|
|
13810
|
+
var plan = promotion;
|
|
13811
|
+
promotion = null;
|
|
13812
|
+
plan.then(function(pl) {
|
|
13813
|
+
return self.promoteLinkedCopies(pl);
|
|
13814
|
+
}).catch(function() {
|
|
13815
|
+
});
|
|
13816
|
+
}
|
|
13410
13817
|
}
|
|
13411
13818
|
}, function(e) {
|
|
13412
13819
|
console.error("[chat-engine] indexing request failed", e);
|
|
@@ -13487,6 +13894,12 @@ var _ChatSession = class _ChatSession {
|
|
|
13487
13894
|
att.status = "cancelled";
|
|
13488
13895
|
att._abort = null;
|
|
13489
13896
|
self.host.renderAttachmentChips();
|
|
13897
|
+
if (typeof att._onCancelSettled === "function") {
|
|
13898
|
+
try {
|
|
13899
|
+
att._onCancelSettled((att._landedNew || []).slice());
|
|
13900
|
+
} catch (e) {
|
|
13901
|
+
}
|
|
13902
|
+
}
|
|
13490
13903
|
return;
|
|
13491
13904
|
}
|
|
13492
13905
|
if (removed || aborted) return;
|
|
@@ -13523,6 +13936,6 @@ var _ChatSession = class _ChatSession {
|
|
|
13523
13936
|
_ChatSession.RUN_PASS_PAGE = 10;
|
|
13524
13937
|
var ChatSession = _ChatSession;
|
|
13525
13938
|
|
|
13526
|
-
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, 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, LOOK_DEADLINE_MS, LOOK_FAST_MS, LOOK_SLOW_MS, LOOK_STALE_MS, LookScheduler, 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, NOT_SENT_TEXT, 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, REQUEST_GONE_TEXT, REQUEST_UNREACHABLE_TEXT, 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, UPLOAD_CANCELLED_MESSAGE, XML_EXTS, __resetSplitHistoryState, accessSettingFrom, adoptLiveTextIntoRunningRow, 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, crefSupported, csrEnvelopeError, encodePathSegments, encodingClassForExt, ensureHtmlCharset, ensureXmlEncoding, escapeInlineHtml, escapeRtfNonAscii, estimateMessageTokens, estimateTextTokens, extOf, extractClaudeText, extractLastUserTextFromRequest, extractOpenAIText, extractRemotePathFromAttachmentHref, extractRetrievalNote, fetchLiveIndexingKeys, fillHistoryViewport, filterListByClearHorizon, findAttachmentParser, findDuplicateUpload, formatChatTimestamp, formatDuration, formatIndexDuration, formatRetrievalNote, getAttachmentParsers, getChatHistory, getContextWindow, getErrorMessage, getExpiredAttachmentVisiblePath, getInputTokenBudget, getMaxOutputTokens, getModelContextWindow, getProjectContextWindow, getSplitChatHistory, getVisionProfile, groupAttachmentFailures, hasBom, hydrateImagePreviews, indexDoneUniqueId, indexGroupDurationLabel, indexScopeKey, indexingAccessGroup, isAuthExpiredError, isBgIndexingQueue, isCsrStatusEnvelope, isDataToolName, isDuplicateCandidateId, isErrorResponseBody, isHttpUrlLike, isImageVisionFile, isIndexingRequestText, isLinkUnavailable, isNonRetryableRequestError, isNotExistsError, isOfficeFile, isPagedReadFile, isPreviewableImagePath, isProviderApiKeyError, isRetriedFailure, isRetrievalNote, isReturnTrigger, isServerExtractable, isServiceDbAttachmentHref, isTransportFailure, isUploadCancelledError, isWindowedReadFile, linkUnavailableKeyForHref, linkUnavailableKeyForPath, linkUnavailableKeysForPath, listClaudeModels, listOpenAIModels, listedRequestText, liveSafePrefix, loadProjectSettings, looksLikeRtf, makeExtractPlaceholder, mapHistoryListToMessages, markImagePreviewStale, mayKeepStreamedAnswer, messageTimeMs, mintCacheBustStamp, needsBomForExt, newClientRef, 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, reconcilerReadsEnabled, registerAttachmentParser, registerModelContextWindows, renderInlineLinkHtml, repairUrlEntities, repairUrlWhitespace, requestIdTimeMs, resetFileIndexOnServer, resolveAnswerMode, resolveImagePreviewUrl, resolveSkipDuplicateFiles, resolveWebAccess, retrievalNoteFromText, retrievalNoteOfAnswer, runIndexUniqueId, runRecordDurationMs, runSettleSideEffect, safeDecodeURIComponent, sanitizeAttachmentLinksForHistory, setProjectContextWindow, setProjectSettings, shouldRescueInFlightMessage, sideEffectDone, skapiSupportsStreaming, skipDuplicateFilesEnabled, skipDuplicateFilesFrom, splitLabelForFit, statusPushEnabled, statusPushLive, streamRecoveryEnabled, streamRecoveryLabels, streamRecoveryPhase, stripFileBlocksFromHistory, transformContentWithImages, transformContentWithOpenAIImages, truncateLabelForDisplay, typewriterResumeIndex, uploadAccessGroupFrom, upsertIndexRunRecordSafe, wallClockNow, webAccessEnabled, webAccessFrom };
|
|
13939
|
+
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, CONTENT_CLAIM_PREFIX, CONTEXT_WINDOW_BY_MODEL, CONTEXT_WINDOW_DEFAULT, ChatSession, DATA_TOOL_NAMES, DEFAULT_ANSWER_MODE, DEFAULT_CLAUDE_MODEL, DEFAULT_CONTEXT_WINDOW, DEFAULT_OPENAI_MODEL, DEFAULT_SHARE_IDENTICAL_FILES, 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, 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, LINKED_COPY_TAG, LINK_LABEL_MAX_DISPLAY_CHARS, LINK_REFRESH_WINDOW_MS, LOOK_DEADLINE_MS, LOOK_FAST_MS, LOOK_SLOW_MS, LOOK_STALE_MS, LookScheduler, 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, NOT_SENT_TEXT, 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, REQUEST_GONE_TEXT, REQUEST_UNREACHABLE_TEXT, 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, SHARE_IDENTICAL_FILES_KEY, STREAM_POLL_INTERVAL, TOOL_AND_RESPONSE_BUFFER, UPLOAD_ACCESS_GROUPS, UPLOAD_ACCESS_HINTS, UPLOAD_ACCESS_LABELS, UPLOAD_ACCESS_OPTIONS, UPLOAD_CANCELLED_MESSAGE, XML_EXTS, __resetSplitHistoryState, accessSettingFrom, adoptLiveTextIntoRunningRow, 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, copiesByOriginal, copiesToPromote, copyCountLabel, copyCountTitle, copyStatusOf, createHistoryFiller, createInlineLinkRegex, createScrollAnchor, createSseParser, crefSupported, csrEnvelopeError, encodePathSegments, encodingClassForExt, ensureHtmlCharset, ensureXmlEncoding, escapeInlineHtml, escapeRtfNonAscii, estimateMessageTokens, estimateTextTokens, extOf, extractClaudeText, extractLastUserTextFromRequest, extractOpenAIText, extractRemotePathFromAttachmentHref, extractRetrievalNote, fetchLiveIndexingKeys, fileNameOf, fillHistoryViewport, filterListByClearHorizon, findAttachmentParser, findDuplicateUpload, findIdenticalFiles, formatChatTimestamp, formatDuration, formatIndexDuration, formatLinkDuration, formatRetrievalNote, getAttachmentParsers, getChatHistory, getContextWindow, getErrorMessage, getExpiredAttachmentVisiblePath, getInputTokenBudget, getMaxOutputTokens, getModelContextWindow, getProjectContextWindow, getSplitChatHistory, getVisionProfile, groupAttachmentFailures, hasBom, hydrateImagePreviews, identicalLinkReasonText, indexDoneUniqueId, indexGroupDurationLabel, indexGroupLinkedLabel, indexScopeKey, indexingAccessGroup, isAuthExpiredError, isBgIndexingQueue, isCsrStatusEnvelope, isDataToolName, isDuplicateCandidateId, isErrorResponseBody, isHttpUrlLike, isImageVisionFile, isIndexingRequestText, isLinkUnavailable, isNonRetryableRequestError, isNotExistsError, isOfficeFile, isPagedReadFile, isPreviewableImagePath, isProviderApiKeyError, isRetriedFailure, isRetrievalNote, isReturnTrigger, isServerExtractable, isServiceDbAttachmentHref, isTransportFailure, isUploadCancelledError, isWindowedReadFile, linkIdenticalFile, linkUnavailableKeyForHref, linkUnavailableKeyForPath, linkUnavailableKeysForPath, linkedMarkerOf, linkedRowLabel, listClaudeModels, listContentClaims, listLinkedCopies, listOpenAIModels, listedRequestText, liveSafePrefix, loadProjectSettings, looksLikeRtf, makeExtractPlaceholder, mapHistoryListToMessages, markImagePreviewStale, mayKeepStreamedAnswer, messageTimeMs, mintCacheBustStamp, needsBomForExt, newClientRef, normalizeAnswerMode, normalizeAttachmentPathCandidate, normalizeChatGreeting, normalizeExt, normalizeProjectAccessSetting, normalizeShareIdenticalFiles, normalizeSkipDuplicateFiles, normalizeStoredPathTarget, normalizeTextContent, normalizeTrailingInlineToken, normalizeUploadAccessGroup, normalizeWebAccess, notifyAgentSaveAttachment, parseAiAgentValue, parseAttachmentContent, parseIndexingLabel, parseIndexingRequestText, parseLinkedReply, patchProjectSettings, peekImagePreviewUrl, prepareDownloadText, presignExpiryEpochMs, previewImageContentType, previewLayoutBox, previewMintCacheToken, previewableExtOf, primeProjectSettings, projectAccessSetting, projectAnswerMode, projectAsksUploadAccess, projectChatGreeting, projectSettingsSettled, projectShareIdenticalFiles, projectSkipDuplicateFiles, projectUploadAccessGroup, projectWebAccess, promotableCopies, providerBodyWasRead, providerDocument, readExpiredAttachmentHref, readyProjectSettings, reconcilerReadsEnabled, registerAttachmentParser, registerModelContextWindows, renderInlineLinkHtml, repairUrlEntities, repairUrlWhitespace, requestIdTimeMs, resetFileIndexOnServer, resolveAnswerMode, resolveImagePreviewUrl, resolveSkipDuplicateFiles, resolveWebAccess, retrievalNoteFromText, retrievalNoteOfAnswer, runIndexUniqueId, runRecordDurationMs, runSettleSideEffect, safeDecodeURIComponent, sanitizeAttachmentLinksForHistory, setProjectContextWindow, setProjectSettings, shareIdenticalFilesFrom, shouldRescueInFlightMessage, sideEffectDone, skapiSupportsStreaming, skipDuplicateFilesEnabled, skipDuplicateFilesFrom, splitLabelForFit, statusPushEnabled, statusPushLive, streamRecoveryEnabled, streamRecoveryLabels, streamRecoveryPhase, stripFileBlocksFromHistory, transformContentWithImages, transformContentWithOpenAIImages, truncateLabelForDisplay, typewriterResumeIndex, uploadAccessGroupFrom, upsertIndexRunRecordSafe, wallClockNow, webAccessEnabled, webAccessFrom };
|
|
13527
13940
|
//# sourceMappingURL=engine.mjs.map
|
|
13528
13941
|
//# sourceMappingURL=engine.mjs.map
|