@voicethere/agent 0.23.1 → 0.24.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.
Files changed (32) hide show
  1. package/README.md +2 -0
  2. package/dist/agent.js +29 -1
  3. package/dist/llm/agent/create-llm-agent.d.ts.map +1 -1
  4. package/dist/llm/agent/create-llm-agent.js +2 -1
  5. package/dist/llm/agent/create-llm-agent.js.map +1 -1
  6. package/dist/llm/agent/link-extractor.d.ts +21 -3
  7. package/dist/llm/agent/link-extractor.d.ts.map +1 -1
  8. package/dist/llm/agent/link-extractor.js +139 -15
  9. package/dist/llm/agent/link-extractor.js.map +1 -1
  10. package/dist/runtime.d.ts +8 -0
  11. package/dist/runtime.d.ts.map +1 -1
  12. package/dist/runtime.js +40 -3
  13. package/dist/runtime.js.map +1 -1
  14. package/dist/sandbox/loader-entry.js +21 -1
  15. package/dist/templates/echo/agent.js +29 -1
  16. package/dist/templates/echo-dc/agent.js +29 -1
  17. package/dist/templates/game-sync/agent.js +29 -1
  18. package/dist/templates/language-switch/agent.js +29 -1
  19. package/dist/templates/llm-agent/agent.js +151 -15
  20. package/dist/templates/llm-docs-rag/agent.js +151 -15
  21. package/dist/templates/llm-mcp-service/agent.js +151 -15
  22. package/dist/templates/positional-tts/agent.js +29 -1
  23. package/dist/templates/recording-consent/agent.js +29 -1
  24. package/dist/templates/spatial-showcase/agent.js +29 -1
  25. package/dist/templates/voice-showcase/agent.js +29 -1
  26. package/dist/templates/voice-starter/agent.js +29 -1
  27. package/dist/templates/webhooks/agent.js +29 -1
  28. package/dist/templates/webhooks-redis/agent.js +29 -1
  29. package/dist/templates/world-sync/agent.js +29 -1
  30. package/dist/templates/world-sync-binary/agent.js +29 -1
  31. package/eject/llm/loop.ts +6 -2
  32. package/package.json +1 -1
@@ -31205,6 +31205,34 @@ function isVoicethereAgentChild() {
31205
31205
  }
31206
31206
  var sessionExecutionContext = new AsyncLocalStorage();
31207
31207
  var agentLogSessionContext = new AsyncLocalStorage();
31208
+ var CURRENT_SESSION_ID_GETTER_KEY = Symbol.for("voicethere.agent.currentSessionId");
31209
+ function currentHandlerSessionId() {
31210
+ const id = sessionExecutionContext.getStore()?.sessionId ?? agentLogSessionContext.getStore();
31211
+ return id ? id : void 0;
31212
+ }
31213
+ var previousSessionIdGetter;
31214
+ function stringOrUndefined(value) {
31215
+ return typeof value === "string" && value ? value : void 0;
31216
+ }
31217
+ function currentSessionIdGetter() {
31218
+ const own2 = currentHandlerSessionId();
31219
+ if (own2)
31220
+ return own2;
31221
+ try {
31222
+ return stringOrUndefined(previousSessionIdGetter?.());
31223
+ } catch {
31224
+ return void 0;
31225
+ }
31226
+ }
31227
+ function installCurrentSessionIdGetter() {
31228
+ const g = globalThis;
31229
+ const previous = g[CURRENT_SESSION_ID_GETTER_KEY];
31230
+ if (previous === currentSessionIdGetter)
31231
+ return;
31232
+ g[CURRENT_SESSION_ID_GETTER_KEY] = currentSessionIdGetter;
31233
+ previousSessionIdGetter = typeof previous === "function" ? previous : void 0;
31234
+ }
31235
+ installCurrentSessionIdGetter();
31208
31236
  var inboundQueueAuthority = null;
31209
31237
  var childUnhandledRejectionGuardInstalled = false;
31210
31238
  function normalizeRejectionReason(reason) {
@@ -31858,7 +31886,7 @@ function sanitizeAgentLogFields(fields) {
31858
31886
  }
31859
31887
  }
31860
31888
  function buildAgentLogPayload(level, message, fields, sessionId) {
31861
- const resolvedSessionId = sessionId ?? sessionExecutionContext.getStore()?.sessionId ?? agentLogSessionContext.getStore();
31889
+ const resolvedSessionId = sessionId ?? currentHandlerSessionId();
31862
31890
  const sanitizedFields = fields ? sanitizeAgentLogFields(fields) : void 0;
31863
31891
  return {
31864
31892
  type: "log",
@@ -34962,6 +34990,24 @@ var ConversationHistory = class {
34962
34990
 
34963
34991
  // dist/llm/agent/link-extractor.js
34964
34992
  var LINK_MARK = "\uE000";
34993
+ var BARE_DOMAIN_TLDS = /* @__PURE__ */ new Set([
34994
+ "com",
34995
+ "org",
34996
+ "net",
34997
+ "dev",
34998
+ "io",
34999
+ "ai",
35000
+ "app",
35001
+ "co",
35002
+ "cloud",
35003
+ "eu",
35004
+ "de",
35005
+ "uk",
35006
+ "us"
35007
+ ]);
35008
+ var DOMAIN_RE = /^((?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+([a-z]{2,63}))(\/[^\s]*)?/i;
35009
+ var DOMAIN_PREFIX_RE = /^[a-z0-9][a-z0-9.-]*$/i;
35010
+ var ALNUM_RE = /[\p{L}\p{N}]/u;
34965
35011
  var SCHEMES = ["https://", "http://"];
34966
35012
  var START_RE = /\[|https?:\/\//i;
34967
35013
  var BARE_RE = /^https?:\/\/\S*/i;
@@ -35027,6 +35073,85 @@ function hasHost(url2) {
35027
35073
  var LinkExtractor = class {
35028
35074
  buf = "";
35029
35075
  links = [];
35076
+ /**
35077
+ * The emitted tail of the current word when it is made only of host
35078
+ * characters (`[a-z0-9.-]`), and the character before that word. A word
35079
+ * such as "voicethere" is spoken before ".dev" arrives; the lead lets the
35080
+ * domain still be recognised, so streaming gives the same result as one push.
35081
+ */
35082
+ lead = "";
35083
+ leadPrev = "";
35084
+ consume(n) {
35085
+ const taken = this.buf.slice(0, n);
35086
+ this.buf = this.buf.slice(n);
35087
+ const s = this.lead + taken;
35088
+ let k = -1;
35089
+ for (let j = s.length - 1; j >= 0; j -= 1) {
35090
+ if (!/[a-z0-9.-]/i.test(s[j])) {
35091
+ k = j;
35092
+ break;
35093
+ }
35094
+ }
35095
+ if (k >= 0) {
35096
+ this.leadPrev = s[k];
35097
+ this.lead = s.slice(k + 1);
35098
+ } else {
35099
+ this.lead = s;
35100
+ }
35101
+ if (this.lead.length > MAX_HOLD) {
35102
+ this.lead = "";
35103
+ this.leadPrev = "x";
35104
+ }
35105
+ return taken;
35106
+ }
35107
+ /** After a link: the text now ends in a mark, so no word is open. */
35108
+ closeWord() {
35109
+ this.lead = "";
35110
+ this.leadPrev = LINK_MARK;
35111
+ }
35112
+ /** The first bare domain (or possible start of one at the tail) in the buffer. */
35113
+ scanDomain(final) {
35114
+ const off = this.lead.length;
35115
+ const ctx = this.lead + this.buf;
35116
+ for (let i = 0; i < ctx.length; i += 1) {
35117
+ if (!/[a-z0-9]/i.test(ctx[i]))
35118
+ continue;
35119
+ const before = i === 0 ? this.leadPrev : ctx[i - 1];
35120
+ if (!(before === "" || /[\s("']/.test(before)))
35121
+ continue;
35122
+ const rest = ctx.slice(i);
35123
+ const m = DOMAIN_RE.exec(rest);
35124
+ if (!m) {
35125
+ if (!final && rest.length <= MAX_HOLD && rest.includes(".") && DOMAIN_PREFIX_RE.test(rest)) {
35126
+ return { index: i, hold: true, off };
35127
+ }
35128
+ continue;
35129
+ }
35130
+ const host = m[1];
35131
+ const path2 = m[3] ?? "";
35132
+ const end = m[0].length;
35133
+ if (!final && end === rest.length && end <= MAX_HOLD) {
35134
+ return { index: i, hold: true, off };
35135
+ }
35136
+ const next = rest[end] ?? "";
35137
+ if (!final && !path2 && next === "." && end + 1 === rest.length) {
35138
+ return { index: i, hold: true, off };
35139
+ }
35140
+ if (!BARE_DOMAIN_TLDS.has(m[2].toLowerCase()))
35141
+ continue;
35142
+ if (!path2) {
35143
+ if (next && /[\p{L}\p{N}@_-]/u.test(next))
35144
+ continue;
35145
+ if (next === "." && ALNUM_RE.test(rest[end + 1] ?? ""))
35146
+ continue;
35147
+ }
35148
+ const { url: url2 } = trimUrl(host + path2);
35149
+ if (i < off && host.length < off - i)
35150
+ continue;
35151
+ return { index: i, hold: false, off, host, url: url2 };
35152
+ }
35153
+ return void 0;
35154
+ }
35030
35155
  push(delta) {
35031
35156
  this.buf += delta;
35032
35157
  return this.drain(false);
@@ -35044,54 +35169,65 @@ var LinkExtractor = class {
35044
35169
  this.links = [];
35045
35170
  return all;
35046
35171
  }
35047
- add(url2, label) {
35172
+ add(url2, label, sourceText) {
35048
35173
  const trimmed = label?.trim();
35049
35174
  this.links.push({
35050
35175
  url: url2,
35051
35176
  ...trimmed ? { label: trimmed } : {},
35052
- secure: /^https:\/\//i.test(url2)
35177
+ secure: /^https:\/\//i.test(url2),
35178
+ ...sourceText ? { sourceText } : {}
35053
35179
  });
35054
35180
  }
35055
35181
  drain(final) {
35056
35182
  let out = "";
35057
35183
  for (; ; ) {
35058
35184
  const m = START_RE.exec(this.buf);
35185
+ const d = this.scanDomain(final);
35186
+ if (d && (!m || Math.max(0, d.index - d.off) < m.index)) {
35187
+ const spoken = Math.max(0, d.off - d.index);
35188
+ out += this.consume(Math.max(0, d.index - d.off));
35189
+ if (d.hold)
35190
+ return out;
35191
+ this.add("https://" + d.url, d.host, d.url);
35192
+ this.consume(d.url.length - spoken);
35193
+ out += d.host.slice(spoken) + LINK_MARK;
35194
+ this.closeWord();
35195
+ continue;
35196
+ }
35059
35197
  if (!m) {
35060
35198
  const hold = final ? 0 : partialSchemeSuffix(this.buf);
35061
- out += this.buf.slice(0, this.buf.length - hold);
35062
- this.buf = this.buf.slice(this.buf.length - hold);
35199
+ out += this.consume(this.buf.length - hold);
35063
35200
  return out;
35064
35201
  }
35065
- out += this.buf.slice(0, m.index);
35066
- this.buf = this.buf.slice(m.index);
35202
+ out += this.consume(m.index);
35067
35203
  if (this.buf[0] === "[") {
35068
35204
  const md = MARKDOWN_RE.exec(this.buf);
35069
35205
  if (md && hasHost(md[2])) {
35070
35206
  this.add(md[2], md[1]);
35071
35207
  out += `${md[1]}${LINK_MARK}`;
35072
- this.buf = this.buf.slice(md[0].length);
35208
+ this.consume(md[0].length);
35209
+ this.closeWord();
35073
35210
  continue;
35074
35211
  }
35075
35212
  if (!final && this.buf.length <= MAX_HOLD && MARKDOWN_PREFIX_RE.test(this.buf)) {
35076
35213
  return out;
35077
35214
  }
35078
- out += "[";
35079
- this.buf = this.buf.slice(1);
35215
+ out += this.consume(1);
35080
35216
  continue;
35081
35217
  }
35082
35218
  const bare = BARE_RE.exec(this.buf);
35083
35219
  if (!final && bare[0].length === this.buf.length && this.buf.length <= MAX_HOLD) {
35084
35220
  return out;
35085
35221
  }
35086
- const { url: url2, rest } = trimUrl(bare[0]);
35222
+ const { url: url2 } = trimUrl(bare[0]);
35087
35223
  if (!hasHost(url2)) {
35088
- out += bare[0];
35089
- this.buf = this.buf.slice(bare[0].length);
35224
+ out += this.consume(bare[0].length);
35090
35225
  continue;
35091
35226
  }
35092
35227
  this.add(url2);
35093
35228
  out += LINK_MARK;
35094
- this.buf = rest + this.buf.slice(bare[0].length);
35229
+ this.consume(url2.length);
35230
+ this.closeWord();
35095
35231
  }
35096
35232
  }
35097
35233
  };
@@ -35423,7 +35559,7 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
35423
35559
  t.linksDropped += 1;
35424
35560
  return;
35425
35561
  }
35426
- if (linksRequireToolSource && !t.toolResults.some((r) => r.includes(link.url))) {
35562
+ if (linksRequireToolSource && !t.toolResults.some((r) => r.includes(link.url) || link.sourceText !== void 0 && r.includes(link.sourceText))) {
35427
35563
  t.linksDropped += 1;
35428
35564
  return;
35429
35565
  }
@@ -577,6 +577,34 @@ function isVoicethereAgentChild() {
577
577
  }
578
578
  var sessionExecutionContext = new AsyncLocalStorage();
579
579
  var agentLogSessionContext = new AsyncLocalStorage();
580
+ var CURRENT_SESSION_ID_GETTER_KEY = Symbol.for("voicethere.agent.currentSessionId");
581
+ function currentHandlerSessionId() {
582
+ const id = sessionExecutionContext.getStore()?.sessionId ?? agentLogSessionContext.getStore();
583
+ return id ? id : void 0;
584
+ }
585
+ var previousSessionIdGetter;
586
+ function stringOrUndefined(value) {
587
+ return typeof value === "string" && value ? value : void 0;
588
+ }
589
+ function currentSessionIdGetter() {
590
+ const own = currentHandlerSessionId();
591
+ if (own)
592
+ return own;
593
+ try {
594
+ return stringOrUndefined(previousSessionIdGetter?.());
595
+ } catch {
596
+ return void 0;
597
+ }
598
+ }
599
+ function installCurrentSessionIdGetter() {
600
+ const g = globalThis;
601
+ const previous = g[CURRENT_SESSION_ID_GETTER_KEY];
602
+ if (previous === currentSessionIdGetter)
603
+ return;
604
+ g[CURRENT_SESSION_ID_GETTER_KEY] = currentSessionIdGetter;
605
+ previousSessionIdGetter = typeof previous === "function" ? previous : void 0;
606
+ }
607
+ installCurrentSessionIdGetter();
580
608
  var inboundQueueAuthority = null;
581
609
  var childUnhandledRejectionGuardInstalled = false;
582
610
  function normalizeRejectionReason(reason) {
@@ -1222,7 +1250,7 @@ function sanitizeAgentLogFields(fields) {
1222
1250
  }
1223
1251
  }
1224
1252
  function buildAgentLogPayload(level, message, fields, sessionId) {
1225
- const resolvedSessionId = sessionId ?? sessionExecutionContext.getStore()?.sessionId ?? agentLogSessionContext.getStore();
1253
+ const resolvedSessionId = sessionId ?? currentHandlerSessionId();
1226
1254
  const sanitizedFields = fields ? sanitizeAgentLogFields(fields) : void 0;
1227
1255
  return {
1228
1256
  type: "log",
@@ -562,6 +562,34 @@ function isVoicethereAgentChild() {
562
562
  }
563
563
  var sessionExecutionContext = new AsyncLocalStorage();
564
564
  var agentLogSessionContext = new AsyncLocalStorage();
565
+ var CURRENT_SESSION_ID_GETTER_KEY = Symbol.for("voicethere.agent.currentSessionId");
566
+ function currentHandlerSessionId() {
567
+ const id = sessionExecutionContext.getStore()?.sessionId ?? agentLogSessionContext.getStore();
568
+ return id ? id : void 0;
569
+ }
570
+ var previousSessionIdGetter;
571
+ function stringOrUndefined(value) {
572
+ return typeof value === "string" && value ? value : void 0;
573
+ }
574
+ function currentSessionIdGetter() {
575
+ const own = currentHandlerSessionId();
576
+ if (own)
577
+ return own;
578
+ try {
579
+ return stringOrUndefined(previousSessionIdGetter?.());
580
+ } catch {
581
+ return void 0;
582
+ }
583
+ }
584
+ function installCurrentSessionIdGetter() {
585
+ const g = globalThis;
586
+ const previous = g[CURRENT_SESSION_ID_GETTER_KEY];
587
+ if (previous === currentSessionIdGetter)
588
+ return;
589
+ g[CURRENT_SESSION_ID_GETTER_KEY] = currentSessionIdGetter;
590
+ previousSessionIdGetter = typeof previous === "function" ? previous : void 0;
591
+ }
592
+ installCurrentSessionIdGetter();
565
593
  var inboundQueueAuthority = null;
566
594
  var childUnhandledRejectionGuardInstalled = false;
567
595
  function normalizeRejectionReason(reason) {
@@ -1213,7 +1241,7 @@ function sanitizeAgentLogFields(fields) {
1213
1241
  }
1214
1242
  }
1215
1243
  function buildAgentLogPayload(level, message, fields, sessionId) {
1216
- const resolvedSessionId = sessionId ?? sessionExecutionContext.getStore()?.sessionId ?? agentLogSessionContext.getStore();
1244
+ const resolvedSessionId = sessionId ?? currentHandlerSessionId();
1217
1245
  const sanitizedFields = fields ? sanitizeAgentLogFields(fields) : void 0;
1218
1246
  return {
1219
1247
  type: "log",
@@ -592,6 +592,34 @@ function isVoicethereAgentChild() {
592
592
  }
593
593
  var sessionExecutionContext = new AsyncLocalStorage();
594
594
  var agentLogSessionContext = new AsyncLocalStorage();
595
+ var CURRENT_SESSION_ID_GETTER_KEY = Symbol.for("voicethere.agent.currentSessionId");
596
+ function currentHandlerSessionId() {
597
+ const id = sessionExecutionContext.getStore()?.sessionId ?? agentLogSessionContext.getStore();
598
+ return id ? id : void 0;
599
+ }
600
+ var previousSessionIdGetter;
601
+ function stringOrUndefined(value) {
602
+ return typeof value === "string" && value ? value : void 0;
603
+ }
604
+ function currentSessionIdGetter() {
605
+ const own = currentHandlerSessionId();
606
+ if (own)
607
+ return own;
608
+ try {
609
+ return stringOrUndefined(previousSessionIdGetter?.());
610
+ } catch {
611
+ return void 0;
612
+ }
613
+ }
614
+ function installCurrentSessionIdGetter() {
615
+ const g = globalThis;
616
+ const previous = g[CURRENT_SESSION_ID_GETTER_KEY];
617
+ if (previous === currentSessionIdGetter)
618
+ return;
619
+ g[CURRENT_SESSION_ID_GETTER_KEY] = currentSessionIdGetter;
620
+ previousSessionIdGetter = typeof previous === "function" ? previous : void 0;
621
+ }
622
+ installCurrentSessionIdGetter();
595
623
  var inboundQueueAuthority = null;
596
624
  var childUnhandledRejectionGuardInstalled = false;
597
625
  function normalizeRejectionReason(reason) {
@@ -1457,7 +1485,7 @@ function sanitizeAgentLogFields(fields) {
1457
1485
  }
1458
1486
  }
1459
1487
  function buildAgentLogPayload(level, message, fields, sessionId) {
1460
- const resolvedSessionId = sessionId ?? sessionExecutionContext.getStore()?.sessionId ?? agentLogSessionContext.getStore();
1488
+ const resolvedSessionId = sessionId ?? currentHandlerSessionId();
1461
1489
  const sanitizedFields = fields ? sanitizeAgentLogFields(fields) : void 0;
1462
1490
  return {
1463
1491
  type: "log",
@@ -561,6 +561,34 @@ function isVoicethereAgentChild() {
561
561
  }
562
562
  var sessionExecutionContext = new AsyncLocalStorage();
563
563
  var agentLogSessionContext = new AsyncLocalStorage();
564
+ var CURRENT_SESSION_ID_GETTER_KEY = Symbol.for("voicethere.agent.currentSessionId");
565
+ function currentHandlerSessionId() {
566
+ const id = sessionExecutionContext.getStore()?.sessionId ?? agentLogSessionContext.getStore();
567
+ return id ? id : void 0;
568
+ }
569
+ var previousSessionIdGetter;
570
+ function stringOrUndefined(value) {
571
+ return typeof value === "string" && value ? value : void 0;
572
+ }
573
+ function currentSessionIdGetter() {
574
+ const own = currentHandlerSessionId();
575
+ if (own)
576
+ return own;
577
+ try {
578
+ return stringOrUndefined(previousSessionIdGetter?.());
579
+ } catch {
580
+ return void 0;
581
+ }
582
+ }
583
+ function installCurrentSessionIdGetter() {
584
+ const g = globalThis;
585
+ const previous = g[CURRENT_SESSION_ID_GETTER_KEY];
586
+ if (previous === currentSessionIdGetter)
587
+ return;
588
+ g[CURRENT_SESSION_ID_GETTER_KEY] = currentSessionIdGetter;
589
+ previousSessionIdGetter = typeof previous === "function" ? previous : void 0;
590
+ }
591
+ installCurrentSessionIdGetter();
564
592
  var inboundQueueAuthority = null;
565
593
  var childUnhandledRejectionGuardInstalled = false;
566
594
  function normalizeRejectionReason(reason) {
@@ -1190,7 +1218,7 @@ function sanitizeAgentLogFields(fields) {
1190
1218
  }
1191
1219
  }
1192
1220
  function buildAgentLogPayload(level, message, fields, sessionId) {
1193
- const resolvedSessionId = sessionId ?? sessionExecutionContext.getStore()?.sessionId ?? agentLogSessionContext.getStore();
1221
+ const resolvedSessionId = sessionId ?? currentHandlerSessionId();
1194
1222
  const sanitizedFields = fields ? sanitizeAgentLogFields(fields) : void 0;
1195
1223
  return {
1196
1224
  type: "log",
@@ -561,6 +561,34 @@ function isVoicethereAgentChild() {
561
561
  }
562
562
  var sessionExecutionContext = new AsyncLocalStorage();
563
563
  var agentLogSessionContext = new AsyncLocalStorage();
564
+ var CURRENT_SESSION_ID_GETTER_KEY = Symbol.for("voicethere.agent.currentSessionId");
565
+ function currentHandlerSessionId() {
566
+ const id = sessionExecutionContext.getStore()?.sessionId ?? agentLogSessionContext.getStore();
567
+ return id ? id : void 0;
568
+ }
569
+ var previousSessionIdGetter;
570
+ function stringOrUndefined(value) {
571
+ return typeof value === "string" && value ? value : void 0;
572
+ }
573
+ function currentSessionIdGetter() {
574
+ const own = currentHandlerSessionId();
575
+ if (own)
576
+ return own;
577
+ try {
578
+ return stringOrUndefined(previousSessionIdGetter?.());
579
+ } catch {
580
+ return void 0;
581
+ }
582
+ }
583
+ function installCurrentSessionIdGetter() {
584
+ const g = globalThis;
585
+ const previous = g[CURRENT_SESSION_ID_GETTER_KEY];
586
+ if (previous === currentSessionIdGetter)
587
+ return;
588
+ g[CURRENT_SESSION_ID_GETTER_KEY] = currentSessionIdGetter;
589
+ previousSessionIdGetter = typeof previous === "function" ? previous : void 0;
590
+ }
591
+ installCurrentSessionIdGetter();
564
592
  var inboundQueueAuthority = null;
565
593
  var childUnhandledRejectionGuardInstalled = false;
566
594
  function normalizeRejectionReason(reason) {
@@ -1174,7 +1202,7 @@ function sanitizeAgentLogFields(fields) {
1174
1202
  }
1175
1203
  }
1176
1204
  function buildAgentLogPayload(level, message, fields, sessionId) {
1177
- const resolvedSessionId = sessionId ?? sessionExecutionContext.getStore()?.sessionId ?? agentLogSessionContext.getStore();
1205
+ const resolvedSessionId = sessionId ?? currentHandlerSessionId();
1178
1206
  const sanitizedFields = fields ? sanitizeAgentLogFields(fields) : void 0;
1179
1207
  return {
1180
1208
  type: "log",
@@ -564,6 +564,34 @@ function isVoicethereAgentChild() {
564
564
  }
565
565
  var sessionExecutionContext = new AsyncLocalStorage();
566
566
  var agentLogSessionContext = new AsyncLocalStorage();
567
+ var CURRENT_SESSION_ID_GETTER_KEY = Symbol.for("voicethere.agent.currentSessionId");
568
+ function currentHandlerSessionId() {
569
+ const id = sessionExecutionContext.getStore()?.sessionId ?? agentLogSessionContext.getStore();
570
+ return id ? id : void 0;
571
+ }
572
+ var previousSessionIdGetter;
573
+ function stringOrUndefined(value) {
574
+ return typeof value === "string" && value ? value : void 0;
575
+ }
576
+ function currentSessionIdGetter() {
577
+ const own = currentHandlerSessionId();
578
+ if (own)
579
+ return own;
580
+ try {
581
+ return stringOrUndefined(previousSessionIdGetter?.());
582
+ } catch {
583
+ return void 0;
584
+ }
585
+ }
586
+ function installCurrentSessionIdGetter() {
587
+ const g = globalThis;
588
+ const previous = g[CURRENT_SESSION_ID_GETTER_KEY];
589
+ if (previous === currentSessionIdGetter)
590
+ return;
591
+ g[CURRENT_SESSION_ID_GETTER_KEY] = currentSessionIdGetter;
592
+ previousSessionIdGetter = typeof previous === "function" ? previous : void 0;
593
+ }
594
+ installCurrentSessionIdGetter();
567
595
  var inboundQueueAuthority = null;
568
596
  var childUnhandledRejectionGuardInstalled = false;
569
597
  function normalizeRejectionReason(reason) {
@@ -1185,7 +1213,7 @@ function sanitizeAgentLogFields(fields) {
1185
1213
  }
1186
1214
  }
1187
1215
  function buildAgentLogPayload(level, message, fields, sessionId) {
1188
- const resolvedSessionId = sessionId ?? sessionExecutionContext.getStore()?.sessionId ?? agentLogSessionContext.getStore();
1216
+ const resolvedSessionId = sessionId ?? currentHandlerSessionId();
1189
1217
  const sanitizedFields = fields ? sanitizeAgentLogFields(fields) : void 0;
1190
1218
  return {
1191
1219
  type: "log",
@@ -11312,6 +11312,34 @@ function clearPendingConversationHistoryAcksForSession(sessionId, reason) {
11312
11312
  }
11313
11313
  var sessionExecutionContext = new AsyncLocalStorage();
11314
11314
  var agentLogSessionContext = new AsyncLocalStorage();
11315
+ var CURRENT_SESSION_ID_GETTER_KEY = Symbol.for("voicethere.agent.currentSessionId");
11316
+ function currentHandlerSessionId() {
11317
+ const id = sessionExecutionContext.getStore()?.sessionId ?? agentLogSessionContext.getStore();
11318
+ return id ? id : void 0;
11319
+ }
11320
+ var previousSessionIdGetter;
11321
+ function stringOrUndefined(value) {
11322
+ return typeof value === "string" && value ? value : void 0;
11323
+ }
11324
+ function currentSessionIdGetter() {
11325
+ const own = currentHandlerSessionId();
11326
+ if (own)
11327
+ return own;
11328
+ try {
11329
+ return stringOrUndefined(previousSessionIdGetter?.());
11330
+ } catch {
11331
+ return void 0;
11332
+ }
11333
+ }
11334
+ function installCurrentSessionIdGetter() {
11335
+ const g = globalThis;
11336
+ const previous = g[CURRENT_SESSION_ID_GETTER_KEY];
11337
+ if (previous === currentSessionIdGetter)
11338
+ return;
11339
+ g[CURRENT_SESSION_ID_GETTER_KEY] = currentSessionIdGetter;
11340
+ previousSessionIdGetter = typeof previous === "function" ? previous : void 0;
11341
+ }
11342
+ installCurrentSessionIdGetter();
11315
11343
  var inboundQueueAuthority = null;
11316
11344
  var childUnhandledRejectionGuardInstalled = false;
11317
11345
  function normalizeRejectionReason(reason) {
@@ -11842,7 +11870,7 @@ function sanitizeAgentLogFields(fields) {
11842
11870
  }
11843
11871
  }
11844
11872
  function buildAgentLogPayload(level, message, fields, sessionId) {
11845
- const resolvedSessionId = sessionId ?? sessionExecutionContext.getStore()?.sessionId ?? agentLogSessionContext.getStore();
11873
+ const resolvedSessionId = sessionId ?? currentHandlerSessionId();
11846
11874
  const sanitizedFields = fields ? sanitizeAgentLogFields(fields) : void 0;
11847
11875
  return {
11848
11876
  type: "log",
@@ -557,6 +557,34 @@ function clearPendingConversationHistoryAcksForSession(sessionId, reason) {
557
557
  }
558
558
  var sessionExecutionContext = new AsyncLocalStorage();
559
559
  var agentLogSessionContext = new AsyncLocalStorage();
560
+ var CURRENT_SESSION_ID_GETTER_KEY = Symbol.for("voicethere.agent.currentSessionId");
561
+ function currentHandlerSessionId() {
562
+ const id = sessionExecutionContext.getStore()?.sessionId ?? agentLogSessionContext.getStore();
563
+ return id ? id : void 0;
564
+ }
565
+ var previousSessionIdGetter;
566
+ function stringOrUndefined(value) {
567
+ return typeof value === "string" && value ? value : void 0;
568
+ }
569
+ function currentSessionIdGetter() {
570
+ const own = currentHandlerSessionId();
571
+ if (own)
572
+ return own;
573
+ try {
574
+ return stringOrUndefined(previousSessionIdGetter?.());
575
+ } catch {
576
+ return void 0;
577
+ }
578
+ }
579
+ function installCurrentSessionIdGetter() {
580
+ const g = globalThis;
581
+ const previous = g[CURRENT_SESSION_ID_GETTER_KEY];
582
+ if (previous === currentSessionIdGetter)
583
+ return;
584
+ g[CURRENT_SESSION_ID_GETTER_KEY] = currentSessionIdGetter;
585
+ previousSessionIdGetter = typeof previous === "function" ? previous : void 0;
586
+ }
587
+ installCurrentSessionIdGetter();
560
588
  var inboundQueueAuthority = null;
561
589
  var childUnhandledRejectionGuardInstalled = false;
562
590
  function normalizeRejectionReason(reason) {
@@ -1082,7 +1110,7 @@ function sanitizeAgentLogFields(fields) {
1082
1110
  }
1083
1111
  }
1084
1112
  function buildAgentLogPayload(level, message, fields, sessionId) {
1085
- const resolvedSessionId = sessionId ?? sessionExecutionContext.getStore()?.sessionId ?? agentLogSessionContext.getStore();
1113
+ const resolvedSessionId = sessionId ?? currentHandlerSessionId();
1086
1114
  const sanitizedFields = fields ? sanitizeAgentLogFields(fields) : void 0;
1087
1115
  return {
1088
1116
  type: "log",
@@ -557,6 +557,34 @@ function clearPendingConversationHistoryAcksForSession(sessionId, reason) {
557
557
  }
558
558
  var sessionExecutionContext = new AsyncLocalStorage();
559
559
  var agentLogSessionContext = new AsyncLocalStorage();
560
+ var CURRENT_SESSION_ID_GETTER_KEY = Symbol.for("voicethere.agent.currentSessionId");
561
+ function currentHandlerSessionId() {
562
+ const id = sessionExecutionContext.getStore()?.sessionId ?? agentLogSessionContext.getStore();
563
+ return id ? id : void 0;
564
+ }
565
+ var previousSessionIdGetter;
566
+ function stringOrUndefined(value) {
567
+ return typeof value === "string" && value ? value : void 0;
568
+ }
569
+ function currentSessionIdGetter() {
570
+ const own = currentHandlerSessionId();
571
+ if (own)
572
+ return own;
573
+ try {
574
+ return stringOrUndefined(previousSessionIdGetter?.());
575
+ } catch {
576
+ return void 0;
577
+ }
578
+ }
579
+ function installCurrentSessionIdGetter() {
580
+ const g = globalThis;
581
+ const previous = g[CURRENT_SESSION_ID_GETTER_KEY];
582
+ if (previous === currentSessionIdGetter)
583
+ return;
584
+ g[CURRENT_SESSION_ID_GETTER_KEY] = currentSessionIdGetter;
585
+ previousSessionIdGetter = typeof previous === "function" ? previous : void 0;
586
+ }
587
+ installCurrentSessionIdGetter();
560
588
  var inboundQueueAuthority = null;
561
589
  var childUnhandledRejectionGuardInstalled = false;
562
590
  function normalizeRejectionReason(reason) {
@@ -1093,7 +1121,7 @@ function sanitizeAgentLogFields(fields) {
1093
1121
  }
1094
1122
  }
1095
1123
  function buildAgentLogPayload(level, message, fields, sessionId) {
1096
- const resolvedSessionId = sessionId ?? sessionExecutionContext.getStore()?.sessionId ?? agentLogSessionContext.getStore();
1124
+ const resolvedSessionId = sessionId ?? currentHandlerSessionId();
1097
1125
  const sanitizedFields = fields ? sanitizeAgentLogFields(fields) : void 0;
1098
1126
  return {
1099
1127
  type: "log",
package/eject/llm/loop.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Copied from @voicethere/agent 0.23.1. Package updates no longer change this file.
1
+ // Copied from @voicethere/agent 0.24.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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voicethere/agent",
3
- "version": "0.23.1",
3
+ "version": "0.24.0",
4
4
  "description": "VoiceThere customer agent SDK — IPC types and runtime helpers for sandboxed child bundles",
5
5
  "type": "module",
6
6
  "exports": {