bunnyquery 1.5.0 → 1.5.1

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
@@ -473,7 +473,7 @@ ${options.inlineContentPlaceholder}
473
473
  }
474
474
  function stripFileBlocksFromHistory(content) {
475
475
  if (!content) return content;
476
- return content.replace(/```([\w.-]+\.[a-zA-Z0-9]+)\n[\s\S]*?```/g, "[file previously attached: $1]");
476
+ return content.replace(/```([^\n`]+?\.[^\s.`]+)\n[\s\S]*?```/g, "[file previously attached: $1]");
477
477
  }
478
478
  function buildBoundedChatMessages(options) {
479
479
  var contextWindow = getContextWindow(options.platform, options.model);
@@ -1530,7 +1530,7 @@ ${options.inlineContentPlaceholder}
1530
1530
  var MIN_STEP = 1;
1531
1531
  var MAX_FRAME_MS = 1e3;
1532
1532
  var regions = [], m;
1533
- var fenceRegex = /```[\w.-]+\.[a-zA-Z0-9]+\n[\s\S]*?```/g;
1533
+ var fenceRegex = /```[^\n`]+?\.[^\s.`]+\n[\s\S]*?```/g;
1534
1534
  while ((m = fenceRegex.exec(fullText)) !== null) regions.push({ start: m.index, end: m.index + m[0].length });
1535
1535
  var linkRegex = createInlineLinkRegex();
1536
1536
  while ((m = linkRegex.exec(fullText)) !== null) regions.push({ start: m.index, end: m.index + m[0].length });
@@ -2015,6 +2015,7 @@ ${options.inlineContentPlaceholder}
2015
2015
  members.forEach(function(member, idx) {
2016
2016
  chain = chain.then(function() {
2017
2017
  var hadExists = false;
2018
+ var skipped = false;
2018
2019
  var onProg = function(p) {
2019
2020
  if (p && p.total) {
2020
2021
  att.progress = Math.floor((idx + p.loaded / p.total) / total * 100);
@@ -2039,11 +2040,17 @@ ${options.inlineContentPlaceholder}
2039
2040
  if (!isExists) throw err;
2040
2041
  return self.host.promptOverwrite(member.file.name).then(function(choice) {
2041
2042
  if (choice === "overwrite") return doMemberUpload(false);
2043
+ if (choice === "skip") {
2044
+ skipped = true;
2045
+ return;
2046
+ }
2042
2047
  hadExists = true;
2043
2048
  });
2044
2049
  }).then(function() {
2050
+ if (skipped) return;
2045
2051
  return self.host.getTemporaryUrl(member.storagePath);
2046
2052
  }).then(function(url) {
2053
+ if (skipped) return;
2047
2054
  urls.push({ name: member.relPath, url, storagePath: member.storagePath });
2048
2055
  if (att.kind !== "folder") {
2049
2056
  att.uploadedUrl = url;
@@ -2176,7 +2183,7 @@ ${options.inlineContentPlaceholder}
2176
2183
  (function() {
2177
2184
  var MCP_PROD = "https://mcp.broadwayinc.computer";
2178
2185
  var MCP_DEV = "https://mcp-dev.broadwayinc.computer";
2179
- var BQ_VERSION = "1.5.0" ;
2186
+ var BQ_VERSION = "1.5.1" ;
2180
2187
  var ATTACHMENT_URL_EXPIRES_SECONDS = 600;
2181
2188
  var GOOGLE_AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth";
2182
2189
  var GOOGLE_TOKEN_URL = "https://oauth2.googleapis.com/token";
@@ -4018,13 +4025,18 @@ ${options.inlineContentPlaceholder}
4018
4025
  var existing = fileBlobCache.get(key);
4019
4026
  if (existing) return existing;
4020
4027
  var contentType = mimeGetType(filename) || "text/plain";
4021
- var href = URL.createObjectURL(new Blob([body], { type: contentType }));
4028
+ var ext = (String(filename || "").split(".").pop() || "").toLowerCase();
4029
+ var isText = /^text\//i.test(contentType) || /application\/(json|xml|csv|yaml|x-yaml|javascript)/i.test(contentType);
4030
+ var needsBom = ext === "csv" || ext === "tsv" || ext === "tab";
4031
+ var type = isText ? contentType + "; charset=utf-8" : contentType;
4032
+ var data = needsBom ? "\uFEFF" + body : body;
4033
+ var href = URL.createObjectURL(new Blob([data], { type }));
4022
4034
  fileBlobCache.set(key, href);
4023
4035
  return href;
4024
4036
  }
4025
4037
  function fileToAnchorHtml(filename, href) {
4026
4038
  var text = "\u2197 " + filename;
4027
- return '<a class="bq-file-download" href="' + escapeHtml(href) + '" target="_blank" rel="noopener noreferrer">' + escapeHtml(text) + "</a>";
4039
+ return '<a class="bq-file-download" href="' + escapeHtml(href) + '" download="' + escapeHtml(filename) + '" target="_blank" rel="noopener noreferrer">' + escapeHtml(text) + "</a>";
4028
4040
  }
4029
4041
  function linkToAnchorHtml(link) {
4030
4042
  var refreshing = !!refreshingLinkMap[link.expiredHref || link.href];
@@ -4095,13 +4107,13 @@ ${options.inlineContentPlaceholder}
4095
4107
  return PH(idx);
4096
4108
  };
4097
4109
  var working = String(content == null ? "" : content).replace(
4098
- /```([\w.-]+\.[a-zA-Z0-9]+)\n([\s\S]*?)```/g,
4110
+ /```([^\n`]+?\.[^\s.`]+)\n([\s\S]*?)```/g,
4099
4111
  function(_full, filename, body) {
4100
4112
  return pushPlaceholder(fileToAnchorHtml(filename, getOrCreateFileHref(filename, body)));
4101
4113
  }
4102
4114
  );
4103
4115
  if (CS.typing) {
4104
- var openFence = working.match(/```([\w.-]+\.[a-zA-Z0-9]+)\n?/);
4116
+ var openFence = working.match(/```([^\n`]+?\.[^\s.`]+)\n?/);
4105
4117
  if (openFence && typeof openFence.index === "number") {
4106
4118
  working = working.slice(0, openFence.index) + "\n[generating " + openFence[1] + "\u2026]";
4107
4119
  }
@@ -5107,12 +5119,15 @@ ${options.inlineContentPlaceholder}
5107
5119
  h(
5108
5120
  "p",
5109
5121
  { class: "bq-modal-desc" },
5110
- "A file named \u201C" + filename + "\u201D already exists. Keep the existing file and just reindex it, or overwrite it completely?"
5122
+ "A file named \u201C" + filename + "\u201D already exists. Skip it, keep the existing file and just reindex it, or overwrite it completely?"
5111
5123
  ),
5112
5124
  applyLabel,
5113
5125
  h(
5114
5126
  "div",
5115
5127
  { class: "bq-modal-btns" },
5128
+ h("button", { class: "btn btn--outline", type: "button", onclick: function() {
5129
+ chooseOverwrite("skip");
5130
+ } }, "Skip"),
5116
5131
  h("button", { class: "btn btn--outline", type: "button", onclick: function() {
5117
5132
  chooseOverwrite("reindex");
5118
5133
  } }, "Reindex only"),
package/dist/engine.cjs CHANGED
@@ -480,7 +480,7 @@ function getContextWindow(platform, model) {
480
480
  }
481
481
  function stripFileBlocksFromHistory(content) {
482
482
  if (!content) return content;
483
- return content.replace(/```([\w.-]+\.[a-zA-Z0-9]+)\n[\s\S]*?```/g, "[file previously attached: $1]");
483
+ return content.replace(/```([^\n`]+?\.[^\s.`]+)\n[\s\S]*?```/g, "[file previously attached: $1]");
484
484
  }
485
485
  function buildBoundedChatMessages(options) {
486
486
  var contextWindow = getContextWindow(options.platform, options.model);
@@ -1564,7 +1564,7 @@ var ChatSession = class {
1564
1564
  var MIN_STEP = 1;
1565
1565
  var MAX_FRAME_MS = 1e3;
1566
1566
  var regions = [], m;
1567
- var fenceRegex = /```[\w.-]+\.[a-zA-Z0-9]+\n[\s\S]*?```/g;
1567
+ var fenceRegex = /```[^\n`]+?\.[^\s.`]+\n[\s\S]*?```/g;
1568
1568
  while ((m = fenceRegex.exec(fullText)) !== null) regions.push({ start: m.index, end: m.index + m[0].length });
1569
1569
  var linkRegex = createInlineLinkRegex();
1570
1570
  while ((m = linkRegex.exec(fullText)) !== null) regions.push({ start: m.index, end: m.index + m[0].length });
@@ -2049,6 +2049,7 @@ var ChatSession = class {
2049
2049
  members.forEach(function(member, idx) {
2050
2050
  chain = chain.then(function() {
2051
2051
  var hadExists = false;
2052
+ var skipped = false;
2052
2053
  var onProg = function(p) {
2053
2054
  if (p && p.total) {
2054
2055
  att.progress = Math.floor((idx + p.loaded / p.total) / total * 100);
@@ -2073,11 +2074,17 @@ var ChatSession = class {
2073
2074
  if (!isExists) throw err;
2074
2075
  return self.host.promptOverwrite(member.file.name).then(function(choice) {
2075
2076
  if (choice === "overwrite") return doMemberUpload(false);
2077
+ if (choice === "skip") {
2078
+ skipped = true;
2079
+ return;
2080
+ }
2076
2081
  hadExists = true;
2077
2082
  });
2078
2083
  }).then(function() {
2084
+ if (skipped) return;
2079
2085
  return self.host.getTemporaryUrl(member.storagePath);
2080
2086
  }).then(function(url) {
2087
+ if (skipped) return;
2081
2088
  urls.push({ name: member.relPath, url, storagePath: member.storagePath });
2082
2089
  if (att.kind !== "folder") {
2083
2090
  att.uploadedUrl = url;