@voicethere/agent 0.23.2 → 0.25.0

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.
@@ -31724,6 +31724,14 @@ function buildIdleEnv(sessionId) {
31724
31724
  ...process.env.IDLE_TIMEOUT_SEC ? { IDLE_TIMEOUT_SEC: process.env.IDLE_TIMEOUT_SEC } : {}
31725
31725
  };
31726
31726
  }
31727
+ function speakKindFields(options) {
31728
+ if (options?.kind !== "filler")
31729
+ return {};
31730
+ return {
31731
+ kind: "filler",
31732
+ ...options.fillerKind ? { fillerKind: options.fillerKind } : {}
31733
+ };
31734
+ }
31727
31735
  function speakControlAvailableFor(sessionId) {
31728
31736
  return speakControlAvailableBySessionId.get(sessionId) ?? false;
31729
31737
  }
@@ -31761,7 +31769,8 @@ function speak(sessionId, text, options) {
31761
31769
  type: "speak",
31762
31770
  sessionId,
31763
31771
  text,
31764
- ...options?.interruptible === false ? { interruptible: false } : {}
31772
+ ...options?.interruptible === false ? { interruptible: false } : {},
31773
+ ...speakKindFields(options)
31765
31774
  });
31766
31775
  warnSpeakControlUnavailable(sessionId);
31767
31776
  return handle({ requestId, status: "unsupported", playedMs: 0 });
@@ -31793,7 +31802,8 @@ function speak(sessionId, text, options) {
31793
31802
  requestId,
31794
31803
  ...options?.interruptible === false ? { interruptible: false } : {},
31795
31804
  ...turnId ? { turnId } : {},
31796
- ...inReplyTo ? { inReplyTo } : {}
31805
+ ...inReplyTo ? { inReplyTo } : {},
31806
+ ...speakKindFields(options)
31797
31807
  });
31798
31808
  return {
31799
31809
  requestId,
@@ -34990,6 +35000,24 @@ var ConversationHistory = class {
34990
35000
 
34991
35001
  // dist/llm/agent/link-extractor.js
34992
35002
  var LINK_MARK = "\uE000";
35003
+ var BARE_DOMAIN_TLDS = /* @__PURE__ */ new Set([
35004
+ "com",
35005
+ "org",
35006
+ "net",
35007
+ "dev",
35008
+ "io",
35009
+ "ai",
35010
+ "app",
35011
+ "co",
35012
+ "cloud",
35013
+ "eu",
35014
+ "de",
35015
+ "uk",
35016
+ "us"
35017
+ ]);
35018
+ var DOMAIN_RE = /^((?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+([a-z]{2,63}))(\/[^\s]*)?/i;
35019
+ var DOMAIN_PREFIX_RE = /^[a-z0-9][a-z0-9.-]*$/i;
35020
+ var ALNUM_RE = /[\p{L}\p{N}]/u;
34993
35021
  var SCHEMES = ["https://", "http://"];
34994
35022
  var START_RE = /\[|https?:\/\//i;
34995
35023
  var BARE_RE = /^https?:\/\/\S*/i;
@@ -35055,6 +35083,85 @@ function hasHost(url2) {
35055
35083
  var LinkExtractor = class {
35056
35084
  buf = "";
35057
35085
  links = [];
35086
+ /**
35087
+ * The emitted tail of the current word when it is made only of host
35088
+ * characters (`[a-z0-9.-]`), and the character before that word. A word
35089
+ * such as "voicethere" is spoken before ".dev" arrives; the lead lets the
35090
+ * domain still be recognised, so streaming gives the same result as one push.
35091
+ */
35092
+ lead = "";
35093
+ leadPrev = "";
35094
+ consume(n) {
35095
+ const taken = this.buf.slice(0, n);
35096
+ this.buf = this.buf.slice(n);
35097
+ const s = this.lead + taken;
35098
+ let k = -1;
35099
+ for (let j = s.length - 1; j >= 0; j -= 1) {
35100
+ if (!/[a-z0-9.-]/i.test(s[j])) {
35101
+ k = j;
35102
+ break;
35103
+ }
35104
+ }
35105
+ if (k >= 0) {
35106
+ this.leadPrev = s[k];
35107
+ this.lead = s.slice(k + 1);
35108
+ } else {
35109
+ this.lead = s;
35110
+ }
35111
+ if (this.lead.length > MAX_HOLD) {
35112
+ this.lead = "";
35113
+ this.leadPrev = "x";
35114
+ }
35115
+ return taken;
35116
+ }
35117
+ /** After a link: the text now ends in a mark, so no word is open. */
35118
+ closeWord() {
35119
+ this.lead = "";
35120
+ this.leadPrev = LINK_MARK;
35121
+ }
35122
+ /** The first bare domain (or possible start of one at the tail) in the buffer. */
35123
+ scanDomain(final) {
35124
+ const off = this.lead.length;
35125
+ const ctx = this.lead + this.buf;
35126
+ for (let i = 0; i < ctx.length; i += 1) {
35127
+ if (!/[a-z0-9]/i.test(ctx[i]))
35128
+ continue;
35129
+ const before = i === 0 ? this.leadPrev : ctx[i - 1];
35130
+ if (!(before === "" || /[\s("']/.test(before)))
35131
+ continue;
35132
+ const rest = ctx.slice(i);
35133
+ const m = DOMAIN_RE.exec(rest);
35134
+ if (!m) {
35135
+ if (!final && rest.length <= MAX_HOLD && rest.includes(".") && DOMAIN_PREFIX_RE.test(rest)) {
35136
+ return { index: i, hold: true, off };
35137
+ }
35138
+ continue;
35139
+ }
35140
+ const host = m[1];
35141
+ const path2 = m[3] ?? "";
35142
+ const end = m[0].length;
35143
+ if (!final && end === rest.length && end <= MAX_HOLD) {
35144
+ return { index: i, hold: true, off };
35145
+ }
35146
+ const next = rest[end] ?? "";
35147
+ if (!final && !path2 && next === "." && end + 1 === rest.length) {
35148
+ return { index: i, hold: true, off };
35149
+ }
35150
+ if (!BARE_DOMAIN_TLDS.has(m[2].toLowerCase()))
35151
+ continue;
35152
+ if (!path2) {
35153
+ if (next && /[\p{L}\p{N}@_-]/u.test(next))
35154
+ continue;
35155
+ if (next === "." && ALNUM_RE.test(rest[end + 1] ?? ""))
35156
+ continue;
35157
+ }
35158
+ const { url: url2 } = trimUrl(host + path2);
35159
+ if (i < off && host.length < off - i)
35160
+ continue;
35161
+ return { index: i, hold: false, off, host, url: url2 };
35162
+ }
35163
+ return void 0;
35164
+ }
35058
35165
  push(delta) {
35059
35166
  this.buf += delta;
35060
35167
  return this.drain(false);
@@ -35072,54 +35179,65 @@ var LinkExtractor = class {
35072
35179
  this.links = [];
35073
35180
  return all;
35074
35181
  }
35075
- add(url2, label) {
35182
+ add(url2, label, sourceText) {
35076
35183
  const trimmed = label?.trim();
35077
35184
  this.links.push({
35078
35185
  url: url2,
35079
35186
  ...trimmed ? { label: trimmed } : {},
35080
- secure: /^https:\/\//i.test(url2)
35187
+ secure: /^https:\/\//i.test(url2),
35188
+ ...sourceText ? { sourceText } : {}
35081
35189
  });
35082
35190
  }
35083
35191
  drain(final) {
35084
35192
  let out = "";
35085
35193
  for (; ; ) {
35086
35194
  const m = START_RE.exec(this.buf);
35195
+ const d = this.scanDomain(final);
35196
+ if (d && (!m || Math.max(0, d.index - d.off) < m.index)) {
35197
+ const spoken = Math.max(0, d.off - d.index);
35198
+ out += this.consume(Math.max(0, d.index - d.off));
35199
+ if (d.hold)
35200
+ return out;
35201
+ this.add("https://" + d.url, d.host, d.url);
35202
+ this.consume(d.url.length - spoken);
35203
+ out += d.host.slice(spoken) + LINK_MARK;
35204
+ this.closeWord();
35205
+ continue;
35206
+ }
35087
35207
  if (!m) {
35088
35208
  const hold = final ? 0 : partialSchemeSuffix(this.buf);
35089
- out += this.buf.slice(0, this.buf.length - hold);
35090
- this.buf = this.buf.slice(this.buf.length - hold);
35209
+ out += this.consume(this.buf.length - hold);
35091
35210
  return out;
35092
35211
  }
35093
- out += this.buf.slice(0, m.index);
35094
- this.buf = this.buf.slice(m.index);
35212
+ out += this.consume(m.index);
35095
35213
  if (this.buf[0] === "[") {
35096
35214
  const md = MARKDOWN_RE.exec(this.buf);
35097
35215
  if (md && hasHost(md[2])) {
35098
35216
  this.add(md[2], md[1]);
35099
35217
  out += `${md[1]}${LINK_MARK}`;
35100
- this.buf = this.buf.slice(md[0].length);
35218
+ this.consume(md[0].length);
35219
+ this.closeWord();
35101
35220
  continue;
35102
35221
  }
35103
35222
  if (!final && this.buf.length <= MAX_HOLD && MARKDOWN_PREFIX_RE.test(this.buf)) {
35104
35223
  return out;
35105
35224
  }
35106
- out += "[";
35107
- this.buf = this.buf.slice(1);
35225
+ out += this.consume(1);
35108
35226
  continue;
35109
35227
  }
35110
35228
  const bare = BARE_RE.exec(this.buf);
35111
35229
  if (!final && bare[0].length === this.buf.length && this.buf.length <= MAX_HOLD) {
35112
35230
  return out;
35113
35231
  }
35114
- const { url: url2, rest } = trimUrl(bare[0]);
35232
+ const { url: url2 } = trimUrl(bare[0]);
35115
35233
  if (!hasHost(url2)) {
35116
- out += bare[0];
35117
- this.buf = this.buf.slice(bare[0].length);
35234
+ out += this.consume(bare[0].length);
35118
35235
  continue;
35119
35236
  }
35120
35237
  this.add(url2);
35121
35238
  out += LINK_MARK;
35122
- this.buf = rest + this.buf.slice(bare[0].length);
35239
+ this.consume(url2.length);
35240
+ this.closeWord();
35123
35241
  }
35124
35242
  }
35125
35243
  };
@@ -35451,7 +35569,7 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
35451
35569
  t.linksDropped += 1;
35452
35570
  return;
35453
35571
  }
35454
- if (linksRequireToolSource && !t.toolResults.some((r) => r.includes(link.url))) {
35572
+ if (linksRequireToolSource && !t.toolResults.some((r) => r.includes(link.url) || link.sourceText !== void 0 && r.includes(link.sourceText))) {
35455
35573
  t.linksDropped += 1;
35456
35574
  return;
35457
35575
  }
@@ -35475,11 +35593,15 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
35475
35593
  }
35476
35594
  }
35477
35595
  }
35478
- function speakAnnouncement(s, turnId, text, interruptible) {
35596
+ function sendFillerMessage(s, turnId, text) {
35597
+ sendToClient(s.sessionId, { type: "assistant_filler", turnId, text });
35598
+ }
35599
+ function speakAnnouncement(s, turnId, text, interruptible, fillerKind) {
35600
+ const opts2 = fillerKind ? { turnId, kind: "filler", fillerKind } : { turnId };
35479
35601
  if (interruptible) {
35480
- return speak(s.sessionId, text, { turnId });
35602
+ return speak(s.sessionId, text, opts2);
35481
35603
  }
35482
- const h = announce(s.sessionId, text, { turnId });
35604
+ const h = announce(s.sessionId, text, opts2);
35483
35605
  trackAnnouncement(s, h.done);
35484
35606
  return h;
35485
35607
  }
@@ -35548,7 +35670,8 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
35548
35670
  t.toolCallSpoken = true;
35549
35671
  if (kind === "toolWait")
35550
35672
  t.toolWaitSpoken += 1;
35551
- speakAnnouncement(s, t.turnId, text, fillersInterruptible);
35673
+ speakAnnouncement(s, t.turnId, text, fillersInterruptible, kind);
35674
+ sendFillerMessage(s, t.turnId, text);
35552
35675
  return void 0;
35553
35676
  }
35554
35677
  function armFiller(s, t, kind, delayMs, afterMs) {
@@ -36075,7 +36198,8 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
36075
36198
  if (t.fillerSpoken || signal.aborted)
36076
36199
  return;
36077
36200
  t.fillerSpoken = true;
36078
- speakAnnouncement(s, t.turnId, fillerLegacy.text, fillerLegacy.interruptible ?? D.fillerInterruptible);
36201
+ speakAnnouncement(s, t.turnId, fillerLegacy.text, fillerLegacy.interruptible ?? D.fillerInterruptible, "toolWait");
36202
+ sendFillerMessage(s, t.turnId, fillerLegacy.text);
36079
36203
  }, fillerLegacy.afterMs ?? D.fillerAfterMs);
36080
36204
  }
36081
36205
  let results;
@@ -1096,6 +1096,14 @@ function buildIdleEnv(sessionId) {
1096
1096
  ...process.env.IDLE_TIMEOUT_SEC ? { IDLE_TIMEOUT_SEC: process.env.IDLE_TIMEOUT_SEC } : {}
1097
1097
  };
1098
1098
  }
1099
+ function speakKindFields(options) {
1100
+ if (options?.kind !== "filler")
1101
+ return {};
1102
+ return {
1103
+ kind: "filler",
1104
+ ...options.fillerKind ? { fillerKind: options.fillerKind } : {}
1105
+ };
1106
+ }
1099
1107
  function speakControlAvailableFor(sessionId) {
1100
1108
  return speakControlAvailableBySessionId.get(sessionId) ?? false;
1101
1109
  }
@@ -1133,7 +1141,8 @@ function speak(sessionId, text, options) {
1133
1141
  type: "speak",
1134
1142
  sessionId,
1135
1143
  text,
1136
- ...options?.interruptible === false ? { interruptible: false } : {}
1144
+ ...options?.interruptible === false ? { interruptible: false } : {},
1145
+ ...speakKindFields(options)
1137
1146
  });
1138
1147
  warnSpeakControlUnavailable(sessionId);
1139
1148
  return handle({ requestId, status: "unsupported", playedMs: 0 });
@@ -1165,7 +1174,8 @@ function speak(sessionId, text, options) {
1165
1174
  requestId,
1166
1175
  ...options?.interruptible === false ? { interruptible: false } : {},
1167
1176
  ...turnId ? { turnId } : {},
1168
- ...inReplyTo ? { inReplyTo } : {}
1177
+ ...inReplyTo ? { inReplyTo } : {},
1178
+ ...speakKindFields(options)
1169
1179
  });
1170
1180
  return {
1171
1181
  requestId,
@@ -1081,6 +1081,14 @@ function buildIdleEnv(sessionId) {
1081
1081
  ...process.env.IDLE_TIMEOUT_SEC ? { IDLE_TIMEOUT_SEC: process.env.IDLE_TIMEOUT_SEC } : {}
1082
1082
  };
1083
1083
  }
1084
+ function speakKindFields(options) {
1085
+ if (options?.kind !== "filler")
1086
+ return {};
1087
+ return {
1088
+ kind: "filler",
1089
+ ...options.fillerKind ? { fillerKind: options.fillerKind } : {}
1090
+ };
1091
+ }
1084
1092
  function speakControlAvailableFor(sessionId) {
1085
1093
  return speakControlAvailableBySessionId.get(sessionId) ?? false;
1086
1094
  }
@@ -1118,7 +1126,8 @@ function speak(sessionId, text, options) {
1118
1126
  type: "speak",
1119
1127
  sessionId,
1120
1128
  text,
1121
- ...options?.interruptible === false ? { interruptible: false } : {}
1129
+ ...options?.interruptible === false ? { interruptible: false } : {},
1130
+ ...speakKindFields(options)
1122
1131
  });
1123
1132
  warnSpeakControlUnavailable(sessionId);
1124
1133
  return handle({ requestId, status: "unsupported", playedMs: 0 });
@@ -1150,7 +1159,8 @@ function speak(sessionId, text, options) {
1150
1159
  requestId,
1151
1160
  ...options?.interruptible === false ? { interruptible: false } : {},
1152
1161
  ...turnId ? { turnId } : {},
1153
- ...inReplyTo ? { inReplyTo } : {}
1162
+ ...inReplyTo ? { inReplyTo } : {},
1163
+ ...speakKindFields(options)
1154
1164
  });
1155
1165
  return {
1156
1166
  requestId,
@@ -1111,6 +1111,14 @@ function buildIdleEnv(sessionId) {
1111
1111
  ...process.env.IDLE_TIMEOUT_SEC ? { IDLE_TIMEOUT_SEC: process.env.IDLE_TIMEOUT_SEC } : {}
1112
1112
  };
1113
1113
  }
1114
+ function speakKindFields(options) {
1115
+ if (options?.kind !== "filler")
1116
+ return {};
1117
+ return {
1118
+ kind: "filler",
1119
+ ...options.fillerKind ? { fillerKind: options.fillerKind } : {}
1120
+ };
1121
+ }
1114
1122
  function speakControlAvailableFor(sessionId) {
1115
1123
  return speakControlAvailableBySessionId.get(sessionId) ?? false;
1116
1124
  }
@@ -1148,7 +1156,8 @@ function speak(sessionId, text, options) {
1148
1156
  type: "speak",
1149
1157
  sessionId,
1150
1158
  text,
1151
- ...options?.interruptible === false ? { interruptible: false } : {}
1159
+ ...options?.interruptible === false ? { interruptible: false } : {},
1160
+ ...speakKindFields(options)
1152
1161
  });
1153
1162
  warnSpeakControlUnavailable(sessionId);
1154
1163
  return handle({ requestId, status: "unsupported", playedMs: 0 });
@@ -1180,7 +1189,8 @@ function speak(sessionId, text, options) {
1180
1189
  requestId,
1181
1190
  ...options?.interruptible === false ? { interruptible: false } : {},
1182
1191
  ...turnId ? { turnId } : {},
1183
- ...inReplyTo ? { inReplyTo } : {}
1192
+ ...inReplyTo ? { inReplyTo } : {},
1193
+ ...speakKindFields(options)
1184
1194
  });
1185
1195
  return {
1186
1196
  requestId,
@@ -1080,6 +1080,14 @@ function buildIdleEnv(sessionId) {
1080
1080
  ...process.env.IDLE_TIMEOUT_SEC ? { IDLE_TIMEOUT_SEC: process.env.IDLE_TIMEOUT_SEC } : {}
1081
1081
  };
1082
1082
  }
1083
+ function speakKindFields(options) {
1084
+ if (options?.kind !== "filler")
1085
+ return {};
1086
+ return {
1087
+ kind: "filler",
1088
+ ...options.fillerKind ? { fillerKind: options.fillerKind } : {}
1089
+ };
1090
+ }
1083
1091
  function speakControlAvailableFor(sessionId) {
1084
1092
  return speakControlAvailableBySessionId.get(sessionId) ?? false;
1085
1093
  }
@@ -1117,7 +1125,8 @@ function speak(sessionId, text, options) {
1117
1125
  type: "speak",
1118
1126
  sessionId,
1119
1127
  text,
1120
- ...options?.interruptible === false ? { interruptible: false } : {}
1128
+ ...options?.interruptible === false ? { interruptible: false } : {},
1129
+ ...speakKindFields(options)
1121
1130
  });
1122
1131
  warnSpeakControlUnavailable(sessionId);
1123
1132
  return handle({ requestId, status: "unsupported", playedMs: 0 });
@@ -1149,7 +1158,8 @@ function speak(sessionId, text, options) {
1149
1158
  requestId,
1150
1159
  ...options?.interruptible === false ? { interruptible: false } : {},
1151
1160
  ...turnId ? { turnId } : {},
1152
- ...inReplyTo ? { inReplyTo } : {}
1161
+ ...inReplyTo ? { inReplyTo } : {},
1162
+ ...speakKindFields(options)
1153
1163
  });
1154
1164
  return {
1155
1165
  requestId,
@@ -1080,6 +1080,14 @@ function buildIdleEnv(sessionId) {
1080
1080
  ...process.env.IDLE_TIMEOUT_SEC ? { IDLE_TIMEOUT_SEC: process.env.IDLE_TIMEOUT_SEC } : {}
1081
1081
  };
1082
1082
  }
1083
+ function speakKindFields(options) {
1084
+ if (options?.kind !== "filler")
1085
+ return {};
1086
+ return {
1087
+ kind: "filler",
1088
+ ...options.fillerKind ? { fillerKind: options.fillerKind } : {}
1089
+ };
1090
+ }
1083
1091
  function speakControlAvailableFor(sessionId) {
1084
1092
  return speakControlAvailableBySessionId.get(sessionId) ?? false;
1085
1093
  }
@@ -1117,7 +1125,8 @@ function speak(sessionId, text, options) {
1117
1125
  type: "speak",
1118
1126
  sessionId,
1119
1127
  text,
1120
- ...options?.interruptible === false ? { interruptible: false } : {}
1128
+ ...options?.interruptible === false ? { interruptible: false } : {},
1129
+ ...speakKindFields(options)
1121
1130
  });
1122
1131
  warnSpeakControlUnavailable(sessionId);
1123
1132
  return handle({ requestId, status: "unsupported", playedMs: 0 });
@@ -1149,7 +1158,8 @@ function speak(sessionId, text, options) {
1149
1158
  requestId,
1150
1159
  ...options?.interruptible === false ? { interruptible: false } : {},
1151
1160
  ...turnId ? { turnId } : {},
1152
- ...inReplyTo ? { inReplyTo } : {}
1161
+ ...inReplyTo ? { inReplyTo } : {},
1162
+ ...speakKindFields(options)
1153
1163
  });
1154
1164
  return {
1155
1165
  requestId,
@@ -1083,6 +1083,14 @@ function buildIdleEnv(sessionId) {
1083
1083
  ...process.env.IDLE_TIMEOUT_SEC ? { IDLE_TIMEOUT_SEC: process.env.IDLE_TIMEOUT_SEC } : {}
1084
1084
  };
1085
1085
  }
1086
+ function speakKindFields(options) {
1087
+ if (options?.kind !== "filler")
1088
+ return {};
1089
+ return {
1090
+ kind: "filler",
1091
+ ...options.fillerKind ? { fillerKind: options.fillerKind } : {}
1092
+ };
1093
+ }
1086
1094
  function speakControlAvailableFor(sessionId) {
1087
1095
  return speakControlAvailableBySessionId.get(sessionId) ?? false;
1088
1096
  }
@@ -1120,7 +1128,8 @@ function speak(sessionId, text, options) {
1120
1128
  type: "speak",
1121
1129
  sessionId,
1122
1130
  text,
1123
- ...options?.interruptible === false ? { interruptible: false } : {}
1131
+ ...options?.interruptible === false ? { interruptible: false } : {},
1132
+ ...speakKindFields(options)
1124
1133
  });
1125
1134
  warnSpeakControlUnavailable(sessionId);
1126
1135
  return handle({ requestId, status: "unsupported", playedMs: 0 });
@@ -1152,7 +1161,8 @@ function speak(sessionId, text, options) {
1152
1161
  requestId,
1153
1162
  ...options?.interruptible === false ? { interruptible: false } : {},
1154
1163
  ...turnId ? { turnId } : {},
1155
- ...inReplyTo ? { inReplyTo } : {}
1164
+ ...inReplyTo ? { inReplyTo } : {},
1165
+ ...speakKindFields(options)
1156
1166
  });
1157
1167
  return {
1158
1168
  requestId,
package/eject/llm/loop.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Copied from @voicethere/agent 0.23.2. Package updates no longer change this file.
1
+ // Copied from @voicethere/agent 0.25.0. Package updates no longer change this file.
2
2
  import { randomUUID } from "node:crypto";
3
3
  import {
4
4
  type AgentHandlers,
@@ -411,7 +411,11 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
411
411
  }
412
412
  if (
413
413
  linksRequireToolSource &&
414
- !t.toolResults.some((r) => r.includes(link.url))
414
+ !t.toolResults.some(
415
+ (r) =>
416
+ r.includes(link.url) ||
417
+ (link.sourceText !== undefined && r.includes(link.sourceText)),
418
+ )
415
419
  ) {
416
420
  t.linksDropped += 1;
417
421
  return;
@@ -444,16 +448,33 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
444
448
  }
445
449
  }
446
450
 
451
+ /**
452
+ * The one place where a filler reaches the client as text. Fillers are not
453
+ * reply text: never `assistant_delta`, never in `chat_reply`, never in history.
454
+ */
455
+ function sendFillerMessage(
456
+ s: SessionState,
457
+ turnId: string,
458
+ text: string,
459
+ ): void {
460
+ sendToClient(s.sessionId, { type: "assistant_filler", turnId, text });
461
+ }
462
+
463
+ /** Speak options for a filler; replies carry no `kind`. */
447
464
  function speakAnnouncement(
448
465
  s: SessionState,
449
466
  turnId: string,
450
467
  text: string,
451
468
  interruptible: boolean,
469
+ fillerKind?: FillerKind,
452
470
  ): SpeakHandle {
471
+ const opts = fillerKind
472
+ ? { turnId, kind: "filler" as const, fillerKind }
473
+ : { turnId };
453
474
  if (interruptible) {
454
- return speak(s.sessionId, text, { turnId });
475
+ return speak(s.sessionId, text, opts);
455
476
  }
456
- const h = announce(s.sessionId, text, { turnId });
477
+ const h = announce(s.sessionId, text, opts);
457
478
  trackAnnouncement(s, h.done);
458
479
  return h;
459
480
  }
@@ -536,7 +557,8 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
536
557
  if (kind === "thinking") t.thinkingSpoken = true;
537
558
  if (kind === "toolCall") t.toolCallSpoken = true;
538
559
  if (kind === "toolWait") t.toolWaitSpoken += 1;
539
- speakAnnouncement(s, t.turnId, text, fillersInterruptible);
560
+ speakAnnouncement(s, t.turnId, text, fillersInterruptible, kind);
561
+ sendFillerMessage(s, t.turnId, text);
540
562
  return undefined;
541
563
  }
542
564
 
@@ -1208,7 +1230,9 @@ export function createLlmAgent(opts: CreateLlmAgentOptions): AgentHandlers {
1208
1230
  t.turnId,
1209
1231
  fillerLegacy.text,
1210
1232
  fillerLegacy.interruptible ?? D.fillerInterruptible,
1233
+ "toolWait",
1211
1234
  );
1235
+ sendFillerMessage(s, t.turnId, fillerLegacy.text);
1212
1236
  }, fillerLegacy.afterMs ?? D.fillerAfterMs);
1213
1237
  }
1214
1238
  let results: LlmToolResult[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voicethere/agent",
3
- "version": "0.23.2",
3
+ "version": "0.25.0",
4
4
  "description": "VoiceThere customer agent SDK — IPC types and runtime helpers for sandboxed child bundles",
5
5
  "type": "module",
6
6
  "exports": {
@@ -34,7 +34,9 @@ The `fillers` block in `voicethere.llm.json` lists short sentences the agent spe
34
34
  - `toolWait`: a tool round is still running `afterMs` (1000 to 30000, default 4000) after it started. Once per tool round, twice per turn.
35
35
  - At most 3 fillers per turn. Two fillers never play back to back unless the reply spoke in between or `afterMs` passed. Phrases are picked at random and never repeat the previous filler of the session. Each list takes up to 20 phrases.
36
36
  - Callers can cut a filler by speaking (`interruptible`, default true). If the answer arrives while a filler plays, the answer follows it.
37
- - Fillers are speech only. They do not appear in the conversation the model sees or in chat text.
37
+ - Fillers are not part of the conversation the model sees (`ConversationHistory`), so the model does not copy them, and they never appear in `assistant_delta`, `assistant_done` or `chat_reply` text.
38
+ - Each filler that is spoken also reaches the client once as `{ "type": "assistant_filler", "turnId", "text" }`, with the `turnId` of the turn it belongs to, so a chat UI can show it as its own line before the reply. A filler that is not spoken (typed chat with `speakChatReplies` off, a limit reached) sends nothing.
39
+ - The speak request for a filler carries `kind: "filler"` and `fillerKind` (`"thinking"`, `"toolCall"` or `"toolWait"`), so a runner can tag the stored utterance. Replies carry neither. Runners that predate the options ignore them.
38
40
  - `tools.filler` (a single text) is deprecated. It still works when `toolCall` and `toolWait` have no phrases; otherwise `fillers` wins and a warning is logged.
39
41
 
40
42
  ## Speech coalescing
@@ -43,7 +45,7 @@ The `fillers` block in `voicethere.llm.json` lists short sentences the agent spe
43
45
 
44
46
  ## Client messages for voice replies
45
47
 
46
- A voice reply also reaches the client as text. Each spoken sentence arrives as `{ "type": "assistant_delta", "turnId", "text", "spoken": true }`, and the turn ends with one `{ "type": "assistant_done", "turnId", "text", "spoken": true, "status" }`. `status` is `completed`, `failed`, `interrupted` or `cancelled`, and `text` holds the sentences delivered so far. When the runner sends an utterance id for the caller's final (`SpeechContext.utteranceId` in `onUserSpeechFinal`), both messages also carry `inReplyTo`, the caller utterance the reply answers. Render one line per `turnId` and reveal it as the speech plays. Typed (chat) turns keep sending `assistant_delta`, `assistant_done` and `chat_reply` without `spoken`. Fillers are never sent as text.
48
+ A voice reply also reaches the client as text. Each spoken sentence arrives as `{ "type": "assistant_delta", "turnId", "text", "spoken": true }`, and the turn ends with one `{ "type": "assistant_done", "turnId", "text", "spoken": true, "status" }`. `status` is `completed`, `failed`, `interrupted` or `cancelled`, and `text` holds the sentences delivered so far. When the runner sends an utterance id for the caller's final (`SpeechContext.utteranceId` in `onUserSpeechFinal`), both messages also carry `inReplyTo`, the caller utterance the reply answers. Render one line per `turnId` and reveal it as the speech plays. Typed (chat) turns keep sending `assistant_delta`, `assistant_done` and `chat_reply` without `spoken`. Fillers are never part of this reply text; see `assistant_filler` below.
47
49
 
48
50
  ## Always search first
49
51