bunnyquery 1.21.13 → 1.21.15

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/dist/engine.cjs CHANGED
@@ -1076,7 +1076,7 @@ function buildChatSystemPrompt(params) {
1076
1076
  const indexGroupLiteral = typeof g === "number" ? String(g) : g === "public" || g === "private" || g === "authorized" || g === "admin" ? `"${g}"` : '"authorized"';
1077
1077
  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)`;
1078
1078
  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.
1079
- 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.
1079
+ FILES IN ANOTHER LANGUAGE. The files may be written in another language than the question, in another alphabet or in the same one (a Russian or English manual asked about in Korean, German documents asked about in English). When searches in the question's language find nothing, or searchText reports query_language_mismatch (its text_language names the files' language), search again with the question's key terms translated into the language the files' TEXT is in: searchText names that language for each file ("its text is in German"; only when it cannot tell, the alphabet, "Latin script, e.g. English"), and earlier hits show it; passing the question as the DOCUMENTS rule says lets searchText tell the question's language; a file NAME can be in another language than its text (a "\u0420\u042D" manual written in English), so go by the text. One or two short queries of the main terms (e.g. "oil leak", "gearbox"), and if the first translation finds nothing, try the other likely language (English is the most common for technical manuals), before concluding anything.
1080
1080
  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`}.
1081
1081
  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.
1082
1082
  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.
@@ -2918,6 +2918,7 @@ async function notifyAgentSaveAttachment(info) {
2918
2918
  ...shareIdentical ? { share_identical: true } : {}
2919
2919
  }]
2920
2920
  } : {};
2921
+ const groupHeader = info.fileGroup && attachment.storagePath ? fileGroupHeader(attachment.storagePath) : {};
2921
2922
  const userMessage = visionFile && renderPlaceholder ? buildIndexingRenderMessage(attachment, renderPlaceholder, renderFrom) : windowedRead && windowPlaceholder ? buildIndexingWindowMessage(attachment, windowPlaceholder, false) : continuing ? buildIndexingContinueMessage(attachment) : buildIndexingUserMessage(
2922
2923
  attachment,
2923
2924
  parsedContent ? { inlineContent: parsedContent } : placeholder ? { inlineContentPlaceholder: placeholder } : pagedRead ? { pagedRead: true } : imageFile ? { imageFile } : void 0
@@ -2950,7 +2951,8 @@ async function notifyAgentSaveAttachment(info) {
2950
2951
  method: "POST",
2951
2952
  headers: {
2952
2953
  "content-type": "application/json",
2953
- Authorization: "Bearer $CLIENT_SECRET"
2954
+ Authorization: "Bearer $CLIENT_SECRET",
2955
+ ...groupHeader
2954
2956
  },
2955
2957
  data: {
2956
2958
  model: resolvedModel2,
@@ -3000,7 +3002,8 @@ async function notifyAgentSaveAttachment(info) {
3000
3002
  "content-type": "application/json",
3001
3003
  "x-api-key": "$CLIENT_SECRET",
3002
3004
  "anthropic-version": ANTHROPIC_VERSION,
3003
- "anthropic-beta": ANTHROPIC_BETA_HEADER
3005
+ "anthropic-beta": ANTHROPIC_BETA_HEADER,
3006
+ ...groupHeader
3004
3007
  },
3005
3008
  data: {
3006
3009
  model: resolvedModel,
@@ -3159,6 +3162,57 @@ function upsertIndexRunRecordSafe(service, storagePath, patch, opts) {
3159
3162
  return void 0;
3160
3163
  });
3161
3164
  }
3165
+ var FILE_GROUP_HEADER = "x-bq-file-group";
3166
+ function fileGroupHeader(groupKey) {
3167
+ return groupKey ? { [FILE_GROUP_HEADER]: sha1Hex(groupKey) } : {};
3168
+ }
3169
+ function sha1Hex(text) {
3170
+ const bytes = new TextEncoder().encode(String(text));
3171
+ const bitLen = bytes.length * 8;
3172
+ const words = new Uint32Array(((bytes.length + 8 >> 6) + 1) * 16);
3173
+ for (let i = 0; i < bytes.length; i++) words[i >> 2] |= bytes[i] << 24 - i % 4 * 8;
3174
+ words[bytes.length >> 2] |= 128 << 24 - bytes.length % 4 * 8;
3175
+ words[words.length - 1] = bitLen >>> 0;
3176
+ words[words.length - 2] = Math.floor(bitLen / 4294967296);
3177
+ let h0 = 1732584193, h1 = 4023233417, h2 = 2562383102, h3 = 271733878, h4 = 3285377520;
3178
+ const w = new Uint32Array(80);
3179
+ for (let off = 0; off < words.length; off += 16) {
3180
+ for (let t = 0; t < 16; t++) w[t] = words[off + t];
3181
+ for (let t = 16; t < 80; t++) {
3182
+ const x = w[t - 3] ^ w[t - 8] ^ w[t - 14] ^ w[t - 16];
3183
+ w[t] = x << 1 | x >>> 31;
3184
+ }
3185
+ let a = h0, b = h1, c = h2, d = h3, e = h4;
3186
+ for (let t = 0; t < 80; t++) {
3187
+ let f, k;
3188
+ if (t < 20) {
3189
+ f = b & c | ~b & d;
3190
+ k = 1518500249;
3191
+ } else if (t < 40) {
3192
+ f = b ^ c ^ d;
3193
+ k = 1859775393;
3194
+ } else if (t < 60) {
3195
+ f = b & c | b & d | c & d;
3196
+ k = 2400959708;
3197
+ } else {
3198
+ f = b ^ c ^ d;
3199
+ k = 3395469782;
3200
+ }
3201
+ const tmp = (a << 5 | a >>> 27) + f + e + k + w[t] >>> 0;
3202
+ e = d;
3203
+ d = c;
3204
+ c = b << 30 | b >>> 2;
3205
+ b = a;
3206
+ a = tmp;
3207
+ }
3208
+ h0 = h0 + a >>> 0;
3209
+ h1 = h1 + b >>> 0;
3210
+ h2 = h2 + c >>> 0;
3211
+ h3 = h3 + d >>> 0;
3212
+ h4 = h4 + e >>> 0;
3213
+ }
3214
+ return [h0, h1, h2, h3, h4].map((v) => (v >>> 0).toString(16).padStart(8, "0")).join("");
3215
+ }
3162
3216
  function bgIndexingQueueName(userId, service) {
3163
3217
  return (userId || service || "") + BG_INDEXING_QUEUE_SUFFIX;
3164
3218
  }
@@ -4814,6 +4868,7 @@ function createSseParser() {
4814
4868
  var error = null;
4815
4869
  var stopReason = null;
4816
4870
  var toolCalls = [];
4871
+ var argBuf = {};
4817
4872
  var malformedFrames = 0;
4818
4873
  var malformedToolJson = 0;
4819
4874
  var message = null;
@@ -4936,7 +4991,10 @@ function createSseParser() {
4936
4991
  type: block.type
4937
4992
  };
4938
4993
  if (typeof block.server_name === "string") call.serverName = block.server_name;
4994
+ if (typeof block.id === "string" && block.id) call.id = block.id;
4939
4995
  toolCalls.push(call);
4996
+ } else if (block && typeof block.type === "string") {
4997
+ markClaudeCallsDone(block);
4940
4998
  }
4941
4999
  return;
4942
5000
  }
@@ -4960,6 +5018,10 @@ function createSseParser() {
4960
5018
  var j = numberOr(ev.index, -1);
4961
5019
  var s = j >= 0 ? blocks.get(j) : void 0;
4962
5020
  if (s && s.sawJson) finishToolJson(s);
5021
+ if (s && s.block && s.block.input && typeof s.block.input === "object") {
5022
+ var sc = callAt(j);
5023
+ if (sc) sc.input = s.block.input;
5024
+ }
4963
5025
  return;
4964
5026
  }
4965
5027
  if (type === "message_delta") {
@@ -5020,6 +5082,34 @@ function createSseParser() {
5020
5082
  malformedToolJson++;
5021
5083
  }
5022
5084
  }
5085
+ function callAt(index) {
5086
+ for (var k = toolCalls.length - 1; k >= 0; k--) {
5087
+ if (toolCalls[k].index === index) return toolCalls[k];
5088
+ }
5089
+ return null;
5090
+ }
5091
+ function markClaudeCallsDone(block) {
5092
+ var t = block.type;
5093
+ if (/tool_result$/.test(t)) {
5094
+ var ref = typeof block.tool_use_id === "string" ? block.tool_use_id : "";
5095
+ for (var k = 0; k < toolCalls.length; k++) {
5096
+ if (ref && toolCalls[k].id === ref) toolCalls[k].done = true;
5097
+ }
5098
+ return;
5099
+ }
5100
+ if (t === "text" || t === "thinking" || t === "redacted_thinking") {
5101
+ for (var m = 0; m < toolCalls.length; m++) toolCalls[m].done = true;
5102
+ }
5103
+ }
5104
+ function parseArgs(args) {
5105
+ if (args && typeof args === "object") return args;
5106
+ if (typeof args !== "string" || !args) return void 0;
5107
+ try {
5108
+ return JSON.parse(args);
5109
+ } catch (e) {
5110
+ return void 0;
5111
+ }
5112
+ }
5023
5113
  function deltaBlockType(deltaType) {
5024
5114
  if (deltaType === "thinking_delta" || deltaType === "signature_delta") return "thinking";
5025
5115
  if (deltaType === "input_json_delta") return "tool_use";
@@ -5053,13 +5143,54 @@ function createSseParser() {
5053
5143
  if (type === "response.output_item.added") {
5054
5144
  var item = ev.item;
5055
5145
  if (item && typeof item.type === "string" && OPENAI_TOOL_ITEMS[item.type]) {
5056
- toolCalls.push({
5146
+ var oc = {
5057
5147
  index: numberOr(ev.output_index, toolCalls.length),
5058
5148
  // A built-in tool (web_search_call) has no name of its own, so the item
5059
5149
  // type is the only label there is and a row can still be drawn.
5060
5150
  name: typeof item.name === "string" && item.name ? item.name : item.type,
5061
5151
  type: item.type
5062
- });
5152
+ };
5153
+ if (typeof item.id === "string" && item.id) oc.id = item.id;
5154
+ var oa = parseArgs(item.arguments);
5155
+ if (oa !== void 0) oc.input = oa;
5156
+ toolCalls.push(oc);
5157
+ }
5158
+ return;
5159
+ }
5160
+ if (type === "response.mcp_call_arguments.delta" || type === "response.function_call_arguments.delta") {
5161
+ var gi = numberOr(ev.output_index, -1);
5162
+ var gc = callAt(gi);
5163
+ if (gc && gc.input === void 0 && typeof ev.delta === "string") {
5164
+ argBuf[gi] = (argBuf[gi] || "") + ev.delta;
5165
+ var gt = argBuf[gi].trim();
5166
+ if (gt.charAt(gt.length - 1) === "}") {
5167
+ var ga = parseArgs(gt);
5168
+ if (ga !== void 0) gc.input = ga;
5169
+ }
5170
+ }
5171
+ return;
5172
+ }
5173
+ if (type === "response.mcp_call_arguments.done" || type === "response.function_call_arguments.done") {
5174
+ var ac = callAt(numberOr(ev.output_index, -1));
5175
+ var aa = parseArgs(ev.arguments);
5176
+ if (ac && aa !== void 0) ac.input = aa;
5177
+ return;
5178
+ }
5179
+ if (type === "response.mcp_call.completed" || type === "response.mcp_call.failed") {
5180
+ var cc = callAt(numberOr(ev.output_index, -1));
5181
+ if (cc) cc.done = true;
5182
+ return;
5183
+ }
5184
+ if (type === "response.output_item.done") {
5185
+ var di = ev.item;
5186
+ if (di && typeof di.type === "string" && OPENAI_TOOL_ITEMS[di.type]) {
5187
+ var dc = callAt(numberOr(ev.output_index, -1));
5188
+ if (dc) {
5189
+ var da = parseArgs(di.arguments);
5190
+ if (da !== void 0) dc.input = da;
5191
+ else if (di.action && typeof di.action === "object" && dc.input === void 0) dc.input = di.action;
5192
+ dc.done = true;
5193
+ }
5063
5194
  }
5064
5195
  return;
5065
5196
  }
@@ -5210,7 +5341,12 @@ function createSseParser() {
5210
5341
  provider,
5211
5342
  text: currentText(),
5212
5343
  thinkingText: currentThinking(),
5213
- toolCalls: toolCalls.slice(),
5344
+ // Copied per call, not just per array: a call's input/done fill in after it
5345
+ // is first seen, and a snapshot already handed out must not change under
5346
+ // its reader.
5347
+ toolCalls: toolCalls.map(function(t) {
5348
+ return Object.assign({}, t);
5349
+ }),
5214
5350
  toolNames: toolCalls.map(function(t) {
5215
5351
  return t.name;
5216
5352
  }),
@@ -5264,6 +5400,190 @@ function mergeInto(target, src) {
5264
5400
  return target;
5265
5401
  }
5266
5402
 
5403
+ // src/engine/activity.ts
5404
+ var CHAT_ACTIVITY_ROTATE_MS = 4e3;
5405
+ var byItem = /* @__PURE__ */ new Map();
5406
+ var startByObj = /* @__PURE__ */ new WeakMap();
5407
+ var startById = /* @__PURE__ */ new Map();
5408
+ var MAX_IDS = 200;
5409
+ function remember(map, key, value) {
5410
+ if (map.has(key)) map.delete(key);
5411
+ map.set(key, value);
5412
+ if (map.size > MAX_IDS) {
5413
+ var oldest = map.keys().next();
5414
+ if (!oldest.done) map.delete(oldest.value);
5415
+ }
5416
+ }
5417
+ function stepOf(snap) {
5418
+ if (!snap) return { step: "thinking", count: 0 };
5419
+ var calls = Array.isArray(snap.toolCalls) ? snap.toolCalls : [];
5420
+ if (typeof snap.text === "string" && /\S/.test(snap.text)) return { step: "writing", count: calls.length };
5421
+ if (!calls.length) return { step: "thinking", count: 0 };
5422
+ var last = calls[calls.length - 1];
5423
+ if (last && !last.done) return { step: "tool", call: last, count: calls.length };
5424
+ return { step: "between", count: calls.length };
5425
+ }
5426
+ function noteChatActivity(serverItemId, snap, now) {
5427
+ if (!serverItemId) return;
5428
+ var t = typeof now === "number" ? now : Date.now();
5429
+ var s = stepOf(snap);
5430
+ var key = s.step + ":" + s.count;
5431
+ var prev = byItem.get(serverItemId);
5432
+ if (prev && prev.key === key) {
5433
+ if (s.call && s.call.input !== void 0 && prev.input === void 0) prev.input = s.call.input;
5434
+ return;
5435
+ }
5436
+ var act = { step: s.step, since: t, key };
5437
+ if (s.call) {
5438
+ act.tool = s.call.name;
5439
+ if (s.call.input !== void 0) act.input = s.call.input;
5440
+ }
5441
+ remember(byItem, serverItemId, act);
5442
+ }
5443
+ function chatActivityOf(msg) {
5444
+ var id = msg && typeof msg._serverItemId === "string" ? msg._serverItemId : "";
5445
+ return id && byItem.get(id) || null;
5446
+ }
5447
+ function turnStart(msg, now) {
5448
+ var ids = [];
5449
+ if (msg && typeof msg._serverItemId === "string" && msg._serverItemId) ids.push(msg._serverItemId);
5450
+ if (msg && typeof msg._localId === "string" && msg._localId) ids.push(msg._localId);
5451
+ var t;
5452
+ if (msg && typeof msg === "object") t = startByObj.get(msg);
5453
+ for (var i = 0; t === void 0 && i < ids.length; i++) t = startById.get(ids[i]);
5454
+ if (t === void 0) t = now;
5455
+ if (msg && typeof msg === "object") startByObj.set(msg, t);
5456
+ for (var j = 0; j < ids.length; j++) if (startById.get(ids[j]) !== t) remember(startById, ids[j], t);
5457
+ return t;
5458
+ }
5459
+ function langOf(lang) {
5460
+ return typeof lang === "string" && /^ko\b/i.test(lang) ? "ko" : "en";
5461
+ }
5462
+ function clip(v, max) {
5463
+ if (typeof v !== "string") return "";
5464
+ var s = v.replace(/\s+/g, " ").trim();
5465
+ if (s.length > max) s = s.slice(0, max - 1).trim() + "\u2026";
5466
+ return s;
5467
+ }
5468
+ function fileName(v) {
5469
+ if (typeof v !== "string" || !v) return "";
5470
+ var s = v.replace(/^(src::|db:)/, "");
5471
+ var parts = s.split("/").filter(function(p) {
5472
+ return !!p;
5473
+ });
5474
+ return clip(parts.length ? parts[parts.length - 1] : s, 40);
5475
+ }
5476
+ var T = {
5477
+ en: {
5478
+ thinking: ["Reading your question", "Thinking about where to look", "Planning the search", "Still thinking, this can take a moment", "Working out the best way to find it", "Getting ready to look through your data"],
5479
+ between: ["Looking at what it found", "Deciding what to check next", "Putting the pieces together", "Checking that it has what it needs", "Still working on it"],
5480
+ writing: ["Writing the answer"],
5481
+ still: "Still working on it",
5482
+ working: "Working"
5483
+ },
5484
+ ko: {
5485
+ thinking: ["\uC9C8\uBB38\uC744 \uC77D\uB294 \uC911", "\uC5B4\uB514\uB97C \uCC3E\uC544\uBCFC\uC9C0 \uC0DD\uAC01\uD558\uB294 \uC911", "\uAC80\uC0C9 \uBC29\uBC95\uC744 \uC815\uD558\uB294 \uC911", "\uC544\uC9C1 \uC0DD\uAC01\uD558\uB294 \uC911, \uC7A0\uC2DC\uB9CC \uAE30\uB2E4\uB824 \uC8FC\uC138\uC694", "\uAC00\uC7A5 \uC88B\uC740 \uBC29\uBC95\uC744 \uCC3E\uB294 \uC911", "\uB370\uC774\uD130\uB97C \uC0B4\uD3B4\uBCFC \uC900\uBE44\uB97C \uD558\uB294 \uC911"],
5486
+ between: ["\uCC3E\uC740 \uB0B4\uC6A9\uC744 \uC0B4\uD3B4\uBCF4\uB294 \uC911", "\uB2E4\uC74C\uC5D0 \uD655\uC778\uD560 \uAC83\uC744 \uC815\uD558\uB294 \uC911", "\uB0B4\uC6A9\uC744 \uC815\uB9AC\uD558\uB294 \uC911", "\uD544\uC694\uD55C \uB0B4\uC6A9\uC774 \uB2E4 \uC788\uB294\uC9C0 \uD655\uC778\uD558\uB294 \uC911", "\uC544\uC9C1 \uC791\uC5C5 \uC911"],
5487
+ writing: ["\uB2F5\uBCC0\uC744 \uC791\uC131\uD558\uB294 \uC911"],
5488
+ still: "\uC544\uC9C1 \uC791\uC5C5 \uC911",
5489
+ working: "\uC791\uC5C5 \uC911"
5490
+ }
5491
+ };
5492
+ function toolLines(tool, i, lang) {
5493
+ var ko = lang === "ko";
5494
+ var inp = i && typeof i === "object" ? i : {};
5495
+ var q = clip(inp.query || inp.question, 40);
5496
+ var f = fileName(inp.path);
5497
+ var tbl = clip(inp.table_name, 30);
5498
+ switch (tool) {
5499
+ case "searchText":
5500
+ return ko ? [
5501
+ q ? f ? f + '\uC5D0\uC11C "' + q + '" \uCC3E\uB294 \uC911' : '\uD30C\uC77C\uC5D0\uC11C "' + q + '" \uCC3E\uB294 \uC911' : "\uD30C\uC77C\uC5D0\uC11C \uCC3E\uB294 \uC911",
5502
+ "\uBAA8\uB4E0 \uD398\uC774\uC9C0\uB97C \uD655\uC778\uD558\uB294 \uC911",
5503
+ "\uC544\uC9C1 \uCC3E\uB294 \uC911, \uD070 \uD504\uB85C\uC81D\uD2B8\uB294 \uC870\uAE08 \uB354 \uAC78\uB824\uC694",
5504
+ "\uACC4\uC18D \uCC3E\uB294 \uC911, \uAE30\uB2E4\uB824 \uC8FC\uC154\uC11C \uAC10\uC0AC\uD574\uC694"
5505
+ ] : [
5506
+ q ? f ? "Searching " + f + ' for "' + q + '"' : 'Searching your files for "' + q + '"' : "Searching your files",
5507
+ "Checking every page",
5508
+ "Still searching, big projects take a bit longer",
5509
+ "Still searching, thanks for waiting"
5510
+ ];
5511
+ case "readFileContent":
5512
+ return ko ? [
5513
+ f ? f + " \uC77D\uB294 \uC911" : "\uD30C\uC77C\uC744 \uC77D\uB294 \uC911",
5514
+ "\uD398\uC774\uC9C0\uB97C \uC0B4\uD3B4\uBCF4\uB294 \uC911",
5515
+ "\uC544\uC9C1 \uC77D\uB294 \uC911, \uAE34 \uD30C\uC77C\uC740 \uC870\uAE08 \uB354 \uAC78\uB824\uC694"
5516
+ ] : [
5517
+ f ? "Reading " + f : "Reading a file",
5518
+ "Going through the pages",
5519
+ "Still reading, long files take a bit longer"
5520
+ ];
5521
+ case "getFileOutline":
5522
+ return ko ? [f ? f + " \uAD6C\uC131\uC744 \uC0B4\uD3B4\uBCF4\uB294 \uC911" : "\uD30C\uC77C \uAD6C\uC131\uC744 \uC0B4\uD3B4\uBCF4\uB294 \uC911", "\uBAA9\uCC28\uB97C \uD655\uC778\uD558\uB294 \uC911", T.ko.still] : [f ? "Looking at how " + f + " is laid out" : "Looking at how the file is laid out", "Checking the table of contents", T.en.still];
5523
+ case "getRecords":
5524
+ return ko ? [
5525
+ tbl ? tbl + " \uD14C\uC774\uBE14\uC5D0\uC11C \uAE30\uB85D\uC744 \uCC3E\uB294 \uC911" : "\uAE30\uB85D\uC744 \uCC3E\uB294 \uC911",
5526
+ "\uD589\uC744 \uC0B4\uD3B4\uBCF4\uB294 \uC911",
5527
+ "\uC544\uC9C1 \uCC3E\uB294 \uC911, \uD070 \uD14C\uC774\uBE14\uC740 \uC870\uAE08 \uB354 \uAC78\uB824\uC694"
5528
+ ] : [
5529
+ tbl ? "Looking up records in " + tbl : "Looking up records",
5530
+ "Going through the rows",
5531
+ "Still looking, big tables take a bit longer"
5532
+ ];
5533
+ case "exportRecordsToFile":
5534
+ return ko ? [tbl ? tbl + " \uAE30\uB85D\uC744 \uD30C\uC77C\uB85C \uB9CC\uB4DC\uB294 \uC911" : "\uAE30\uB85D\uC744 \uD30C\uC77C\uB85C \uB9CC\uB4DC\uB294 \uC911", "\uD30C\uC77C\uC744 \uB9CC\uB4DC\uB294 \uC911", "\uC544\uC9C1 \uB9CC\uB4DC\uB294 \uC911, \uD070 \uD14C\uC774\uBE14\uC740 \uC870\uAE08 \uB354 \uAC78\uB824\uC694"] : [tbl ? "Exporting records from " + tbl : "Exporting records", "Building the file", "Still exporting, big tables take a bit longer"];
5535
+ case "writeReport":
5536
+ return ko ? ["\uBCF4\uACE0\uC11C\uB97C \uC791\uC131\uD558\uB294 \uC911", "\uC544\uC9C1 \uC791\uC131\uD558\uB294 \uC911, \uAE34 \uBCF4\uACE0\uC11C\uB294 \uC870\uAE08 \uB354 \uAC78\uB824\uC694"] : ["Writing the report", "Still writing, long reports take a bit longer"];
5537
+ case "getTables":
5538
+ return ko ? ["\uC5B4\uB5A4 \uD14C\uC774\uBE14\uC774 \uC788\uB294\uC9C0 \uD655\uC778\uD558\uB294 \uC911", T.ko.still] : ["Checking which tables there are", T.en.still];
5539
+ case "getTags":
5540
+ return ko ? ["\uD0DC\uADF8\uB97C \uD655\uC778\uD558\uB294 \uC911", T.ko.still] : ["Checking tags", T.en.still];
5541
+ case "getIndexes":
5542
+ return ko ? ["\uD14C\uC774\uBE14 \uD56D\uBAA9\uC744 \uD655\uC778\uD558\uB294 \uC911", T.ko.still] : ["Checking the table's fields", T.en.still];
5543
+ case "getUniqueId":
5544
+ return ko ? ["\uB808\uCF54\uB4DC ID\uB97C \uD655\uC778\uD558\uB294 \uC911", T.ko.still] : ["Checking record IDs", T.en.still];
5545
+ case "postRecords":
5546
+ return ko ? ["\uAE30\uB85D\uC744 \uC800\uC7A5\uD558\uB294 \uC911", T.ko.still] : ["Saving records", T.en.still];
5547
+ case "updateRecords":
5548
+ return ko ? ["\uAE30\uB85D\uC744 \uC218\uC815\uD558\uB294 \uC911", T.ko.still] : ["Updating records", T.en.still];
5549
+ case "deleteRecords":
5550
+ return ko ? ["\uAE30\uB85D\uC744 \uC0AD\uC81C\uD558\uB294 \uC911", T.ko.still] : ["Deleting records", T.en.still];
5551
+ case "getTemporaryUrl":
5552
+ return ko ? [f ? f + " \uB9C1\uD06C\uB97C \uB9CC\uB4DC\uB294 \uC911" : "\uB9C1\uD06C\uB97C \uB9CC\uB4DC\uB294 \uC911", T.ko.still] : [f ? "Getting a link to " + f : "Getting a link", T.en.still];
5553
+ case "getToolResponsePage":
5554
+ return ko ? ["\uACB0\uACFC\uC758 \uB2E4\uC74C \uBD80\uBD84\uC744 \uC77D\uB294 \uC911", T.ko.still] : ["Reading the next part of the results", T.en.still];
5555
+ case "correctSearchLink":
5556
+ return ko ? ["\uD398\uC774\uC9C0 \uB9C1\uD06C\uB97C \uD655\uC778\uD558\uB294 \uC911", T.ko.still] : ["Checking the page link", T.en.still];
5557
+ case "getProjectInfos":
5558
+ return ko ? ["\uD504\uB85C\uC81D\uD2B8 \uC815\uBCF4\uB97C \uD655\uC778\uD558\uB294 \uC911", T.ko.still] : ["Checking the project details", T.en.still];
5559
+ case "getProfile":
5560
+ return ko ? ["\uACC4\uC815 \uC815\uBCF4\uB97C \uD655\uC778\uD558\uB294 \uC911", T.ko.still] : ["Checking your account", T.en.still];
5561
+ case "web_search":
5562
+ case "web_search_call":
5563
+ return ko ? ["\uC6F9\uC5D0\uC11C \uCC3E\uB294 \uC911", T.ko.still] : ["Searching the web", T.en.still];
5564
+ default:
5565
+ return ko ? [T.ko.working, T.ko.still] : [T.en.working, T.en.still];
5566
+ }
5567
+ }
5568
+ function pick(lines, elapsed, loopFrom) {
5569
+ var n = Math.floor(Math.max(0, elapsed) / CHAT_ACTIVITY_ROTATE_MS);
5570
+ if (n < lines.length) return lines[n];
5571
+ var from = Math.min(Math.max(0, loopFrom || 0), lines.length - 1);
5572
+ var span = lines.length - from;
5573
+ return lines[from + (n - lines.length) % span];
5574
+ }
5575
+ function chatActivityLine(msg, now, lang) {
5576
+ var t = typeof now === "number" ? now : Date.now();
5577
+ var L = langOf(lang);
5578
+ var start = turnStart(msg, t);
5579
+ var act = chatActivityOf(msg);
5580
+ if (!act || act.step === "thinking") return pick(T[L].thinking, t - start, 1);
5581
+ var elapsed = t - act.since;
5582
+ if (act.step === "writing") return pick(T[L].writing, elapsed);
5583
+ if (act.step === "between") return pick(T[L].between, elapsed);
5584
+ return pick(toolLines(act.tool || "", act.input, L), elapsed);
5585
+ }
5586
+
5267
5587
  // src/engine/history.ts
5268
5588
  function filterListByClearHorizon(list, clearedAt) {
5269
5589
  if (!clearedAt) return list;
@@ -5948,7 +6268,7 @@ function createScrollAnchor(options) {
5948
6268
  restore(anchor);
5949
6269
  return result;
5950
6270
  }
5951
- function remember() {
6271
+ function remember2() {
5952
6272
  held = capture();
5953
6273
  }
5954
6274
  function hold() {
@@ -5994,7 +6314,7 @@ function createScrollAnchor(options) {
5994
6314
  capture,
5995
6315
  restore,
5996
6316
  preserve,
5997
- remember,
6317
+ remember: remember2,
5998
6318
  hold,
5999
6319
  pinBottom,
6000
6320
  absorb,
@@ -7272,6 +7592,7 @@ var _ChatSession = class _ChatSession {
7272
7592
  _paintLiveStream(st) {
7273
7593
  if (st.ended) return;
7274
7594
  st.lastPaintAt = nowMs();
7595
+ noteChatActivity(st.id, st.parser.snapshot());
7275
7596
  if (this.getHistoryCacheKey() !== st.ownerKey) return;
7276
7597
  var idx = this._liveTargetIndex(st.id);
7277
7598
  if (idx === -1) {
@@ -12129,7 +12450,7 @@ var _ChatSession = class _ChatSession {
12129
12450
  * or waiting is left to the live queue check, which shows it as it settles; one already
12130
12451
  * in the chat is not read again. Never throws.
12131
12452
  */
12132
- loadRunPasses(storagePath, fileName) {
12453
+ loadRunPasses(storagePath, fileName2) {
12133
12454
  var self = this;
12134
12455
  var cfg = chatEngineConfig();
12135
12456
  var list = cfg.listIndexPasses, lookup = cfg.csrHistoryItemLookup;
@@ -12148,7 +12469,7 @@ var _ChatSession = class _ChatSession {
12148
12469
  p.error = void 0;
12149
12470
  this.host.notify();
12150
12471
  var svcId = id.projectId, owner = id.owner;
12151
- var name = fileName || storagePath.split("/").pop() || storagePath;
12472
+ var name = fileName2 || storagePath.split("/").pop() || storagePath;
12152
12473
  var idsReady = p.ids.length ? Promise.resolve(p.ids) : Promise.resolve(list(svcId, storagePath)).then(function(ids) {
12153
12474
  var clean = (Array.isArray(ids) ? ids : []).filter(function(x) {
12154
12475
  return typeof x === "string" && !!x;
@@ -12310,14 +12631,14 @@ var _ChatSession = class _ChatSession {
12310
12631
  });
12311
12632
  }
12312
12633
  /** The page progress to show for a file's row, or null (see _refreshPageProgress). */
12313
- pageProgressFor(storagePath, fileName) {
12634
+ pageProgressFor(storagePath, fileName2) {
12314
12635
  var map = this.state.indexPageProgress;
12315
12636
  if (!map) return null;
12316
12637
  var p = storagePath ? map[storagePath] : void 0;
12317
- if (!p && fileName) {
12638
+ if (!p && fileName2) {
12318
12639
  var hit = null;
12319
12640
  for (var k in map) {
12320
- if (k === fileName || k.slice(-(fileName.length + 1)) === "/" + fileName) {
12641
+ if (k === fileName2 || k.slice(-(fileName2.length + 1)) === "/" + fileName2) {
12321
12642
  if (hit) {
12322
12643
  hit = null;
12323
12644
  break;
@@ -13946,6 +14267,7 @@ exports.ANSWER_MODE_SETTING_LABEL = ANSWER_MODE_SETTING_LABEL;
13946
14267
  exports.BG_INDEXING_QUEUE_SUFFIX = BG_INDEXING_QUEUE_SUFFIX;
13947
14268
  exports.BOM = BOM;
13948
14269
  exports.BOM_EXTS = BOM_EXTS;
14270
+ exports.CHAT_ACTIVITY_ROTATE_MS = CHAT_ACTIVITY_ROTATE_MS;
13949
14271
  exports.CHAT_GREETING_MAX_LENGTH = CHAT_GREETING_MAX_LENGTH;
13950
14272
  exports.CLAUDE_INPUT_CAP_RATIO = CLAUDE_INPUT_CAP_RATIO;
13951
14273
  exports.CLAUDE_PER_REQUEST_INPUT_CAP = CLAUDE_PER_REQUEST_INPUT_CAP;
@@ -13970,6 +14292,7 @@ exports.EXPIRED_ATTACHMENT_URL_HOST = EXPIRED_ATTACHMENT_URL_HOST;
13970
14292
  exports.EXPIRED_ATTACHMENT_URL_ORIGIN = EXPIRED_ATTACHMENT_URL_ORIGIN;
13971
14293
  exports.EXPIRED_LINK_REFRESH_EXPIRES_SECONDS = EXPIRED_LINK_REFRESH_EXPIRES_SECONDS;
13972
14294
  exports.EXT_CONTENT_TYPES = EXT_CONTENT_TYPES;
14295
+ exports.FILE_GROUP_HEADER = FILE_GROUP_HEADER;
13973
14296
  exports.HISTORY_BUDGET_RATIO = HISTORY_BUDGET_RATIO;
13974
14297
  exports.HISTORY_FILL_SLACK_PX = HISTORY_FILL_SLACK_PX;
13975
14298
  exports.HISTORY_TOKEN_BUDGET = HISTORY_TOKEN_BUDGET;
@@ -14060,6 +14383,8 @@ exports.callClaudeWithMcp = callClaudeWithMcp;
14060
14383
  exports.callClaudeWithPublicMcp = callClaudeWithPublicMcp;
14061
14384
  exports.callOpenAIWithPublicMcp = callOpenAIWithPublicMcp;
14062
14385
  exports.canonicalizePathForm = canonicalizePathForm;
14386
+ exports.chatActivityLine = chatActivityLine;
14387
+ exports.chatActivityOf = chatActivityOf;
14063
14388
  exports.chatCacheKey = chatCacheKey;
14064
14389
  exports.chatEffortFields = chatEffortFields;
14065
14390
  exports.chatEngineConfig = chatEngineConfig;
@@ -14102,6 +14427,7 @@ exports.extractOpenAIText = extractOpenAIText;
14102
14427
  exports.extractRemotePathFromAttachmentHref = extractRemotePathFromAttachmentHref;
14103
14428
  exports.extractRetrievalNote = extractRetrievalNote;
14104
14429
  exports.fetchLiveIndexingKeys = fetchLiveIndexingKeys;
14430
+ exports.fileGroupHeader = fileGroupHeader;
14105
14431
  exports.fileNameOf = fileNameOf;
14106
14432
  exports.fillHistoryViewport = fillHistoryViewport;
14107
14433
  exports.filterListByClearHorizon = filterListByClearHorizon;
@@ -14191,6 +14517,7 @@ exports.normalizeTextContent = normalizeTextContent;
14191
14517
  exports.normalizeTrailingInlineToken = normalizeTrailingInlineToken;
14192
14518
  exports.normalizeUploadAccessGroup = normalizeUploadAccessGroup;
14193
14519
  exports.normalizeWebAccess = normalizeWebAccess;
14520
+ exports.noteChatActivity = noteChatActivity;
14194
14521
  exports.notifyAgentSaveAttachment = notifyAgentSaveAttachment;
14195
14522
  exports.parseAiAgentValue = parseAiAgentValue;
14196
14523
  exports.parseAttachmentContent = parseAttachmentContent;
@@ -14241,6 +14568,7 @@ exports.safeDecodeURIComponent = safeDecodeURIComponent;
14241
14568
  exports.sanitizeAttachmentLinksForHistory = sanitizeAttachmentLinksForHistory;
14242
14569
  exports.setProjectContextWindow = setProjectContextWindow;
14243
14570
  exports.setProjectSettings = setProjectSettings;
14571
+ exports.sha1Hex = sha1Hex;
14244
14572
  exports.shareIdenticalFilesFrom = shareIdenticalFilesFrom;
14245
14573
  exports.shouldRescueInFlightMessage = shouldRescueInFlightMessage;
14246
14574
  exports.sideEffectDone = sideEffectDone;