agent-theatre 1.3.2 → 1.3.4

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/index.js CHANGED
@@ -360,9 +360,17 @@ function hookPayloadToEvents(payload, opts = {}) {
360
360
  }
361
361
  function noteOf(text) {
362
362
  if (!text) return {};
363
- const para = text.trim().split(/\n{2,}/).filter((x) => x.trim()).pop()?.replace(/\s+/g, " ").trim() ?? "";
364
- if (!para) return {};
365
- return { note: para.length > 240 ? "\u2026" + para.slice(-239) : para };
363
+ const clean = text.replace(/```[\s\S]*?```/g, " ").replace(/`([^`]*)`/g, "$1").replace(/\[([^\]]+)\]\([^)]*\)/g, "$1").replace(/\*+|#+|>+/g, "").replace(/(^|\s)_+|_+(?=\s|$)/g, "$1").replace(/^\s*[-•\d.)]+\s+/gm, "").replace(/\s+/g, " ").trim();
364
+ if (!clean) return {};
365
+ const sentences = clean.match(/[^.!?]+[.!?]+(?=\s|$)|[^.!?]+$/g)?.map((x) => x.trim()).filter(Boolean) ?? [clean];
366
+ const questions = sentences.filter((x) => x.endsWith("?"));
367
+ let note = questions.length ? questions[questions.length - 1] : sentences[0];
368
+ if (!questions.length) for (const next of sentences.slice(1)) {
369
+ if (!/[.!?]$/.test(next) || note.length + next.length + 1 > 160) break;
370
+ note = `${note} ${next}`;
371
+ }
372
+ if (note.length > 200) note = note.slice(0, 197).replace(/\s+\S*$/, "") + "\u2026";
373
+ return { note };
366
374
  }
367
375
  var ROW_TYPES = /* @__PURE__ */ new Set(["user", "assistant", "system"]);
368
376
  var obj3 = (x) => x && typeof x === "object" ? x : {};