bunnyquery 1.9.0 → 1.9.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/dist/engine.mjs CHANGED
@@ -169,7 +169,22 @@ var PAGED_READ_EXTENSIONS = /* @__PURE__ */ new Set([
169
169
  // documents
170
170
  "pdf",
171
171
  "docx",
172
+ "docm",
172
173
  "pptx",
174
+ "pptm",
175
+ "doc",
176
+ "ppt",
177
+ // Korean word processor (OLE/CFB and OOXML-style variants)
178
+ "hwp",
179
+ "hwpx",
180
+ // opendocument text/presentation (ods is a grid, listed above)
181
+ "odt",
182
+ "odp",
183
+ // other long-form documents
184
+ "epub",
185
+ "rtf",
186
+ "html",
187
+ "htm",
173
188
  // plain text / data / markup
174
189
  "txt",
175
190
  "md",
@@ -6247,6 +6262,9 @@ var ChatSession = class {
6247
6262
  };
6248
6263
 
6249
6264
  // src/engine/indexing_groups.ts
6265
+ function canonIndexKey(s) {
6266
+ return typeof s === "string" && s ? s.trim() : "";
6267
+ }
6250
6268
  var RUN_RECORD_WORKING_STALE_MS = 6 * 60 * 60 * 1e3;
6251
6269
  var INDEXING_LABEL_RE = /^(Re)?[Ii]ndexing(\s*\(continuing\))?\s*:?\s+(.+)$/;
6252
6270
  var LEADING_MD_LINK_RE = /^\[([^\]]+)\]\(([^)]+)\)/;
@@ -6316,15 +6334,24 @@ function buildChatDisplayList(messages, opts) {
6316
6334
  var openRunOfKey = {};
6317
6335
  var runsOfKey = {};
6318
6336
  var keyOfRun = {};
6337
+ var newestTsOfRun = {};
6319
6338
  var runSeq = 0;
6320
6339
  for (var i = 0; i < list.length; i++) {
6321
6340
  var msg = list[i];
6322
6341
  if (!msg || !msg.isBackgroundTask) continue;
6323
6342
  var runId;
6324
6343
  var ref = msg.role === "user" ? readFileRef(msg) : null;
6325
- if (ref) {
6344
+ if (msg._serverItemId && runByItemId[msg._serverItemId]) {
6345
+ runId = runByItemId[msg._serverItemId];
6346
+ } else if (ref) {
6326
6347
  var key = ref.path || keyByName[ref.name] || ref.name;
6327
- if (!ref.continued && openRunOfKey[key]) delete openRunOfKey[key];
6348
+ var alreadySeen = !!(msg._serverItemId && runByItemId[msg._serverItemId]);
6349
+ var openId = openRunOfKey[key];
6350
+ var notLater = false;
6351
+ if (openId && typeof msg._ts === "number" && typeof newestTsOfRun[openId] === "number") {
6352
+ notLater = msg._ts <= newestTsOfRun[openId];
6353
+ }
6354
+ if (!ref.continued && !alreadySeen && !notLater && openRunOfKey[key]) delete openRunOfKey[key];
6328
6355
  runId = openRunOfKey[key];
6329
6356
  if (!runId) {
6330
6357
  runId = "run" + runSeq++;
@@ -6332,12 +6359,14 @@ function buildChatDisplayList(messages, opts) {
6332
6359
  keyOfRun[runId] = key;
6333
6360
  (runsOfKey[key] || (runsOfKey[key] = [])).push(runId);
6334
6361
  }
6335
- } else if (msg._serverItemId && runByItemId[msg._serverItemId]) {
6336
- runId = runByItemId[msg._serverItemId];
6337
6362
  } else if (msg.role !== "user") {
6338
6363
  runId = runOfIndex[i - 1];
6339
6364
  }
6340
6365
  if (!runId) continue;
6366
+ if (typeof msg._ts === "number") {
6367
+ var prevTs = newestTsOfRun[runId];
6368
+ if (typeof prevTs !== "number" || msg._ts > prevTs) newestTsOfRun[runId] = msg._ts;
6369
+ }
6341
6370
  var g = groups[runId];
6342
6371
  if (!g) {
6343
6372
  var fileKey = keyOfRun[runId];
@@ -6502,20 +6531,33 @@ function buildChatDisplayList(messages, opts) {
6502
6531
  for (var ci = 0; ci < order.length; ci++) {
6503
6532
  var cg = groups[order[ci]];
6504
6533
  if (cg.path) {
6505
- coveredPaths[cg.path] = true;
6506
- if (cg.key) coveredPaths[cg.key] = true;
6507
- } else if (cg.name) coveredPathlessNames[cg.name] = true;
6508
- else if (cg.key) coveredPaths[cg.key] = true;
6534
+ coveredPaths[canonIndexKey(cg.path)] = true;
6535
+ if (cg.key) coveredPaths[canonIndexKey(cg.key)] = true;
6536
+ } else if (cg.name) coveredPathlessNames[canonIndexKey(cg.name)] = true;
6537
+ else if (cg.key) coveredPaths[canonIndexKey(cg.key)] = true;
6509
6538
  }
6510
6539
  var now = opts && typeof opts.now === "number" ? opts.now : Date.now();
6511
6540
  var stubClearedAt = opts && typeof opts.stubClearedAt === "number" && opts.stubClearedAt > 0 ? opts.stubClearedAt : 0;
6512
6541
  for (var sp in runStubs) {
6513
6542
  var rec = runStubs[sp];
6514
- if (!sp || !rec || !rec.status || coveredPaths[sp]) continue;
6543
+ if (!sp || !rec || !rec.status || coveredPaths[canonIndexKey(sp)]) continue;
6515
6544
  var fname = rec.filename || sp.split("/").pop() || sp;
6516
- if (coveredPathlessNames[fname]) continue;
6545
+ if (coveredPathlessNames[canonIndexKey(fname)]) continue;
6517
6546
  if (stubPlatform && rec.platform && rec.platform !== stubPlatform) continue;
6518
- var live = !!liveIndexKeys[sp] || !!liveIndexKeys[fname];
6547
+ var live = !!liveIndexKeys[sp] || !!liveIndexKeys[canonIndexKey(sp)];
6548
+ if (!live && (liveIndexKeys[fname] || liveIndexKeys[canonIndexKey(fname)])) {
6549
+ var claimedByOther = false;
6550
+ for (var lk in liveIndexKeys) {
6551
+ if (!liveIndexKeys[lk]) continue;
6552
+ var lkc = canonIndexKey(lk);
6553
+ if (lkc === canonIndexKey(sp)) continue;
6554
+ if (lkc.length > fname.length && lkc.slice(-(fname.length + 1)) === "/" + fname) {
6555
+ claimedByOther = true;
6556
+ break;
6557
+ }
6558
+ }
6559
+ live = !claimedByOther;
6560
+ }
6519
6561
  var recWhen = typeof rec.finished === "number" ? rec.finished : typeof rec.started === "number" ? rec.started : void 0;
6520
6562
  if (stubClearedAt && !live && recWhen !== void 0 && recWhen <= stubClearedAt) continue;
6521
6563
  var st = "active";
@@ -6523,7 +6565,7 @@ function buildChatDisplayList(messages, opts) {
6523
6565
  var res = false;
6524
6566
  var reason;
6525
6567
  if (!live) {
6526
- if (rec.status === "done" || doneKeys[sp] || doneKeys[fname]) {
6568
+ if (rec.status === "done" || doneKeys[sp] || doneKeys[canonIndexKey(sp)] || doneKeys[fname] || doneKeys[canonIndexKey(fname)]) {
6527
6569
  st = "done";
6528
6570
  fin = true;
6529
6571
  } else if (rec.status === "error") {
@@ -6577,11 +6619,13 @@ function buildChatDisplayList(messages, opts) {
6577
6619
  }
6578
6620
  }
6579
6621
  var suppressAnchor = {};
6622
+ var stubByCanon = {};
6623
+ if (runStubs) for (var ck in runStubs) stubByCanon[canonIndexKey(ck)] = runStubs[ck];
6580
6624
  if (runStubs) {
6581
6625
  for (var ti2 = 0; ti2 < order.length; ti2++) {
6582
6626
  var tg = groups[order[ti2]];
6583
6627
  if (!newestRunOfKey[order[ti2]]) continue;
6584
- var trec = tg.path && runStubs[tg.path] || runStubs[tg.key];
6628
+ var trec = tg.path && (runStubs[tg.path] || stubByCanon[canonIndexKey(tg.path)]) || runStubs[tg.key] || stubByCanon[canonIndexKey(tg.key)];
6585
6629
  if (!trec || typeof trec.started !== "number") continue;
6586
6630
  if (stubPlatform && trec.platform && trec.platform !== stubPlatform) continue;
6587
6631
  suppressAnchor[order[ti2]] = true;