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/bunnyquery.js CHANGED
@@ -1008,7 +1008,7 @@ Extracted content of attached office files (read inline below; do NOT fetch thei
1008
1008
  const indexGroupLiteral = typeof g === "number" ? String(g) : g === "public" || g === "private" || g === "authorized" || g === "admin" ? `"${g}"` : '"authorized"';
1009
1009
  const reindexHint = canUpload === false ? `asking the project's owner to re-index that file` : `re-indexing that file (attach the same file again and choose to reindex it)`;
1010
1010
  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.
1011
- 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.
1011
+ 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.
1012
1012
  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`}.
1013
1013
  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.
1014
1014
  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.
@@ -2790,6 +2790,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
2790
2790
  ...shareIdentical ? { share_identical: true } : {}
2791
2791
  }]
2792
2792
  } : {};
2793
+ const groupHeader = info.fileGroup && attachment.storagePath ? fileGroupHeader(attachment.storagePath) : {};
2793
2794
  const userMessage = visionFile && renderPlaceholder ? buildIndexingRenderMessage(attachment, renderPlaceholder, renderFrom) : windowedRead && windowPlaceholder ? buildIndexingWindowMessage(attachment, windowPlaceholder, false) : continuing ? buildIndexingContinueMessage(attachment) : buildIndexingUserMessage(
2794
2795
  attachment,
2795
2796
  parsedContent ? { inlineContent: parsedContent } : placeholder ? { inlineContentPlaceholder: placeholder } : pagedRead ? { pagedRead: true } : imageFile ? { imageFile } : void 0
@@ -2822,7 +2823,8 @@ Index the REMAINING windows - one record per row/item, looking at any page image
2822
2823
  method: "POST",
2823
2824
  headers: {
2824
2825
  "content-type": "application/json",
2825
- Authorization: "Bearer $CLIENT_SECRET"
2826
+ Authorization: "Bearer $CLIENT_SECRET",
2827
+ ...groupHeader
2826
2828
  },
2827
2829
  data: {
2828
2830
  model: resolvedModel2,
@@ -2872,7 +2874,8 @@ Index the REMAINING windows - one record per row/item, looking at any page image
2872
2874
  "content-type": "application/json",
2873
2875
  "x-api-key": "$CLIENT_SECRET",
2874
2876
  "anthropic-version": ANTHROPIC_VERSION,
2875
- "anthropic-beta": ANTHROPIC_BETA_HEADER
2877
+ "anthropic-beta": ANTHROPIC_BETA_HEADER,
2878
+ ...groupHeader
2876
2879
  },
2877
2880
  data: {
2878
2881
  model: resolvedModel,
@@ -3006,6 +3009,57 @@ Index the REMAINING windows - one record per row/item, looking at any page image
3006
3009
  return void 0;
3007
3010
  });
3008
3011
  }
3012
+ var FILE_GROUP_HEADER = "x-bq-file-group";
3013
+ function fileGroupHeader(groupKey) {
3014
+ return groupKey ? { [FILE_GROUP_HEADER]: sha1Hex(groupKey) } : {};
3015
+ }
3016
+ function sha1Hex(text) {
3017
+ const bytes = new TextEncoder().encode(String(text));
3018
+ const bitLen = bytes.length * 8;
3019
+ const words = new Uint32Array(((bytes.length + 8 >> 6) + 1) * 16);
3020
+ for (let i = 0; i < bytes.length; i++) words[i >> 2] |= bytes[i] << 24 - i % 4 * 8;
3021
+ words[bytes.length >> 2] |= 128 << 24 - bytes.length % 4 * 8;
3022
+ words[words.length - 1] = bitLen >>> 0;
3023
+ words[words.length - 2] = Math.floor(bitLen / 4294967296);
3024
+ let h0 = 1732584193, h1 = 4023233417, h2 = 2562383102, h3 = 271733878, h4 = 3285377520;
3025
+ const w = new Uint32Array(80);
3026
+ for (let off = 0; off < words.length; off += 16) {
3027
+ for (let t = 0; t < 16; t++) w[t] = words[off + t];
3028
+ for (let t = 16; t < 80; t++) {
3029
+ const x = w[t - 3] ^ w[t - 8] ^ w[t - 14] ^ w[t - 16];
3030
+ w[t] = x << 1 | x >>> 31;
3031
+ }
3032
+ let a = h0, b = h1, c = h2, d = h3, e = h4;
3033
+ for (let t = 0; t < 80; t++) {
3034
+ let f, k;
3035
+ if (t < 20) {
3036
+ f = b & c | ~b & d;
3037
+ k = 1518500249;
3038
+ } else if (t < 40) {
3039
+ f = b ^ c ^ d;
3040
+ k = 1859775393;
3041
+ } else if (t < 60) {
3042
+ f = b & c | b & d | c & d;
3043
+ k = 2400959708;
3044
+ } else {
3045
+ f = b ^ c ^ d;
3046
+ k = 3395469782;
3047
+ }
3048
+ const tmp = (a << 5 | a >>> 27) + f + e + k + w[t] >>> 0;
3049
+ e = d;
3050
+ d = c;
3051
+ c = b << 30 | b >>> 2;
3052
+ b = a;
3053
+ a = tmp;
3054
+ }
3055
+ h0 = h0 + a >>> 0;
3056
+ h1 = h1 + b >>> 0;
3057
+ h2 = h2 + c >>> 0;
3058
+ h3 = h3 + d >>> 0;
3059
+ h4 = h4 + e >>> 0;
3060
+ }
3061
+ return [h0, h1, h2, h3, h4].map((v) => (v >>> 0).toString(16).padStart(8, "0")).join("");
3062
+ }
3009
3063
  function bgIndexingQueueName(userId, service) {
3010
3064
  return (userId || service || "") + BG_INDEXING_QUEUE_SUFFIX;
3011
3065
  }
@@ -4454,6 +4508,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
4454
4508
  var error = null;
4455
4509
  var stopReason = null;
4456
4510
  var toolCalls = [];
4511
+ var argBuf = {};
4457
4512
  var malformedFrames = 0;
4458
4513
  var malformedToolJson = 0;
4459
4514
  var message = null;
@@ -4576,7 +4631,10 @@ Index the REMAINING windows - one record per row/item, looking at any page image
4576
4631
  type: block.type
4577
4632
  };
4578
4633
  if (typeof block.server_name === "string") call.serverName = block.server_name;
4634
+ if (typeof block.id === "string" && block.id) call.id = block.id;
4579
4635
  toolCalls.push(call);
4636
+ } else if (block && typeof block.type === "string") {
4637
+ markClaudeCallsDone(block);
4580
4638
  }
4581
4639
  return;
4582
4640
  }
@@ -4600,6 +4658,10 @@ Index the REMAINING windows - one record per row/item, looking at any page image
4600
4658
  var j = numberOr(ev.index, -1);
4601
4659
  var s = j >= 0 ? blocks.get(j) : void 0;
4602
4660
  if (s && s.sawJson) finishToolJson(s);
4661
+ if (s && s.block && s.block.input && typeof s.block.input === "object") {
4662
+ var sc = callAt(j);
4663
+ if (sc) sc.input = s.block.input;
4664
+ }
4603
4665
  return;
4604
4666
  }
4605
4667
  if (type === "message_delta") {
@@ -4660,6 +4722,34 @@ Index the REMAINING windows - one record per row/item, looking at any page image
4660
4722
  malformedToolJson++;
4661
4723
  }
4662
4724
  }
4725
+ function callAt(index) {
4726
+ for (var k = toolCalls.length - 1; k >= 0; k--) {
4727
+ if (toolCalls[k].index === index) return toolCalls[k];
4728
+ }
4729
+ return null;
4730
+ }
4731
+ function markClaudeCallsDone(block) {
4732
+ var t = block.type;
4733
+ if (/tool_result$/.test(t)) {
4734
+ var ref = typeof block.tool_use_id === "string" ? block.tool_use_id : "";
4735
+ for (var k = 0; k < toolCalls.length; k++) {
4736
+ if (ref && toolCalls[k].id === ref) toolCalls[k].done = true;
4737
+ }
4738
+ return;
4739
+ }
4740
+ if (t === "text" || t === "thinking" || t === "redacted_thinking") {
4741
+ for (var m = 0; m < toolCalls.length; m++) toolCalls[m].done = true;
4742
+ }
4743
+ }
4744
+ function parseArgs(args) {
4745
+ if (args && typeof args === "object") return args;
4746
+ if (typeof args !== "string" || !args) return void 0;
4747
+ try {
4748
+ return JSON.parse(args);
4749
+ } catch (e) {
4750
+ return void 0;
4751
+ }
4752
+ }
4663
4753
  function deltaBlockType(deltaType) {
4664
4754
  if (deltaType === "thinking_delta" || deltaType === "signature_delta") return "thinking";
4665
4755
  if (deltaType === "input_json_delta") return "tool_use";
@@ -4693,13 +4783,54 @@ Index the REMAINING windows - one record per row/item, looking at any page image
4693
4783
  if (type === "response.output_item.added") {
4694
4784
  var item = ev.item;
4695
4785
  if (item && typeof item.type === "string" && OPENAI_TOOL_ITEMS[item.type]) {
4696
- toolCalls.push({
4786
+ var oc = {
4697
4787
  index: numberOr(ev.output_index, toolCalls.length),
4698
4788
  // A built-in tool (web_search_call) has no name of its own, so the item
4699
4789
  // type is the only label there is and a row can still be drawn.
4700
4790
  name: typeof item.name === "string" && item.name ? item.name : item.type,
4701
4791
  type: item.type
4702
- });
4792
+ };
4793
+ if (typeof item.id === "string" && item.id) oc.id = item.id;
4794
+ var oa = parseArgs(item.arguments);
4795
+ if (oa !== void 0) oc.input = oa;
4796
+ toolCalls.push(oc);
4797
+ }
4798
+ return;
4799
+ }
4800
+ if (type === "response.mcp_call_arguments.delta" || type === "response.function_call_arguments.delta") {
4801
+ var gi = numberOr(ev.output_index, -1);
4802
+ var gc = callAt(gi);
4803
+ if (gc && gc.input === void 0 && typeof ev.delta === "string") {
4804
+ argBuf[gi] = (argBuf[gi] || "") + ev.delta;
4805
+ var gt = argBuf[gi].trim();
4806
+ if (gt.charAt(gt.length - 1) === "}") {
4807
+ var ga = parseArgs(gt);
4808
+ if (ga !== void 0) gc.input = ga;
4809
+ }
4810
+ }
4811
+ return;
4812
+ }
4813
+ if (type === "response.mcp_call_arguments.done" || type === "response.function_call_arguments.done") {
4814
+ var ac = callAt(numberOr(ev.output_index, -1));
4815
+ var aa = parseArgs(ev.arguments);
4816
+ if (ac && aa !== void 0) ac.input = aa;
4817
+ return;
4818
+ }
4819
+ if (type === "response.mcp_call.completed" || type === "response.mcp_call.failed") {
4820
+ var cc = callAt(numberOr(ev.output_index, -1));
4821
+ if (cc) cc.done = true;
4822
+ return;
4823
+ }
4824
+ if (type === "response.output_item.done") {
4825
+ var di = ev.item;
4826
+ if (di && typeof di.type === "string" && OPENAI_TOOL_ITEMS[di.type]) {
4827
+ var dc = callAt(numberOr(ev.output_index, -1));
4828
+ if (dc) {
4829
+ var da = parseArgs(di.arguments);
4830
+ if (da !== void 0) dc.input = da;
4831
+ else if (di.action && typeof di.action === "object" && dc.input === void 0) dc.input = di.action;
4832
+ dc.done = true;
4833
+ }
4703
4834
  }
4704
4835
  return;
4705
4836
  }
@@ -4850,7 +4981,12 @@ Index the REMAINING windows - one record per row/item, looking at any page image
4850
4981
  provider,
4851
4982
  text: currentText(),
4852
4983
  thinkingText: currentThinking(),
4853
- toolCalls: toolCalls.slice(),
4984
+ // Copied per call, not just per array: a call's input/done fill in after it
4985
+ // is first seen, and a snapshot already handed out must not change under
4986
+ // its reader.
4987
+ toolCalls: toolCalls.map(function(t) {
4988
+ return Object.assign({}, t);
4989
+ }),
4854
4990
  toolNames: toolCalls.map(function(t) {
4855
4991
  return t.name;
4856
4992
  }),
@@ -4904,6 +5040,190 @@ Index the REMAINING windows - one record per row/item, looking at any page image
4904
5040
  return target;
4905
5041
  }
4906
5042
 
5043
+ // src/engine/activity.ts
5044
+ var CHAT_ACTIVITY_ROTATE_MS = 4e3;
5045
+ var byItem = /* @__PURE__ */ new Map();
5046
+ var startByObj = /* @__PURE__ */ new WeakMap();
5047
+ var startById = /* @__PURE__ */ new Map();
5048
+ var MAX_IDS = 200;
5049
+ function remember(map, key, value) {
5050
+ if (map.has(key)) map.delete(key);
5051
+ map.set(key, value);
5052
+ if (map.size > MAX_IDS) {
5053
+ var oldest = map.keys().next();
5054
+ if (!oldest.done) map.delete(oldest.value);
5055
+ }
5056
+ }
5057
+ function stepOf(snap) {
5058
+ if (!snap) return { step: "thinking", count: 0 };
5059
+ var calls = Array.isArray(snap.toolCalls) ? snap.toolCalls : [];
5060
+ if (typeof snap.text === "string" && /\S/.test(snap.text)) return { step: "writing", count: calls.length };
5061
+ if (!calls.length) return { step: "thinking", count: 0 };
5062
+ var last = calls[calls.length - 1];
5063
+ if (last && !last.done) return { step: "tool", call: last, count: calls.length };
5064
+ return { step: "between", count: calls.length };
5065
+ }
5066
+ function noteChatActivity(serverItemId, snap, now) {
5067
+ if (!serverItemId) return;
5068
+ var t = Date.now();
5069
+ var s = stepOf(snap);
5070
+ var key = s.step + ":" + s.count;
5071
+ var prev = byItem.get(serverItemId);
5072
+ if (prev && prev.key === key) {
5073
+ if (s.call && s.call.input !== void 0 && prev.input === void 0) prev.input = s.call.input;
5074
+ return;
5075
+ }
5076
+ var act = { step: s.step, since: t, key };
5077
+ if (s.call) {
5078
+ act.tool = s.call.name;
5079
+ if (s.call.input !== void 0) act.input = s.call.input;
5080
+ }
5081
+ remember(byItem, serverItemId, act);
5082
+ }
5083
+ function chatActivityOf(msg) {
5084
+ var id = msg && typeof msg._serverItemId === "string" ? msg._serverItemId : "";
5085
+ return id && byItem.get(id) || null;
5086
+ }
5087
+ function turnStart(msg, now) {
5088
+ var ids = [];
5089
+ if (msg && typeof msg._serverItemId === "string" && msg._serverItemId) ids.push(msg._serverItemId);
5090
+ if (msg && typeof msg._localId === "string" && msg._localId) ids.push(msg._localId);
5091
+ var t;
5092
+ if (msg && typeof msg === "object") t = startByObj.get(msg);
5093
+ for (var i = 0; t === void 0 && i < ids.length; i++) t = startById.get(ids[i]);
5094
+ if (t === void 0) t = now;
5095
+ if (msg && typeof msg === "object") startByObj.set(msg, t);
5096
+ for (var j = 0; j < ids.length; j++) if (startById.get(ids[j]) !== t) remember(startById, ids[j], t);
5097
+ return t;
5098
+ }
5099
+ function langOf(lang) {
5100
+ return typeof lang === "string" && /^ko\b/i.test(lang) ? "ko" : "en";
5101
+ }
5102
+ function clip(v, max) {
5103
+ if (typeof v !== "string") return "";
5104
+ var s = v.replace(/\s+/g, " ").trim();
5105
+ if (s.length > max) s = s.slice(0, max - 1).trim() + "\u2026";
5106
+ return s;
5107
+ }
5108
+ function fileName(v) {
5109
+ if (typeof v !== "string" || !v) return "";
5110
+ var s = v.replace(/^(src::|db:)/, "");
5111
+ var parts = s.split("/").filter(function(p) {
5112
+ return !!p;
5113
+ });
5114
+ return clip(parts.length ? parts[parts.length - 1] : s, 40);
5115
+ }
5116
+ var T = {
5117
+ en: {
5118
+ 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"],
5119
+ 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"],
5120
+ writing: ["Writing the answer"],
5121
+ still: "Still working on it",
5122
+ working: "Working"
5123
+ },
5124
+ ko: {
5125
+ 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"],
5126
+ 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"],
5127
+ writing: ["\uB2F5\uBCC0\uC744 \uC791\uC131\uD558\uB294 \uC911"],
5128
+ still: "\uC544\uC9C1 \uC791\uC5C5 \uC911",
5129
+ working: "\uC791\uC5C5 \uC911"
5130
+ }
5131
+ };
5132
+ function toolLines(tool, i, lang) {
5133
+ var ko = lang === "ko";
5134
+ var inp = i && typeof i === "object" ? i : {};
5135
+ var q = clip(inp.query || inp.question, 40);
5136
+ var f = fileName(inp.path);
5137
+ var tbl = clip(inp.table_name, 30);
5138
+ switch (tool) {
5139
+ case "searchText":
5140
+ return ko ? [
5141
+ q ? f ? f + '\uC5D0\uC11C "' + q + '" \uCC3E\uB294 \uC911' : '\uD30C\uC77C\uC5D0\uC11C "' + q + '" \uCC3E\uB294 \uC911' : "\uD30C\uC77C\uC5D0\uC11C \uCC3E\uB294 \uC911",
5142
+ "\uBAA8\uB4E0 \uD398\uC774\uC9C0\uB97C \uD655\uC778\uD558\uB294 \uC911",
5143
+ "\uC544\uC9C1 \uCC3E\uB294 \uC911, \uD070 \uD504\uB85C\uC81D\uD2B8\uB294 \uC870\uAE08 \uB354 \uAC78\uB824\uC694",
5144
+ "\uACC4\uC18D \uCC3E\uB294 \uC911, \uAE30\uB2E4\uB824 \uC8FC\uC154\uC11C \uAC10\uC0AC\uD574\uC694"
5145
+ ] : [
5146
+ q ? f ? "Searching " + f + ' for "' + q + '"' : 'Searching your files for "' + q + '"' : "Searching your files",
5147
+ "Checking every page",
5148
+ "Still searching, big projects take a bit longer",
5149
+ "Still searching, thanks for waiting"
5150
+ ];
5151
+ case "readFileContent":
5152
+ return ko ? [
5153
+ f ? f + " \uC77D\uB294 \uC911" : "\uD30C\uC77C\uC744 \uC77D\uB294 \uC911",
5154
+ "\uD398\uC774\uC9C0\uB97C \uC0B4\uD3B4\uBCF4\uB294 \uC911",
5155
+ "\uC544\uC9C1 \uC77D\uB294 \uC911, \uAE34 \uD30C\uC77C\uC740 \uC870\uAE08 \uB354 \uAC78\uB824\uC694"
5156
+ ] : [
5157
+ f ? "Reading " + f : "Reading a file",
5158
+ "Going through the pages",
5159
+ "Still reading, long files take a bit longer"
5160
+ ];
5161
+ case "getFileOutline":
5162
+ 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];
5163
+ case "getRecords":
5164
+ return ko ? [
5165
+ tbl ? tbl + " \uD14C\uC774\uBE14\uC5D0\uC11C \uAE30\uB85D\uC744 \uCC3E\uB294 \uC911" : "\uAE30\uB85D\uC744 \uCC3E\uB294 \uC911",
5166
+ "\uD589\uC744 \uC0B4\uD3B4\uBCF4\uB294 \uC911",
5167
+ "\uC544\uC9C1 \uCC3E\uB294 \uC911, \uD070 \uD14C\uC774\uBE14\uC740 \uC870\uAE08 \uB354 \uAC78\uB824\uC694"
5168
+ ] : [
5169
+ tbl ? "Looking up records in " + tbl : "Looking up records",
5170
+ "Going through the rows",
5171
+ "Still looking, big tables take a bit longer"
5172
+ ];
5173
+ case "exportRecordsToFile":
5174
+ 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"];
5175
+ case "writeReport":
5176
+ 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"];
5177
+ case "getTables":
5178
+ 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];
5179
+ case "getTags":
5180
+ return ko ? ["\uD0DC\uADF8\uB97C \uD655\uC778\uD558\uB294 \uC911", T.ko.still] : ["Checking tags", T.en.still];
5181
+ case "getIndexes":
5182
+ return ko ? ["\uD14C\uC774\uBE14 \uD56D\uBAA9\uC744 \uD655\uC778\uD558\uB294 \uC911", T.ko.still] : ["Checking the table's fields", T.en.still];
5183
+ case "getUniqueId":
5184
+ return ko ? ["\uB808\uCF54\uB4DC ID\uB97C \uD655\uC778\uD558\uB294 \uC911", T.ko.still] : ["Checking record IDs", T.en.still];
5185
+ case "postRecords":
5186
+ return ko ? ["\uAE30\uB85D\uC744 \uC800\uC7A5\uD558\uB294 \uC911", T.ko.still] : ["Saving records", T.en.still];
5187
+ case "updateRecords":
5188
+ return ko ? ["\uAE30\uB85D\uC744 \uC218\uC815\uD558\uB294 \uC911", T.ko.still] : ["Updating records", T.en.still];
5189
+ case "deleteRecords":
5190
+ return ko ? ["\uAE30\uB85D\uC744 \uC0AD\uC81C\uD558\uB294 \uC911", T.ko.still] : ["Deleting records", T.en.still];
5191
+ case "getTemporaryUrl":
5192
+ 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];
5193
+ case "getToolResponsePage":
5194
+ 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];
5195
+ case "correctSearchLink":
5196
+ return ko ? ["\uD398\uC774\uC9C0 \uB9C1\uD06C\uB97C \uD655\uC778\uD558\uB294 \uC911", T.ko.still] : ["Checking the page link", T.en.still];
5197
+ case "getProjectInfos":
5198
+ return ko ? ["\uD504\uB85C\uC81D\uD2B8 \uC815\uBCF4\uB97C \uD655\uC778\uD558\uB294 \uC911", T.ko.still] : ["Checking the project details", T.en.still];
5199
+ case "getProfile":
5200
+ return ko ? ["\uACC4\uC815 \uC815\uBCF4\uB97C \uD655\uC778\uD558\uB294 \uC911", T.ko.still] : ["Checking your account", T.en.still];
5201
+ case "web_search":
5202
+ case "web_search_call":
5203
+ return ko ? ["\uC6F9\uC5D0\uC11C \uCC3E\uB294 \uC911", T.ko.still] : ["Searching the web", T.en.still];
5204
+ default:
5205
+ return ko ? [T.ko.working, T.ko.still] : [T.en.working, T.en.still];
5206
+ }
5207
+ }
5208
+ function pick(lines, elapsed, loopFrom) {
5209
+ var n = Math.floor(Math.max(0, elapsed) / CHAT_ACTIVITY_ROTATE_MS);
5210
+ if (n < lines.length) return lines[n];
5211
+ var from = Math.min(Math.max(0, loopFrom || 0), lines.length - 1);
5212
+ var span = lines.length - from;
5213
+ return lines[from + (n - lines.length) % span];
5214
+ }
5215
+ function chatActivityLine(msg, now, lang) {
5216
+ var t = typeof now === "number" ? now : Date.now();
5217
+ var L = langOf(lang);
5218
+ var start = turnStart(msg, t);
5219
+ var act = chatActivityOf(msg);
5220
+ if (!act || act.step === "thinking") return pick(T[L].thinking, t - start, 1);
5221
+ var elapsed = t - act.since;
5222
+ if (act.step === "writing") return pick(T[L].writing, elapsed);
5223
+ if (act.step === "between") return pick(T[L].between, elapsed);
5224
+ return pick(toolLines(act.tool || "", act.input, L), elapsed);
5225
+ }
5226
+
4907
5227
  // src/engine/history.ts
4908
5228
  function filterListByClearHorizon(list, clearedAt) {
4909
5229
  if (!clearedAt) return list;
@@ -5579,7 +5899,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
5579
5899
  restore(anchor);
5580
5900
  return result;
5581
5901
  }
5582
- function remember() {
5902
+ function remember2() {
5583
5903
  held = capture();
5584
5904
  }
5585
5905
  function hold() {
@@ -5625,7 +5945,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
5625
5945
  capture,
5626
5946
  restore,
5627
5947
  preserve,
5628
- remember,
5948
+ remember: remember2,
5629
5949
  hold,
5630
5950
  pinBottom,
5631
5951
  absorb,
@@ -6903,6 +7223,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
6903
7223
  _paintLiveStream(st) {
6904
7224
  if (st.ended) return;
6905
7225
  st.lastPaintAt = nowMs();
7226
+ noteChatActivity(st.id, st.parser.snapshot());
6906
7227
  if (this.getHistoryCacheKey() !== st.ownerKey) return;
6907
7228
  var idx = this._liveTargetIndex(st.id);
6908
7229
  if (idx === -1) {
@@ -11760,7 +12081,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
11760
12081
  * or waiting is left to the live queue check, which shows it as it settles; one already
11761
12082
  * in the chat is not read again. Never throws.
11762
12083
  */
11763
- loadRunPasses(storagePath, fileName) {
12084
+ loadRunPasses(storagePath, fileName2) {
11764
12085
  var self = this;
11765
12086
  var cfg = chatEngineConfig();
11766
12087
  var list = cfg.listIndexPasses, lookup = cfg.csrHistoryItemLookup;
@@ -11779,7 +12100,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
11779
12100
  p.error = void 0;
11780
12101
  this.host.notify();
11781
12102
  var svcId = id.projectId, owner = id.owner;
11782
- var name = fileName || storagePath.split("/").pop() || storagePath;
12103
+ var name = fileName2 || storagePath.split("/").pop() || storagePath;
11783
12104
  var idsReady = p.ids.length ? Promise.resolve(p.ids) : Promise.resolve(list(svcId, storagePath)).then(function(ids) {
11784
12105
  var clean = (Array.isArray(ids) ? ids : []).filter(function(x) {
11785
12106
  return typeof x === "string" && !!x;
@@ -11941,14 +12262,14 @@ Index the REMAINING windows - one record per row/item, looking at any page image
11941
12262
  });
11942
12263
  }
11943
12264
  /** The page progress to show for a file's row, or null (see _refreshPageProgress). */
11944
- pageProgressFor(storagePath, fileName) {
12265
+ pageProgressFor(storagePath, fileName2) {
11945
12266
  var map = this.state.indexPageProgress;
11946
12267
  if (!map) return null;
11947
12268
  var p = storagePath ? map[storagePath] : void 0;
11948
- if (!p && fileName) {
12269
+ if (!p && fileName2) {
11949
12270
  var hit = null;
11950
12271
  for (var k in map) {
11951
- if (k === fileName || k.slice(-(fileName.length + 1)) === "/" + fileName) {
12272
+ if (k === fileName2 || k.slice(-(fileName2.length + 1)) === "/" + fileName2) {
11952
12273
  if (hit) {
11953
12274
  hit = null;
11954
12275
  break;
@@ -13573,7 +13894,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
13573
13894
  (function() {
13574
13895
  var MCP_PROD = "https://mcp.skapi.com";
13575
13896
  var MCP_DEV = "https://mcp.broadwayinc.computer";
13576
- var BQ_VERSION = "1.21.13" ;
13897
+ var BQ_VERSION = "1.21.15" ;
13577
13898
  var ATTACHMENT_URL_EXPIRES_SECONDS = 600;
13578
13899
  var GOOGLE_AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth";
13579
13900
  var GOOGLE_TOKEN_URL = "https://oauth2.googleapis.com/token";
@@ -13780,33 +14101,57 @@ Index the REMAINING windows - one record per row/item, looking at any page image
13780
14101
  _anonIdMemo = lsGet(key) || minted;
13781
14102
  return _anonIdMemo;
13782
14103
  }
13783
- function loadTheme() {
14104
+ function storedTheme() {
13784
14105
  var stored = lsGet(SK.theme);
13785
- if (stored === "dark" || stored === "light") return stored;
13786
- if (S.opts.theme === "dark" || S.opts.theme === "light") return S.opts.theme;
14106
+ return stored === "dark" || stored === "light" ? stored : null;
14107
+ }
14108
+ function prefersDarkQuery() {
13787
14109
  try {
13788
- if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
13789
- return "dark";
13790
- }
14110
+ return window.matchMedia ? window.matchMedia("(prefers-color-scheme: dark)") : null;
13791
14111
  } catch (e) {
14112
+ return null;
13792
14113
  }
13793
- return "light";
13794
14114
  }
13795
- function applyTheme(theme) {
14115
+ function loadTheme() {
14116
+ var stored = storedTheme();
14117
+ if (stored) return stored;
14118
+ if (S.opts.theme === "dark" || S.opts.theme === "light") return S.opts.theme;
14119
+ var mq = prefersDarkQuery();
14120
+ return mq && mq.matches ? "dark" : "light";
14121
+ }
14122
+ var followingOsTheme = false;
14123
+ function followOsTheme() {
14124
+ if (followingOsTheme) return;
14125
+ var mq = prefersDarkQuery();
14126
+ if (!mq) return;
14127
+ followingOsTheme = true;
14128
+ var onChange = function(e) {
14129
+ if (storedTheme()) return;
14130
+ if (S.opts.theme === "dark" || S.opts.theme === "light") return;
14131
+ applyTheme(e.matches ? "dark" : "light");
14132
+ };
14133
+ if (mq.addEventListener) mq.addEventListener("change", onChange);
14134
+ else if (mq.addListener) mq.addListener(onChange);
14135
+ }
14136
+ function applyTheme(theme, save) {
13796
14137
  S.theme = theme === "dark" ? "dark" : "light";
13797
14138
  if (S.root) S.root.setAttribute("data-bq-theme", S.theme);
13798
14139
  var modals = document.querySelectorAll(".bq-modal-root");
13799
14140
  for (var i = 0; i < modals.length; i++) {
13800
14141
  modals[i].setAttribute("data-bq-theme", S.theme);
13801
14142
  }
13802
- lsSet(SK.theme, S.theme);
14143
+ if (save) lsSet(SK.theme, S.theme);
13803
14144
  var toggles = document.querySelectorAll("[data-bq-theme-toggle]");
13804
14145
  for (var j = 0; j < toggles.length; j++) {
13805
14146
  toggles[j].innerHTML = S.theme === "dark" ? THEME_ICON_SUN : THEME_ICON_MOON;
13806
14147
  }
14148
+ var radios = document.querySelectorAll('.bq-theme-radios input[name="bq-theme"]');
14149
+ for (var k = 0; k < radios.length; k++) {
14150
+ radios[k].checked = radios[k].value === S.theme;
14151
+ }
13807
14152
  }
13808
14153
  function toggleTheme() {
13809
- applyTheme(S.theme === "dark" ? "light" : "dark");
14154
+ applyTheme(S.theme === "dark" ? "light" : "dark", true);
13810
14155
  }
13811
14156
  function getProfile(refresh) {
13812
14157
  try {
@@ -15010,10 +15355,10 @@ Index the REMAINING windows - one record per row/item, looking at any page image
15010
15355
  function themeRow() {
15011
15356
  var current = S.theme === "dark" ? "dark" : "light";
15012
15357
  function themeRadio(value, label) {
15013
- var input = h("input", { type: "radio", name: "bq-theme" });
15358
+ var input = h("input", { type: "radio", name: "bq-theme", value });
15014
15359
  input.checked = value === current;
15015
15360
  input.addEventListener("change", function() {
15016
- if (input.checked) applyTheme(value);
15361
+ if (input.checked) applyTheme(value, true);
15017
15362
  });
15018
15363
  return h("label", { class: "bq-checkbox" }, input, h("span", { text: label }));
15019
15364
  }
@@ -17349,6 +17694,34 @@ Index the REMAINING windows - one record per row/item, looking at any page image
17349
17694
  if (CS.stickToBottom) chatScrollAnchor.pinBottom();
17350
17695
  if (nextH < prevH) ensureHistoryFillsViewport();
17351
17696
  }
17697
+ var activityLineEls = [];
17698
+ var activityTicker = null;
17699
+ function activityLang() {
17700
+ return typeof navigator !== "undefined" && navigator.language ? navigator.language : "";
17701
+ }
17702
+ function tickActivityLines() {
17703
+ var now = Date.now();
17704
+ var keep = [];
17705
+ for (var i = 0; i < activityLineEls.length; i++) {
17706
+ var el = activityLineEls[i];
17707
+ if (!el.isConnected) continue;
17708
+ keep.push(el);
17709
+ var t = chatActivityLine(el._bqMsg, now, activityLang());
17710
+ if (el.textContent !== t) el.textContent = t;
17711
+ }
17712
+ activityLineEls = keep;
17713
+ if (!keep.length && activityTicker) {
17714
+ clearInterval(activityTicker);
17715
+ activityTicker = null;
17716
+ }
17717
+ }
17718
+ function buildActivityText(msg) {
17719
+ var text = h("span", { class: "bq-activity-text", text: chatActivityLine(msg, Date.now(), activityLang()) });
17720
+ text._bqMsg = msg;
17721
+ activityLineEls.push(text);
17722
+ if (!activityTicker) activityTicker = setInterval(tickActivityLines, 1e3);
17723
+ return text;
17724
+ }
17352
17725
  function buildMessageEl(msg, idx) {
17353
17726
  var cls = ["bq-message"];
17354
17727
  cls.push(msg.role === "user" ? "is-user" : "is-assistant");
@@ -17359,7 +17732,12 @@ Index the REMAINING windows - one record per row/item, looking at any page image
17359
17732
  if (msg._dimSending || msg._cancelling) cls.push("is-sending-to-server");
17360
17733
  var bubble;
17361
17734
  if (msg.isPending && !msg._streaming || streamRecoveryPhase(msg) === "active") {
17362
- bubble = h("div", { class: "bq-bubble" }, h("span", { class: "bq-loader" }));
17735
+ bubble = h(
17736
+ "div",
17737
+ { class: "bq-bubble" },
17738
+ msg.role === "assistant" && !msg.isBackgroundTask && !streamRecoveryPhase(msg) ? buildActivityText(msg) : null,
17739
+ h("span", { class: "bq-loader" })
17740
+ );
17363
17741
  if (msg.role === "assistant" && !msg.isBackgroundTask && !streamRecoveryPhase(msg)) {
17364
17742
  var waitDisabled = !msg._serverItemId || msg._cancelling;
17365
17743
  var stopWaitBtn = h("button", {
@@ -18802,7 +19180,10 @@ Index the REMAINING windows - one record per row/item, looking at any page image
18802
19180
  if (!mountEl) throw new Error("BunnyQuery.init: mount element not found: " + target);
18803
19181
  S.skapi = skapi;
18804
19182
  S.opts = Object.assign({
18805
- theme: "light",
19183
+ // null follows the visitor's OS colour mode; "light" / "dark" fixes
19184
+ // the starting mode. Either way a mode the visitor picks in the
19185
+ // widget is saved and wins on later visits.
19186
+ theme: null,
18806
19187
  // Header title. null keeps "BunnyQuery \u00b7 <project name>"; a string
18807
19188
  // replaces the whole line, "" hides it. See brandTitleText.
18808
19189
  title: null,
@@ -18896,6 +19277,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
18896
19277
  S.root.style.setProperty("--bq-bubble-face", 'url("' + S.opts.bubbleFace.replace(/"/g, '\\"') + '")');
18897
19278
  }
18898
19279
  applyTheme(loadTheme());
19280
+ followOsTheme();
18899
19281
  S.booted = true;
18900
19282
  console.log("[bunnyquery] v" + BQ_VERSION);
18901
19283
  var canStream = skapiSupportsStreaming(S.skapi);
@@ -19056,7 +19438,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
19056
19438
  // Can be called before or after init(); also settable via init opts.attachmentParsers.
19057
19439
  registerAttachmentParser,
19058
19440
  setTheme: function(t) {
19059
- applyTheme(t);
19441
+ applyTheme(t, true);
19060
19442
  },
19061
19443
  toggleTheme,
19062
19444
  logout,