bunnyquery 1.8.18 → 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/bunnyquery.js CHANGED
@@ -165,7 +165,22 @@
165
165
  // documents
166
166
  "pdf",
167
167
  "docx",
168
+ "docm",
168
169
  "pptx",
170
+ "pptm",
171
+ "doc",
172
+ "ppt",
173
+ // Korean word processor (OLE/CFB and OOXML-style variants)
174
+ "hwp",
175
+ "hwpx",
176
+ // opendocument text/presentation (ods is a grid, listed above)
177
+ "odt",
178
+ "odp",
179
+ // other long-form documents
180
+ "epub",
181
+ "rtf",
182
+ "html",
183
+ "htm",
169
184
  // plain text / data / markup
170
185
  "txt",
171
186
  "md",
@@ -6107,6 +6122,9 @@ Index the REMAINING windows - one record per row/item, looking at any page image
6107
6122
  };
6108
6123
 
6109
6124
  // src/engine/indexing_groups.ts
6125
+ function canonIndexKey(s) {
6126
+ return typeof s === "string" && s ? s.trim() : "";
6127
+ }
6110
6128
  var RUN_RECORD_WORKING_STALE_MS = 6 * 60 * 60 * 1e3;
6111
6129
  var INDEXING_LABEL_RE = /^(Re)?[Ii]ndexing(\s*\(continuing\))?\s*:?\s+(.+)$/;
6112
6130
  var LEADING_MD_LINK_RE = /^\[([^\]]+)\]\(([^)]+)\)/;
@@ -6176,15 +6194,24 @@ Index the REMAINING windows - one record per row/item, looking at any page image
6176
6194
  var openRunOfKey = {};
6177
6195
  var runsOfKey = {};
6178
6196
  var keyOfRun = {};
6197
+ var newestTsOfRun = {};
6179
6198
  var runSeq = 0;
6180
6199
  for (var i = 0; i < list.length; i++) {
6181
6200
  var msg = list[i];
6182
6201
  if (!msg || !msg.isBackgroundTask) continue;
6183
6202
  var runId;
6184
6203
  var ref = msg.role === "user" ? readFileRef(msg) : null;
6185
- if (ref) {
6204
+ if (msg._serverItemId && runByItemId[msg._serverItemId]) {
6205
+ runId = runByItemId[msg._serverItemId];
6206
+ } else if (ref) {
6186
6207
  var key = ref.path || keyByName[ref.name] || ref.name;
6187
- if (!ref.continued && openRunOfKey[key]) delete openRunOfKey[key];
6208
+ var alreadySeen = !!(msg._serverItemId && runByItemId[msg._serverItemId]);
6209
+ var openId = openRunOfKey[key];
6210
+ var notLater = false;
6211
+ if (openId && typeof msg._ts === "number" && typeof newestTsOfRun[openId] === "number") {
6212
+ notLater = msg._ts <= newestTsOfRun[openId];
6213
+ }
6214
+ if (!ref.continued && !alreadySeen && !notLater && openRunOfKey[key]) delete openRunOfKey[key];
6188
6215
  runId = openRunOfKey[key];
6189
6216
  if (!runId) {
6190
6217
  runId = "run" + runSeq++;
@@ -6192,12 +6219,14 @@ Index the REMAINING windows - one record per row/item, looking at any page image
6192
6219
  keyOfRun[runId] = key;
6193
6220
  (runsOfKey[key] || (runsOfKey[key] = [])).push(runId);
6194
6221
  }
6195
- } else if (msg._serverItemId && runByItemId[msg._serverItemId]) {
6196
- runId = runByItemId[msg._serverItemId];
6197
6222
  } else if (msg.role !== "user") {
6198
6223
  runId = runOfIndex[i - 1];
6199
6224
  }
6200
6225
  if (!runId) continue;
6226
+ if (typeof msg._ts === "number") {
6227
+ var prevTs = newestTsOfRun[runId];
6228
+ if (typeof prevTs !== "number" || msg._ts > prevTs) newestTsOfRun[runId] = msg._ts;
6229
+ }
6201
6230
  var g = groups[runId];
6202
6231
  if (!g) {
6203
6232
  var fileKey = keyOfRun[runId];
@@ -6362,20 +6391,33 @@ Index the REMAINING windows - one record per row/item, looking at any page image
6362
6391
  for (var ci = 0; ci < order.length; ci++) {
6363
6392
  var cg = groups[order[ci]];
6364
6393
  if (cg.path) {
6365
- coveredPaths[cg.path] = true;
6366
- if (cg.key) coveredPaths[cg.key] = true;
6367
- } else if (cg.name) coveredPathlessNames[cg.name] = true;
6368
- else if (cg.key) coveredPaths[cg.key] = true;
6394
+ coveredPaths[canonIndexKey(cg.path)] = true;
6395
+ if (cg.key) coveredPaths[canonIndexKey(cg.key)] = true;
6396
+ } else if (cg.name) coveredPathlessNames[canonIndexKey(cg.name)] = true;
6397
+ else if (cg.key) coveredPaths[canonIndexKey(cg.key)] = true;
6369
6398
  }
6370
6399
  var now = opts && typeof opts.now === "number" ? opts.now : Date.now();
6371
6400
  var stubClearedAt = opts && typeof opts.stubClearedAt === "number" && opts.stubClearedAt > 0 ? opts.stubClearedAt : 0;
6372
6401
  for (var sp in runStubs) {
6373
6402
  var rec = runStubs[sp];
6374
- if (!sp || !rec || !rec.status || coveredPaths[sp]) continue;
6403
+ if (!sp || !rec || !rec.status || coveredPaths[canonIndexKey(sp)]) continue;
6375
6404
  var fname = rec.filename || sp.split("/").pop() || sp;
6376
- if (coveredPathlessNames[fname]) continue;
6405
+ if (coveredPathlessNames[canonIndexKey(fname)]) continue;
6377
6406
  if (stubPlatform && rec.platform && rec.platform !== stubPlatform) continue;
6378
- var live = !!liveIndexKeys[sp] || !!liveIndexKeys[fname];
6407
+ var live = !!liveIndexKeys[sp] || !!liveIndexKeys[canonIndexKey(sp)];
6408
+ if (!live && (liveIndexKeys[fname] || liveIndexKeys[canonIndexKey(fname)])) {
6409
+ var claimedByOther = false;
6410
+ for (var lk in liveIndexKeys) {
6411
+ if (!liveIndexKeys[lk]) continue;
6412
+ var lkc = canonIndexKey(lk);
6413
+ if (lkc === canonIndexKey(sp)) continue;
6414
+ if (lkc.length > fname.length && lkc.slice(-(fname.length + 1)) === "/" + fname) {
6415
+ claimedByOther = true;
6416
+ break;
6417
+ }
6418
+ }
6419
+ live = !claimedByOther;
6420
+ }
6379
6421
  var recWhen = typeof rec.finished === "number" ? rec.finished : typeof rec.started === "number" ? rec.started : void 0;
6380
6422
  if (stubClearedAt && !live && recWhen !== void 0 && recWhen <= stubClearedAt) continue;
6381
6423
  var st = "active";
@@ -6383,7 +6425,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
6383
6425
  var res = false;
6384
6426
  var reason;
6385
6427
  if (!live) {
6386
- if (rec.status === "done" || doneKeys[sp] || doneKeys[fname]) {
6428
+ if (rec.status === "done" || doneKeys[sp] || doneKeys[canonIndexKey(sp)] || doneKeys[fname] || doneKeys[canonIndexKey(fname)]) {
6387
6429
  st = "done";
6388
6430
  fin = true;
6389
6431
  } else if (rec.status === "error") {
@@ -6437,11 +6479,13 @@ Index the REMAINING windows - one record per row/item, looking at any page image
6437
6479
  }
6438
6480
  }
6439
6481
  var suppressAnchor = {};
6482
+ var stubByCanon = {};
6483
+ if (runStubs) for (var ck in runStubs) stubByCanon[canonIndexKey(ck)] = runStubs[ck];
6440
6484
  if (runStubs) {
6441
6485
  for (var ti2 = 0; ti2 < order.length; ti2++) {
6442
6486
  var tg = groups[order[ti2]];
6443
6487
  if (!newestRunOfKey[order[ti2]]) continue;
6444
- var trec = tg.path && runStubs[tg.path] || runStubs[tg.key];
6488
+ var trec = tg.path && (runStubs[tg.path] || stubByCanon[canonIndexKey(tg.path)]) || runStubs[tg.key] || stubByCanon[canonIndexKey(tg.key)];
6445
6489
  if (!trec || typeof trec.started !== "number") continue;
6446
6490
  if (stubPlatform && trec.platform && trec.platform !== stubPlatform) continue;
6447
6491
  suppressAnchor[order[ti2]] = true;
@@ -6482,7 +6526,7 @@ Index the REMAINING windows - one record per row/item, looking at any page image
6482
6526
  (function() {
6483
6527
  var MCP_PROD = "https://mcp.broadwayinc.computer";
6484
6528
  var MCP_DEV = "https://mcp-dev.broadwayinc.computer";
6485
- var BQ_VERSION = "1.8.18" ;
6529
+ var BQ_VERSION = "1.9.1" ;
6486
6530
  var ATTACHMENT_URL_EXPIRES_SECONDS = 600;
6487
6531
  var GOOGLE_AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth";
6488
6532
  var GOOGLE_TOKEN_URL = "https://oauth2.googleapis.com/token";
package/dist/engine.cjs CHANGED
@@ -171,7 +171,22 @@ var PAGED_READ_EXTENSIONS = /* @__PURE__ */ new Set([
171
171
  // documents
172
172
  "pdf",
173
173
  "docx",
174
+ "docm",
174
175
  "pptx",
176
+ "pptm",
177
+ "doc",
178
+ "ppt",
179
+ // Korean word processor (OLE/CFB and OOXML-style variants)
180
+ "hwp",
181
+ "hwpx",
182
+ // opendocument text/presentation (ods is a grid, listed above)
183
+ "odt",
184
+ "odp",
185
+ // other long-form documents
186
+ "epub",
187
+ "rtf",
188
+ "html",
189
+ "htm",
175
190
  // plain text / data / markup
176
191
  "txt",
177
192
  "md",
@@ -6249,6 +6264,9 @@ var ChatSession = class {
6249
6264
  };
6250
6265
 
6251
6266
  // src/engine/indexing_groups.ts
6267
+ function canonIndexKey(s) {
6268
+ return typeof s === "string" && s ? s.trim() : "";
6269
+ }
6252
6270
  var RUN_RECORD_WORKING_STALE_MS = 6 * 60 * 60 * 1e3;
6253
6271
  var INDEXING_LABEL_RE = /^(Re)?[Ii]ndexing(\s*\(continuing\))?\s*:?\s+(.+)$/;
6254
6272
  var LEADING_MD_LINK_RE = /^\[([^\]]+)\]\(([^)]+)\)/;
@@ -6318,15 +6336,24 @@ function buildChatDisplayList(messages, opts) {
6318
6336
  var openRunOfKey = {};
6319
6337
  var runsOfKey = {};
6320
6338
  var keyOfRun = {};
6339
+ var newestTsOfRun = {};
6321
6340
  var runSeq = 0;
6322
6341
  for (var i = 0; i < list.length; i++) {
6323
6342
  var msg = list[i];
6324
6343
  if (!msg || !msg.isBackgroundTask) continue;
6325
6344
  var runId;
6326
6345
  var ref = msg.role === "user" ? readFileRef(msg) : null;
6327
- if (ref) {
6346
+ if (msg._serverItemId && runByItemId[msg._serverItemId]) {
6347
+ runId = runByItemId[msg._serverItemId];
6348
+ } else if (ref) {
6328
6349
  var key = ref.path || keyByName[ref.name] || ref.name;
6329
- if (!ref.continued && openRunOfKey[key]) delete openRunOfKey[key];
6350
+ var alreadySeen = !!(msg._serverItemId && runByItemId[msg._serverItemId]);
6351
+ var openId = openRunOfKey[key];
6352
+ var notLater = false;
6353
+ if (openId && typeof msg._ts === "number" && typeof newestTsOfRun[openId] === "number") {
6354
+ notLater = msg._ts <= newestTsOfRun[openId];
6355
+ }
6356
+ if (!ref.continued && !alreadySeen && !notLater && openRunOfKey[key]) delete openRunOfKey[key];
6330
6357
  runId = openRunOfKey[key];
6331
6358
  if (!runId) {
6332
6359
  runId = "run" + runSeq++;
@@ -6334,12 +6361,14 @@ function buildChatDisplayList(messages, opts) {
6334
6361
  keyOfRun[runId] = key;
6335
6362
  (runsOfKey[key] || (runsOfKey[key] = [])).push(runId);
6336
6363
  }
6337
- } else if (msg._serverItemId && runByItemId[msg._serverItemId]) {
6338
- runId = runByItemId[msg._serverItemId];
6339
6364
  } else if (msg.role !== "user") {
6340
6365
  runId = runOfIndex[i - 1];
6341
6366
  }
6342
6367
  if (!runId) continue;
6368
+ if (typeof msg._ts === "number") {
6369
+ var prevTs = newestTsOfRun[runId];
6370
+ if (typeof prevTs !== "number" || msg._ts > prevTs) newestTsOfRun[runId] = msg._ts;
6371
+ }
6343
6372
  var g = groups[runId];
6344
6373
  if (!g) {
6345
6374
  var fileKey = keyOfRun[runId];
@@ -6504,20 +6533,33 @@ function buildChatDisplayList(messages, opts) {
6504
6533
  for (var ci = 0; ci < order.length; ci++) {
6505
6534
  var cg = groups[order[ci]];
6506
6535
  if (cg.path) {
6507
- coveredPaths[cg.path] = true;
6508
- if (cg.key) coveredPaths[cg.key] = true;
6509
- } else if (cg.name) coveredPathlessNames[cg.name] = true;
6510
- else if (cg.key) coveredPaths[cg.key] = true;
6536
+ coveredPaths[canonIndexKey(cg.path)] = true;
6537
+ if (cg.key) coveredPaths[canonIndexKey(cg.key)] = true;
6538
+ } else if (cg.name) coveredPathlessNames[canonIndexKey(cg.name)] = true;
6539
+ else if (cg.key) coveredPaths[canonIndexKey(cg.key)] = true;
6511
6540
  }
6512
6541
  var now = opts && typeof opts.now === "number" ? opts.now : Date.now();
6513
6542
  var stubClearedAt = opts && typeof opts.stubClearedAt === "number" && opts.stubClearedAt > 0 ? opts.stubClearedAt : 0;
6514
6543
  for (var sp in runStubs) {
6515
6544
  var rec = runStubs[sp];
6516
- if (!sp || !rec || !rec.status || coveredPaths[sp]) continue;
6545
+ if (!sp || !rec || !rec.status || coveredPaths[canonIndexKey(sp)]) continue;
6517
6546
  var fname = rec.filename || sp.split("/").pop() || sp;
6518
- if (coveredPathlessNames[fname]) continue;
6547
+ if (coveredPathlessNames[canonIndexKey(fname)]) continue;
6519
6548
  if (stubPlatform && rec.platform && rec.platform !== stubPlatform) continue;
6520
- var live = !!liveIndexKeys[sp] || !!liveIndexKeys[fname];
6549
+ var live = !!liveIndexKeys[sp] || !!liveIndexKeys[canonIndexKey(sp)];
6550
+ if (!live && (liveIndexKeys[fname] || liveIndexKeys[canonIndexKey(fname)])) {
6551
+ var claimedByOther = false;
6552
+ for (var lk in liveIndexKeys) {
6553
+ if (!liveIndexKeys[lk]) continue;
6554
+ var lkc = canonIndexKey(lk);
6555
+ if (lkc === canonIndexKey(sp)) continue;
6556
+ if (lkc.length > fname.length && lkc.slice(-(fname.length + 1)) === "/" + fname) {
6557
+ claimedByOther = true;
6558
+ break;
6559
+ }
6560
+ }
6561
+ live = !claimedByOther;
6562
+ }
6521
6563
  var recWhen = typeof rec.finished === "number" ? rec.finished : typeof rec.started === "number" ? rec.started : void 0;
6522
6564
  if (stubClearedAt && !live && recWhen !== void 0 && recWhen <= stubClearedAt) continue;
6523
6565
  var st = "active";
@@ -6525,7 +6567,7 @@ function buildChatDisplayList(messages, opts) {
6525
6567
  var res = false;
6526
6568
  var reason;
6527
6569
  if (!live) {
6528
- if (rec.status === "done" || doneKeys[sp] || doneKeys[fname]) {
6570
+ if (rec.status === "done" || doneKeys[sp] || doneKeys[canonIndexKey(sp)] || doneKeys[fname] || doneKeys[canonIndexKey(fname)]) {
6529
6571
  st = "done";
6530
6572
  fin = true;
6531
6573
  } else if (rec.status === "error") {
@@ -6579,11 +6621,13 @@ function buildChatDisplayList(messages, opts) {
6579
6621
  }
6580
6622
  }
6581
6623
  var suppressAnchor = {};
6624
+ var stubByCanon = {};
6625
+ if (runStubs) for (var ck in runStubs) stubByCanon[canonIndexKey(ck)] = runStubs[ck];
6582
6626
  if (runStubs) {
6583
6627
  for (var ti2 = 0; ti2 < order.length; ti2++) {
6584
6628
  var tg = groups[order[ti2]];
6585
6629
  if (!newestRunOfKey[order[ti2]]) continue;
6586
- var trec = tg.path && runStubs[tg.path] || runStubs[tg.key];
6630
+ var trec = tg.path && (runStubs[tg.path] || stubByCanon[canonIndexKey(tg.path)]) || runStubs[tg.key] || stubByCanon[canonIndexKey(tg.key)];
6587
6631
  if (!trec || typeof trec.started !== "number") continue;
6588
6632
  if (stubPlatform && trec.platform && trec.platform !== stubPlatform) continue;
6589
6633
  suppressAnchor[order[ti2]] = true;