@agentconnect.md/daemon 1.0.0-rc.154 → 1.0.0-rc.155

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
@@ -24358,6 +24358,14 @@ var LocalStore = class {
24358
24358
  if (sinceTs === null) return this.db.prepare("SELECT * FROM transcript WHERE channel = ? AND thread = ? AND kind = 'text' ORDER BY ts ASC").all(channel, thread);
24359
24359
  return this.db.prepare("SELECT * FROM transcript WHERE channel = ? AND thread = ? AND kind = 'text' AND ts > ? ORDER BY ts ASC").all(channel, thread, sinceTs);
24360
24360
  }
24361
+ /** The earliest inbound (non-agent) `text` message in a thread — the triggering user
24362
+ * message. Used as a session-title fallback when the runtime never pushed one
24363
+ * (`setSessionTitle`): many runtimes don't (e.g. the webchat/playground path), so
24364
+ * without this the console shows only "Session <id>". Returns undefined when the
24365
+ * thread holds no non-agent text row yet. Indexed by (channel, thread, seq). */
24366
+ firstMessageText(channel, thread, agentId) {
24367
+ return this.db.prepare("SELECT text FROM transcript WHERE channel = ? AND thread = ? AND kind = 'text' AND sender != ? ORDER BY seq ASC LIMIT 1").get(channel, thread, agentId)?.text;
24368
+ }
24361
24369
  /** Full activity log for a thread (all kinds), in insertion order — for the Web UI. */
24362
24370
  threadTranscript(channel, thread) {
24363
24371
  return this.db.prepare("SELECT * FROM transcript WHERE channel = ? AND thread = ? ORDER BY seq ASC").all(channel, thread);
@@ -83539,6 +83547,19 @@ function utf8Boundary(buf, len) {
83539
83547
  const seqLen = lead < 128 ? 1 : (lead & 224) === 192 ? 2 : (lead & 240) === 224 ? 3 : (lead & 248) === 240 ? 4 : 1;
83540
83548
  return start + seqLen <= len ? len : start;
83541
83549
  }
83550
+ /** Cap for a first-message-derived session title (chars). Runtime-pushed titles are
83551
+ * already short; a raw user message can be long, so the fallback is trimmed. */
83552
+ const TITLE_MAX_CHARS = 80;
83553
+ /** A short, single-line session title from a raw message body: the first non-empty
83554
+ * line, trimmed and capped at TITLE_MAX_CHARS (a trailing `…` marks truncation).
83555
+ * Returns undefined for empty/whitespace input. Used as the session/list fallback
83556
+ * when the runtime never pushed a title. */
83557
+ function deriveTitle(text) {
83558
+ if (!text) return void 0;
83559
+ const line = text.split("\n").map((l) => l.trim()).find((l) => l.length > 0);
83560
+ if (!line) return void 0;
83561
+ return line.length > TITLE_MAX_CHARS ? line.slice(0, TITLE_MAX_CHARS).trimEnd() + "…" : line;
83562
+ }
83542
83563
  /** Parse a session row's `usage` JSON into the wire shape. Returns undefined when
83543
83564
  * absent, empty, or unparseable so the optional field is simply omitted. */
83544
83565
  function parseUsage(raw) {
@@ -83598,17 +83619,20 @@ function previewBody(full) {
83598
83619
  function createSessionReader(store, workspaceUrlFor) {
83599
83620
  return {
83600
83621
  list(req) {
83601
- const rows = store.listSessions(req.agentId);
83602
- const names = store.getDisplayNames(rows.flatMap((r) => [
83622
+ const enriched = store.listSessions(req.agentId).map((r) => ({
83623
+ r,
83624
+ rawTitle: r.title || deriveTitle(store.firstMessageText(r.channel, r.thread, r.agentId))
83625
+ }));
83626
+ const names = store.getDisplayNames(enriched.flatMap(({ r, rawTitle }) => [
83603
83627
  r.channel,
83604
83628
  ...r.triggeredBy ? [r.triggeredBy] : [],
83605
- ...mentionedUserIds(r.title)
83629
+ ...mentionedUserIds(rawTitle)
83606
83630
  ]));
83607
- return { sessions: rows.map((r) => {
83631
+ return { sessions: enriched.map(({ r, rawTitle }) => {
83608
83632
  const usage = parseUsage(r.usage);
83609
83633
  const channelName = names.get(r.channel);
83610
83634
  const triggeredByName = r.triggeredBy ? names.get(r.triggeredBy) : void 0;
83611
- const title = r.title ? substituteUserMentions(r.title, names) : void 0;
83635
+ const title = rawTitle ? substituteUserMentions(rawTitle, names) : void 0;
83612
83636
  const threadUrl = r.platform === "slack" ? slackThreadUrl(workspaceUrlFor?.(r.agentId), r.channel, r.thread) : void 0;
83613
83637
  return {
83614
83638
  sessionId: r.acpSessionId,