bunnyquery 1.21.14 → 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/README.md CHANGED
@@ -108,7 +108,6 @@ call `BunnyQuery.init()`:
108
108
 
109
109
  // 2. Mount BunnyQuery into the container
110
110
  BunnyQuery.init(skapi, "chatbox", {
111
- theme: "light",
112
111
  signup: true,
113
112
  });
114
113
  </script>
@@ -153,7 +152,7 @@ Mounts the widget. Returns the `BunnyQuery` object.
153
152
 
154
153
  | Option | Type | Default | Description |
155
154
  | ------------------------ | --------- | -------- | -------------------------------------------------------------------------------------------- |
156
- | `theme` | `string` | `"light"`| Initial theme, `"light"` or `"dark"`. Overridden by a remembered choice or OS preference. |
155
+ | `theme` | `string` | `null` | Starting colour mode: `null` follows the visitor's OS setting (and changes with it), `"light"` or `"dark"` fixes it. A mode the visitor picks in the widget is saved and wins on later visits. |
157
156
  | `title` | `string` | `null` | Header title text. `null` keeps `"BunnyQuery · <project name>"`; any string replaces the whole line, and `""` leaves the header title empty. It is one element, so it ellipsizes as a unit. |
158
157
  | `inputPlaceholder` | `string` | `null` | Placeholder in the chat composer. `null` keeps `"Ask anything about: <project name>"`; `""` shows no placeholder. |
159
158
  | `showLogin` | `boolean` | `true` | Whether an **anonymous** visitor is offered a `Login` button in the chat header. Signed-in users are unaffected: they get the settings gear in that slot either way. Set `false` for an embed that handles its own auth, or that does not want visitors making accounts. |
@@ -201,7 +200,7 @@ The `BunnyQuery` global also exposes:
201
200
 
202
201
  | Method | Description |
203
202
  | ---------------------------------- | ----------------------------------------------------------------------------------- |
204
- | `setTheme(theme)` | Apply `"light"` or `"dark"` and persist it. |
203
+ | `setTheme(theme)` | Apply `"light"` or `"dark"` and save it, like the visitor picking it. |
205
204
  | `toggleTheme()` | Switch between light and dark. |
206
205
  | `logout()` | Sign the current user out and return to the login view. |
207
206
  | `registerAttachmentParser(parser)` | Register a client-side attachment parser. May be called before or after `init()`. See [Attachment parser plugins](#attachment-parser-plugins). |
@@ -521,7 +520,14 @@ To customize colors, override the variables in your own stylesheet **after**
521
520
  }
522
521
  ```
523
522
 
524
- The active theme is saved to `localStorage`, so a returning user keeps their choice.
523
+ Until the visitor picks a mode, the widget follows their OS colour mode (or the
524
+ `theme` option, when the host sets one). A mode picked with the toggle or in
525
+ Settings is saved to `localStorage`, so a returning user keeps their choice.
526
+
527
+ The default colours are the bunnyquery.com dashboard chat's: in dark mode the
528
+ widget is a near-black card (`--bq-paper` `#161618`), replies sit one step
529
+ lighter (`--bq-bubble` `#1f1f23`) and text boxes are recessed (`--bq-field`
530
+ `#101012`, edged with `--bq-input-line`).
525
531
 
526
532
  ## Importing the chat engine
527
533
 
package/bunnyquery.css CHANGED
@@ -14,29 +14,38 @@
14
14
  * ==========================================================================*/
15
15
 
16
16
  /* ---- Tokens: light (default) ---------------------------------------------*/
17
+ /* Same values as the BunnyQuery dashboard chat (web-bunnyquery bq-tokens.less +
18
+ agent.vue), so an embedded chat and the dashboard's chat look the same. The
19
+ widget is one card, so --bq-paper here is the dashboard's chat card colour
20
+ (its --bq-surface), not its page canvas. --bq-bubble is the reply bubble one
21
+ step above it (the dashboard's --bq-chat-bubble), --bq-field the text boxes. */
17
22
  .bq-agent,
18
23
  .bq-modal-root {
19
24
  --bq-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
20
- --bq-ink: #111;
21
- --bq-paper: #fff;
22
- --bq-muted: #666;
23
- --bq-line: #c8c8c8;
24
- --bq-hover-bg: #ebebeb;
25
+ --bq-ink: #111113;
26
+ --bq-paper: #ffffff;
27
+ --bq-bubble: #ffffff;
28
+ --bq-field: #ffffff;
29
+ --bq-muted: #5e5e66;
30
+ --bq-line: #d6d6db;
31
+ /* control edges (text boxes); dividers stay on --bq-line */
32
+ --bq-input-line: #8a8a93;
33
+ --bq-hover-bg: #ececef;
25
34
  --bq-main: #c2185b;
26
35
  --bq-light-main: #f06292;
27
- --bq-danger: #c44;
28
- --bq-danger-bg: #fff5f5;
29
- --bq-main-bg: #fff8fa;
30
- --bq-success: #2a7d29;
31
- --bq-success-bg: #eef9f0;
32
- --bq-success-border: #b8dcbc;
33
- --bq-warning: #8a6d00;
34
- --bq-warning-bg: #fff8e1;
35
- --bq-warning-border: #e2a300;
36
+ --bq-danger: #c03b3b;
37
+ --bq-danger-bg: #fdf1f1;
38
+ --bq-main-bg: #fcf0f5;
39
+ --bq-success: #25722a;
40
+ --bq-success-bg: #edf8ef;
41
+ --bq-success-border: #a9d4ae;
42
+ --bq-warning: #7a5f00;
43
+ --bq-warning-bg: #fff7de;
44
+ --bq-warning-border: #d99a00;
36
45
  --bq-info: #1a5bb5;
37
46
  --bq-info-bg: #e8f0fb;
38
- --bq-info-border: #3c94ff;
39
- --bq-placeholder: #aaaaaa;
47
+ --bq-info-border: #6aa5f0;
48
+ --bq-placeholder: #909098;
40
49
  /* hard offset shadow for bubbles; swapped for a light edge in dark */
41
50
  --bq-shadow: rgba(0, 0, 0, 0.12);
42
51
  --bq-code-bg: #1e1e1e;
@@ -45,31 +54,35 @@
45
54
  }
46
55
 
47
56
  /* ---- Tokens: dark --------------------------------------------------------*/
57
+ /* Not #000: the dashboard's dark chat card (#161618), replies one step lighter
58
+ (#1f1f23) and text boxes recessed below the card (#101012). */
48
59
  .bq-agent[data-bq-theme="dark"],
49
60
  .bq-modal-root[data-bq-theme="dark"] {
50
- --bq-ink: #ebebeb;
51
- --bq-paper: #000;
52
- --bq-muted: #a0a0a0;
53
- /* was #3d3d3d — brighter edges, matching the admin's dark tokens */
54
- --bq-line: #484848;
55
- --bq-hover-bg: #252525;
56
- --bq-main: #f06292;
57
- --bq-light-main: #f48fb1;
58
- --bq-danger: #ef5350;
59
- --bq-danger-bg: #2d1616;
60
- --bq-main-bg: #2b1520;
61
- --bq-success: #6abf66;
62
- --bq-success-bg: #192e1e;
63
- --bq-success-border: #4caf50;
64
- --bq-warning: #ffca28;
65
- --bq-warning-bg: #2d2516;
66
- --bq-warning-border: #f9a825;
67
- --bq-info: #64b5f6;
68
- --bq-info-bg: #162230;
69
- --bq-info-border: #42a5f5;
70
- --bq-placeholder: #787878;
71
- /* light edge — a black hard shadow is invisible on the dark paper */
72
- --bq-shadow: rgba(255, 255, 255, 0.16);
61
+ --bq-ink: #ececef;
62
+ --bq-paper: #161618;
63
+ --bq-bubble: #1f1f23;
64
+ --bq-field: #101012;
65
+ --bq-muted: #a9a9b2;
66
+ --bq-line: #333338;
67
+ --bq-input-line: #74747e;
68
+ --bq-hover-bg: #26262a;
69
+ --bq-main: #f2709c;
70
+ --bq-light-main: #f7a1bf;
71
+ --bq-danger: #f0706d;
72
+ --bq-danger-bg: #2a1617;
73
+ --bq-main-bg: #2a1620;
74
+ --bq-success: #6cc068;
75
+ --bq-success-bg: #142318;
76
+ --bq-success-border: #3f8a45;
77
+ --bq-warning: #f2c14e;
78
+ --bq-warning-bg: #29220f;
79
+ --bq-warning-border: #b8892a;
80
+ --bq-info: #6cb4f5;
81
+ --bq-info-bg: #131d29;
82
+ --bq-info-border: #3a7cc4;
83
+ --bq-placeholder: #6c6c75;
84
+ /* light edge: a black hard shadow is invisible on the dark card */
85
+ --bq-shadow: rgba(255, 255, 255, 0.11);
73
86
  --bq-icon-invert: 1;
74
87
  }
75
88
 
@@ -330,8 +343,8 @@
330
343
  .bq-input-text {
331
344
  width: 100%;
332
345
  padding: 0.7rem 0.8rem;
333
- border: 1px solid var(--bq-line);
334
- background: var(--bq-paper);
346
+ border: 1px solid var(--bq-input-line);
347
+ background: var(--bq-field);
335
348
  color: var(--bq-ink);
336
349
  font-family: var(--bq-mono);
337
350
  font-size: 0.9rem;
@@ -840,8 +853,8 @@
840
853
  box-sizing: border-box;
841
854
  overflow-y: hidden; /* autoGrowInput switches to auto only at the max-height cap */
842
855
  resize: none;
843
- border: 1px solid var(--bq-line);
844
- background: var(--bq-paper);
856
+ border: 1px solid var(--bq-input-line);
857
+ background: var(--bq-field);
845
858
  color: var(--bq-ink);
846
859
  padding: 0.7rem 0.7rem 0.7rem var(--chat-control-height);
847
860
  font-family: var(--bq-mono);
@@ -1029,7 +1042,7 @@
1029
1042
  max-width: 100%;
1030
1043
  max-height: 90vh;
1031
1044
  overflow-y: auto;
1032
- background: var(--bq-paper);
1045
+ background: var(--bq-bubble);
1033
1046
  color: var(--bq-ink);
1034
1047
  border: 1px solid var(--bq-line);
1035
1048
  box-shadow: 4px 4px rgba(0, 0, 0, 0.2);
@@ -1151,6 +1164,20 @@
1151
1164
  filter: invert(var(--bq-icon-invert));
1152
1165
  }
1153
1166
 
1167
+ /* ---- Reply bubbles one step above the conversation -----------------------*/
1168
+ /* chat.css paints replies on --bq-paper, the conversation colour, so in dark
1169
+ mode a reply was only a hairline on the card. Same rule as the dashboard
1170
+ (agent.vue): replies on --bq-bubble; the user, error, cancelled and retried
1171
+ variants keep their own chat.css colours, and the two "plain" notes stay on
1172
+ the conversation colour. */
1173
+ .bq-messages .bq-bubble {
1174
+ background: var(--bq-bubble);
1175
+ }
1176
+ .bq-messages .bq-message.is-error.is-retried .bq-bubble,
1177
+ .bq-messages .bq-message.bq-index-pass.is-user:not(.is-cancelled):not(.is-pending-older) .bq-bubble {
1178
+ background: var(--bq-paper);
1179
+ }
1180
+
1154
1181
  /**
1155
1182
  * @skapi/chat-engine — shared chat-display styles.
1156
1183
  *
package/bunnyquery.js CHANGED
@@ -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
  }
@@ -13840,7 +13894,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
13840
13894
  (function() {
13841
13895
  var MCP_PROD = "https://mcp.skapi.com";
13842
13896
  var MCP_DEV = "https://mcp.broadwayinc.computer";
13843
- var BQ_VERSION = "1.21.14" ;
13897
+ var BQ_VERSION = "1.21.15" ;
13844
13898
  var ATTACHMENT_URL_EXPIRES_SECONDS = 600;
13845
13899
  var GOOGLE_AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth";
13846
13900
  var GOOGLE_TOKEN_URL = "https://oauth2.googleapis.com/token";
@@ -14047,33 +14101,57 @@ Index the REMAINING windows - one record per row/item, looking at any page image
14047
14101
  _anonIdMemo = lsGet(key) || minted;
14048
14102
  return _anonIdMemo;
14049
14103
  }
14050
- function loadTheme() {
14104
+ function storedTheme() {
14051
14105
  var stored = lsGet(SK.theme);
14052
- if (stored === "dark" || stored === "light") return stored;
14053
- 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() {
14054
14109
  try {
14055
- if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
14056
- return "dark";
14057
- }
14110
+ return window.matchMedia ? window.matchMedia("(prefers-color-scheme: dark)") : null;
14058
14111
  } catch (e) {
14112
+ return null;
14059
14113
  }
14060
- return "light";
14061
14114
  }
14062
- 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) {
14063
14137
  S.theme = theme === "dark" ? "dark" : "light";
14064
14138
  if (S.root) S.root.setAttribute("data-bq-theme", S.theme);
14065
14139
  var modals = document.querySelectorAll(".bq-modal-root");
14066
14140
  for (var i = 0; i < modals.length; i++) {
14067
14141
  modals[i].setAttribute("data-bq-theme", S.theme);
14068
14142
  }
14069
- lsSet(SK.theme, S.theme);
14143
+ if (save) lsSet(SK.theme, S.theme);
14070
14144
  var toggles = document.querySelectorAll("[data-bq-theme-toggle]");
14071
14145
  for (var j = 0; j < toggles.length; j++) {
14072
14146
  toggles[j].innerHTML = S.theme === "dark" ? THEME_ICON_SUN : THEME_ICON_MOON;
14073
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
+ }
14074
14152
  }
14075
14153
  function toggleTheme() {
14076
- applyTheme(S.theme === "dark" ? "light" : "dark");
14154
+ applyTheme(S.theme === "dark" ? "light" : "dark", true);
14077
14155
  }
14078
14156
  function getProfile(refresh) {
14079
14157
  try {
@@ -15277,10 +15355,10 @@ Index the REMAINING windows - one record per row/item, looking at any page image
15277
15355
  function themeRow() {
15278
15356
  var current = S.theme === "dark" ? "dark" : "light";
15279
15357
  function themeRadio(value, label) {
15280
- var input = h("input", { type: "radio", name: "bq-theme" });
15358
+ var input = h("input", { type: "radio", name: "bq-theme", value });
15281
15359
  input.checked = value === current;
15282
15360
  input.addEventListener("change", function() {
15283
- if (input.checked) applyTheme(value);
15361
+ if (input.checked) applyTheme(value, true);
15284
15362
  });
15285
15363
  return h("label", { class: "bq-checkbox" }, input, h("span", { text: label }));
15286
15364
  }
@@ -19102,7 +19180,10 @@ Index the REMAINING windows - one record per row/item, looking at any page image
19102
19180
  if (!mountEl) throw new Error("BunnyQuery.init: mount element not found: " + target);
19103
19181
  S.skapi = skapi;
19104
19182
  S.opts = Object.assign({
19105
- 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,
19106
19187
  // Header title. null keeps "BunnyQuery \u00b7 <project name>"; a string
19107
19188
  // replaces the whole line, "" hides it. See brandTitleText.
19108
19189
  title: null,
@@ -19196,6 +19277,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
19196
19277
  S.root.style.setProperty("--bq-bubble-face", 'url("' + S.opts.bubbleFace.replace(/"/g, '\\"') + '")');
19197
19278
  }
19198
19279
  applyTheme(loadTheme());
19280
+ followOsTheme();
19199
19281
  S.booted = true;
19200
19282
  console.log("[bunnyquery] v" + BQ_VERSION);
19201
19283
  var canStream = skapiSupportsStreaming(S.skapi);
@@ -19356,7 +19438,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
19356
19438
  // Can be called before or after init(); also settable via init opts.attachmentParsers.
19357
19439
  registerAttachmentParser,
19358
19440
  setTheme: function(t) {
19359
- applyTheme(t);
19441
+ applyTheme(t, true);
19360
19442
  },
19361
19443
  toggleTheme,
19362
19444
  logout,
package/dist/engine.cjs CHANGED
@@ -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
  }
@@ -14238,6 +14292,7 @@ exports.EXPIRED_ATTACHMENT_URL_HOST = EXPIRED_ATTACHMENT_URL_HOST;
14238
14292
  exports.EXPIRED_ATTACHMENT_URL_ORIGIN = EXPIRED_ATTACHMENT_URL_ORIGIN;
14239
14293
  exports.EXPIRED_LINK_REFRESH_EXPIRES_SECONDS = EXPIRED_LINK_REFRESH_EXPIRES_SECONDS;
14240
14294
  exports.EXT_CONTENT_TYPES = EXT_CONTENT_TYPES;
14295
+ exports.FILE_GROUP_HEADER = FILE_GROUP_HEADER;
14241
14296
  exports.HISTORY_BUDGET_RATIO = HISTORY_BUDGET_RATIO;
14242
14297
  exports.HISTORY_FILL_SLACK_PX = HISTORY_FILL_SLACK_PX;
14243
14298
  exports.HISTORY_TOKEN_BUDGET = HISTORY_TOKEN_BUDGET;
@@ -14372,6 +14427,7 @@ exports.extractOpenAIText = extractOpenAIText;
14372
14427
  exports.extractRemotePathFromAttachmentHref = extractRemotePathFromAttachmentHref;
14373
14428
  exports.extractRetrievalNote = extractRetrievalNote;
14374
14429
  exports.fetchLiveIndexingKeys = fetchLiveIndexingKeys;
14430
+ exports.fileGroupHeader = fileGroupHeader;
14375
14431
  exports.fileNameOf = fileNameOf;
14376
14432
  exports.fillHistoryViewport = fillHistoryViewport;
14377
14433
  exports.filterListByClearHorizon = filterListByClearHorizon;
@@ -14512,6 +14568,7 @@ exports.safeDecodeURIComponent = safeDecodeURIComponent;
14512
14568
  exports.sanitizeAttachmentLinksForHistory = sanitizeAttachmentLinksForHistory;
14513
14569
  exports.setProjectContextWindow = setProjectContextWindow;
14514
14570
  exports.setProjectSettings = setProjectSettings;
14571
+ exports.sha1Hex = sha1Hex;
14515
14572
  exports.shareIdenticalFilesFrom = shareIdenticalFilesFrom;
14516
14573
  exports.shouldRescueInFlightMessage = shouldRescueInFlightMessage;
14517
14574
  exports.sideEffectDone = sideEffectDone;