@voicethere/agent 0.20.1 → 0.22.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.
- package/README.md +1 -1
- package/dist/llm/agent/config.d.ts +51 -0
- package/dist/llm/agent/config.d.ts.map +1 -1
- package/dist/llm/agent/config.js +61 -0
- package/dist/llm/agent/config.js.map +1 -1
- package/dist/llm/agent/create-llm-agent.d.ts.map +1 -1
- package/dist/llm/agent/create-llm-agent.js +109 -4
- package/dist/llm/agent/create-llm-agent.js.map +1 -1
- package/dist/llm/agent/hooks.d.ts +23 -0
- package/dist/llm/agent/hooks.d.ts.map +1 -1
- package/dist/llm/agent/link-extractor.d.ts +43 -0
- package/dist/llm/agent/link-extractor.d.ts.map +1 -0
- package/dist/llm/agent/link-extractor.js +184 -0
- package/dist/llm/agent/link-extractor.js.map +1 -0
- package/dist/llm/anthropic-provider.d.ts.map +1 -1
- package/dist/llm/anthropic-provider.js +3 -0
- package/dist/llm/anthropic-provider.js.map +1 -1
- package/dist/llm/catalog.d.ts.map +1 -1
- package/dist/llm/catalog.js +5 -3
- package/dist/llm/catalog.js.map +1 -1
- package/dist/llm/gemini-provider.d.ts.map +1 -1
- package/dist/llm/gemini-provider.js +10 -1
- package/dist/llm/gemini-provider.js.map +1 -1
- package/dist/llm/index.d.ts +4 -2
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +1 -0
- package/dist/llm/index.js.map +1 -1
- package/dist/llm/openai-provider.d.ts.map +1 -1
- package/dist/llm/openai-provider.js +3 -0
- package/dist/llm/openai-provider.js.map +1 -1
- package/dist/llm/types.d.ts +2 -0
- package/dist/llm/types.d.ts.map +1 -1
- package/dist/llm/types.js.map +1 -1
- package/dist/templates/llm-agent/agent.js +374 -75
- package/dist/templates/llm-docs-rag/agent.js +59923 -0
- package/dist/templates/llm-mcp-service/agent.js +374 -75
- package/dist/templates/registry.d.ts.map +1 -1
- package/dist/templates/registry.js +25 -0
- package/dist/templates/registry.js.map +1 -1
- package/eject/llm/loop.ts +134 -5
- package/package.json +1 -1
- package/schema/voicethere.llm.schema.json +27 -0
- package/templates/README.md +1 -0
- package/templates/llm-agent/README.md +27 -1
- package/templates/llm-agent/voicethere.llm.json +1 -1
- package/templates/llm-docs-rag/README.md +50 -0
- package/templates/llm-docs-rag/agent.ts +27 -0
- package/templates/llm-docs-rag/hooks.ts +21 -0
- package/templates/llm-docs-rag/md.d.ts +4 -0
- package/templates/llm-docs-rag/prompt.md +17 -0
- package/templates/llm-docs-rag/tools.ts +5 -0
- package/templates/llm-docs-rag/voicethere.llm.json +52 -0
- package/templates/llm-mcp-service/README.md +27 -1
- package/templates/llm-mcp-service/voicethere.llm.json +1 -1
|
@@ -591,14 +591,14 @@ function codePointLength(str) {
|
|
|
591
591
|
const units = str.length;
|
|
592
592
|
if (!highSurrogate.test(str))
|
|
593
593
|
return units;
|
|
594
|
-
let
|
|
594
|
+
let count2 = units;
|
|
595
595
|
for (let i = 0; i < units - 1; i++) {
|
|
596
596
|
if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
|
|
597
|
-
|
|
597
|
+
count2--;
|
|
598
598
|
i++;
|
|
599
599
|
}
|
|
600
600
|
}
|
|
601
|
-
return
|
|
601
|
+
return count2;
|
|
602
602
|
}
|
|
603
603
|
function getLengthableOrigin(input) {
|
|
604
604
|
if (Array.isArray(input))
|
|
@@ -12279,20 +12279,20 @@ var require_resolve = __commonJS({
|
|
|
12279
12279
|
return false;
|
|
12280
12280
|
}
|
|
12281
12281
|
function countKeys(schema) {
|
|
12282
|
-
let
|
|
12282
|
+
let count2 = 0;
|
|
12283
12283
|
for (const key in schema) {
|
|
12284
12284
|
if (key === "$ref")
|
|
12285
12285
|
return Infinity;
|
|
12286
|
-
|
|
12286
|
+
count2++;
|
|
12287
12287
|
if (SIMPLE_INLINED.has(key))
|
|
12288
12288
|
continue;
|
|
12289
12289
|
if (typeof schema[key] == "object") {
|
|
12290
|
-
(0, util_1.eachItem)(schema[key], (sch) =>
|
|
12290
|
+
(0, util_1.eachItem)(schema[key], (sch) => count2 += countKeys(sch));
|
|
12291
12291
|
}
|
|
12292
|
-
if (
|
|
12292
|
+
if (count2 === Infinity)
|
|
12293
12293
|
return Infinity;
|
|
12294
12294
|
}
|
|
12295
|
-
return
|
|
12295
|
+
return count2;
|
|
12296
12296
|
}
|
|
12297
12297
|
function getFullPath(resolver, id = "", normalize) {
|
|
12298
12298
|
if (normalize !== false)
|
|
@@ -13877,7 +13877,7 @@ var require_schemes = __commonJS({
|
|
|
13877
13877
|
skipNormalize: true
|
|
13878
13878
|
}
|
|
13879
13879
|
);
|
|
13880
|
-
var
|
|
13880
|
+
var SCHEMES2 = (
|
|
13881
13881
|
/** @type {Record<SchemeName, SchemeHandler>} */
|
|
13882
13882
|
{
|
|
13883
13883
|
http,
|
|
@@ -13888,19 +13888,19 @@ var require_schemes = __commonJS({
|
|
|
13888
13888
|
"urn:uuid": urnuuid
|
|
13889
13889
|
}
|
|
13890
13890
|
);
|
|
13891
|
-
Object.setPrototypeOf(
|
|
13891
|
+
Object.setPrototypeOf(SCHEMES2, null);
|
|
13892
13892
|
function getSchemeHandler(scheme) {
|
|
13893
|
-
return scheme && (
|
|
13893
|
+
return scheme && (SCHEMES2[
|
|
13894
13894
|
/** @type {SchemeName} */
|
|
13895
13895
|
scheme
|
|
13896
|
-
] ||
|
|
13896
|
+
] || SCHEMES2[
|
|
13897
13897
|
/** @type {SchemeName} */
|
|
13898
13898
|
scheme.toLowerCase()
|
|
13899
13899
|
]) || void 0;
|
|
13900
13900
|
}
|
|
13901
13901
|
module.exports = {
|
|
13902
13902
|
wsIsSecure,
|
|
13903
|
-
SCHEMES,
|
|
13903
|
+
SCHEMES: SCHEMES2,
|
|
13904
13904
|
isValidSchemeName,
|
|
13905
13905
|
getSchemeHandler
|
|
13906
13906
|
};
|
|
@@ -13912,7 +13912,7 @@ var require_fast_uri = __commonJS({
|
|
|
13912
13912
|
"node_modules/fast-uri/index.js"(exports, module) {
|
|
13913
13913
|
"use strict";
|
|
13914
13914
|
var { normalizeIPv6, removeDotSegments, removeDotSegmentsRelative, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
|
|
13915
|
-
var { SCHEMES, getSchemeHandler } = require_schemes();
|
|
13915
|
+
var { SCHEMES: SCHEMES2, getSchemeHandler } = require_schemes();
|
|
13916
13916
|
var VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
|
|
13917
13917
|
var MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
|
|
13918
13918
|
var MALFORMED_HOST_ERROR = "URI host is malformed.";
|
|
@@ -14283,7 +14283,7 @@ var require_fast_uri = __commonJS({
|
|
|
14283
14283
|
}
|
|
14284
14284
|
if (schemeHandler && schemeHandler.parse) {
|
|
14285
14285
|
schemeHandler.parse(parsed, options);
|
|
14286
|
-
if (schemeHandler ===
|
|
14286
|
+
if (schemeHandler === SCHEMES2.urn && parsed.nid === void 0) {
|
|
14287
14287
|
malformedSchemeSpecific = true;
|
|
14288
14288
|
}
|
|
14289
14289
|
}
|
|
@@ -14323,7 +14323,7 @@ var require_fast_uri = __commonJS({
|
|
|
14323
14323
|
return malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? void 0 : normalized;
|
|
14324
14324
|
}
|
|
14325
14325
|
var fastUri = {
|
|
14326
|
-
SCHEMES,
|
|
14326
|
+
SCHEMES: SCHEMES2,
|
|
14327
14327
|
normalize,
|
|
14328
14328
|
resolve,
|
|
14329
14329
|
resolveComponent,
|
|
@@ -15830,8 +15830,8 @@ var require_contains = __commonJS({
|
|
|
15830
15830
|
cxt.result(valid, () => cxt.reset());
|
|
15831
15831
|
function validateItemsWithCount() {
|
|
15832
15832
|
const schValid = gen.name("_valid");
|
|
15833
|
-
const
|
|
15834
|
-
validateItems(schValid, () => gen.if(schValid, () => checkLimits(
|
|
15833
|
+
const count2 = gen.let("count", 0);
|
|
15834
|
+
validateItems(schValid, () => gen.if(schValid, () => checkLimits(count2)));
|
|
15835
15835
|
}
|
|
15836
15836
|
function validateItems(_valid, block) {
|
|
15837
15837
|
gen.forRange("i", 0, len, (i) => {
|
|
@@ -15844,16 +15844,16 @@ var require_contains = __commonJS({
|
|
|
15844
15844
|
block();
|
|
15845
15845
|
});
|
|
15846
15846
|
}
|
|
15847
|
-
function checkLimits(
|
|
15848
|
-
gen.code((0, codegen_1._)`${
|
|
15847
|
+
function checkLimits(count2) {
|
|
15848
|
+
gen.code((0, codegen_1._)`${count2}++`);
|
|
15849
15849
|
if (max === void 0) {
|
|
15850
|
-
gen.if((0, codegen_1._)`${
|
|
15850
|
+
gen.if((0, codegen_1._)`${count2} >= ${min}`, () => gen.assign(valid, true).break());
|
|
15851
15851
|
} else {
|
|
15852
|
-
gen.if((0, codegen_1._)`${
|
|
15852
|
+
gen.if((0, codegen_1._)`${count2} > ${max}`, () => gen.assign(valid, false).break());
|
|
15853
15853
|
if (min === 1)
|
|
15854
15854
|
gen.assign(valid, true);
|
|
15855
15855
|
else
|
|
15856
|
-
gen.if((0, codegen_1._)`${
|
|
15856
|
+
gen.if((0, codegen_1._)`${count2} >= ${min}`, () => gen.assign(valid, true));
|
|
15857
15857
|
}
|
|
15858
15858
|
}
|
|
15859
15859
|
}
|
|
@@ -26798,51 +26798,51 @@ var require_denque = __commonJS({
|
|
|
26798
26798
|
}
|
|
26799
26799
|
return item;
|
|
26800
26800
|
};
|
|
26801
|
-
Denque.prototype.remove = function remove(index,
|
|
26801
|
+
Denque.prototype.remove = function remove(index, count2) {
|
|
26802
26802
|
var i = index;
|
|
26803
26803
|
var removed;
|
|
26804
|
-
var del_count =
|
|
26804
|
+
var del_count = count2;
|
|
26805
26805
|
if (i !== (i | 0)) {
|
|
26806
26806
|
return void 0;
|
|
26807
26807
|
}
|
|
26808
26808
|
if (this._head === this._tail) return void 0;
|
|
26809
26809
|
var size = this.size();
|
|
26810
26810
|
var len = this._list.length;
|
|
26811
|
-
if (i >= size || i < -size ||
|
|
26811
|
+
if (i >= size || i < -size || count2 < 1) return void 0;
|
|
26812
26812
|
if (i < 0) i += size;
|
|
26813
|
-
if (
|
|
26813
|
+
if (count2 === 1 || !count2) {
|
|
26814
26814
|
removed = new Array(1);
|
|
26815
26815
|
removed[0] = this.removeOne(i);
|
|
26816
26816
|
return removed;
|
|
26817
26817
|
}
|
|
26818
|
-
if (i === 0 && i +
|
|
26818
|
+
if (i === 0 && i + count2 >= size) {
|
|
26819
26819
|
removed = this.toArray();
|
|
26820
26820
|
this.clear();
|
|
26821
26821
|
return removed;
|
|
26822
26822
|
}
|
|
26823
|
-
if (i +
|
|
26823
|
+
if (i + count2 > size) count2 = size - i;
|
|
26824
26824
|
var k;
|
|
26825
|
-
removed = new Array(
|
|
26826
|
-
for (k = 0; k <
|
|
26825
|
+
removed = new Array(count2);
|
|
26826
|
+
for (k = 0; k < count2; k++) {
|
|
26827
26827
|
removed[k] = this._list[this._head + i + k & this._capacityMask];
|
|
26828
26828
|
}
|
|
26829
26829
|
i = this._head + i & this._capacityMask;
|
|
26830
|
-
if (index +
|
|
26831
|
-
this._tail = this._tail -
|
|
26832
|
-
for (k =
|
|
26830
|
+
if (index + count2 === size) {
|
|
26831
|
+
this._tail = this._tail - count2 + len & this._capacityMask;
|
|
26832
|
+
for (k = count2; k > 0; k--) {
|
|
26833
26833
|
this._list[i = i + 1 + len & this._capacityMask] = void 0;
|
|
26834
26834
|
}
|
|
26835
26835
|
return removed;
|
|
26836
26836
|
}
|
|
26837
26837
|
if (index === 0) {
|
|
26838
|
-
this._head = this._head +
|
|
26839
|
-
for (k =
|
|
26838
|
+
this._head = this._head + count2 + len & this._capacityMask;
|
|
26839
|
+
for (k = count2 - 1; k > 0; k--) {
|
|
26840
26840
|
this._list[i = i + 1 + len & this._capacityMask] = void 0;
|
|
26841
26841
|
}
|
|
26842
26842
|
return removed;
|
|
26843
26843
|
}
|
|
26844
26844
|
if (i < size / 2) {
|
|
26845
|
-
this._head = this._head + index +
|
|
26845
|
+
this._head = this._head + index + count2 + len & this._capacityMask;
|
|
26846
26846
|
for (k = index; k > 0; k--) {
|
|
26847
26847
|
this.unshift(this._list[i = i - 1 + len & this._capacityMask]);
|
|
26848
26848
|
}
|
|
@@ -26854,8 +26854,8 @@ var require_denque = __commonJS({
|
|
|
26854
26854
|
if (index < 0) this._tail = i;
|
|
26855
26855
|
} else {
|
|
26856
26856
|
this._tail = i;
|
|
26857
|
-
i = i +
|
|
26858
|
-
for (k = size - (
|
|
26857
|
+
i = i + count2 + len & this._capacityMask;
|
|
26858
|
+
for (k = size - (count2 + index); k > 0; k--) {
|
|
26859
26859
|
this.push(this._list[i++]);
|
|
26860
26860
|
}
|
|
26861
26861
|
i = this._tail;
|
|
@@ -26867,7 +26867,7 @@ var require_denque = __commonJS({
|
|
|
26867
26867
|
if (this._head < 2 && this._tail > 1e4 && this._tail <= len >>> 2) this._shrinkArray();
|
|
26868
26868
|
return removed;
|
|
26869
26869
|
};
|
|
26870
|
-
Denque.prototype.splice = function splice(index,
|
|
26870
|
+
Denque.prototype.splice = function splice(index, count2) {
|
|
26871
26871
|
var i = index;
|
|
26872
26872
|
if (i !== (i | 0)) {
|
|
26873
26873
|
return void 0;
|
|
@@ -26887,13 +26887,13 @@ var require_denque = __commonJS({
|
|
|
26887
26887
|
for (k = 0; k < i; k++) {
|
|
26888
26888
|
temp[k] = this._list[this._head + k & this._capacityMask];
|
|
26889
26889
|
}
|
|
26890
|
-
if (
|
|
26890
|
+
if (count2 === 0) {
|
|
26891
26891
|
removed = [];
|
|
26892
26892
|
if (i > 0) {
|
|
26893
26893
|
this._head = this._head + i + len & this._capacityMask;
|
|
26894
26894
|
}
|
|
26895
26895
|
} else {
|
|
26896
|
-
removed = this.remove(i,
|
|
26896
|
+
removed = this.remove(i, count2);
|
|
26897
26897
|
this._head = this._head + i + len & this._capacityMask;
|
|
26898
26898
|
}
|
|
26899
26899
|
while (arg_len > arguments_index) {
|
|
@@ -26903,18 +26903,18 @@ var require_denque = __commonJS({
|
|
|
26903
26903
|
this.unshift(temp[k - 1]);
|
|
26904
26904
|
}
|
|
26905
26905
|
} else {
|
|
26906
|
-
temp = new Array(size - (i +
|
|
26906
|
+
temp = new Array(size - (i + count2));
|
|
26907
26907
|
var leng = temp.length;
|
|
26908
26908
|
for (k = 0; k < leng; k++) {
|
|
26909
|
-
temp[k] = this._list[this._head + i +
|
|
26909
|
+
temp[k] = this._list[this._head + i + count2 + k & this._capacityMask];
|
|
26910
26910
|
}
|
|
26911
|
-
if (
|
|
26911
|
+
if (count2 === 0) {
|
|
26912
26912
|
removed = [];
|
|
26913
26913
|
if (i != size) {
|
|
26914
26914
|
this._tail = this._head + i + len & this._capacityMask;
|
|
26915
26915
|
}
|
|
26916
26916
|
} else {
|
|
26917
|
-
removed = this.remove(i,
|
|
26917
|
+
removed = this.remove(i, count2);
|
|
26918
26918
|
this._tail = this._tail - leng + len & this._capacityMask;
|
|
26919
26919
|
}
|
|
26920
26920
|
while (arguments_index < arg_len) {
|
|
@@ -26926,7 +26926,7 @@ var require_denque = __commonJS({
|
|
|
26926
26926
|
}
|
|
26927
26927
|
return removed;
|
|
26928
26928
|
} else {
|
|
26929
|
-
return this.remove(i,
|
|
26929
|
+
return this.remove(i, count2);
|
|
26930
26930
|
}
|
|
26931
26931
|
};
|
|
26932
26932
|
Denque.prototype.clear = function clear() {
|
|
@@ -29433,15 +29433,15 @@ var require_DataHandler = __commonJS({
|
|
|
29433
29433
|
if (channel) {
|
|
29434
29434
|
this.redis.condition.subscriber.del(replyType, channel);
|
|
29435
29435
|
}
|
|
29436
|
-
const
|
|
29437
|
-
if (Number(
|
|
29436
|
+
const count2 = reply[2];
|
|
29437
|
+
if (Number(count2) === 0) {
|
|
29438
29438
|
this.redis.condition.subscriber = false;
|
|
29439
29439
|
}
|
|
29440
29440
|
const item = this.shiftCommand(reply);
|
|
29441
29441
|
if (!item) {
|
|
29442
29442
|
return;
|
|
29443
29443
|
}
|
|
29444
|
-
if (!fillUnsubCommand(item.command,
|
|
29444
|
+
if (!fillUnsubCommand(item.command, count2)) {
|
|
29445
29445
|
this.redis.commandQueue.unshift(item);
|
|
29446
29446
|
}
|
|
29447
29447
|
break;
|
|
@@ -29485,30 +29485,30 @@ var require_DataHandler = __commonJS({
|
|
|
29485
29485
|
};
|
|
29486
29486
|
exports.default = DataHandler;
|
|
29487
29487
|
var remainingRepliesMap = /* @__PURE__ */ new WeakMap();
|
|
29488
|
-
function fillSubCommand(command,
|
|
29488
|
+
function fillSubCommand(command, count2) {
|
|
29489
29489
|
let remainingReplies = remainingRepliesMap.has(command) ? remainingRepliesMap.get(command) : command.args.length;
|
|
29490
29490
|
remainingReplies -= 1;
|
|
29491
29491
|
if (remainingReplies <= 0) {
|
|
29492
|
-
command.resolve(
|
|
29492
|
+
command.resolve(count2);
|
|
29493
29493
|
remainingRepliesMap.delete(command);
|
|
29494
29494
|
return true;
|
|
29495
29495
|
}
|
|
29496
29496
|
remainingRepliesMap.set(command, remainingReplies);
|
|
29497
29497
|
return false;
|
|
29498
29498
|
}
|
|
29499
|
-
function fillUnsubCommand(command,
|
|
29499
|
+
function fillUnsubCommand(command, count2) {
|
|
29500
29500
|
let remainingReplies = remainingRepliesMap.has(command) ? remainingRepliesMap.get(command) : command.args.length;
|
|
29501
29501
|
if (remainingReplies === 0) {
|
|
29502
|
-
if (Number(
|
|
29502
|
+
if (Number(count2) === 0) {
|
|
29503
29503
|
remainingRepliesMap.delete(command);
|
|
29504
|
-
command.resolve(
|
|
29504
|
+
command.resolve(count2);
|
|
29505
29505
|
return true;
|
|
29506
29506
|
}
|
|
29507
29507
|
return false;
|
|
29508
29508
|
}
|
|
29509
29509
|
remainingReplies -= 1;
|
|
29510
29510
|
if (remainingReplies <= 0) {
|
|
29511
|
-
command.resolve(
|
|
29511
|
+
command.resolve(count2);
|
|
29512
29512
|
return true;
|
|
29513
29513
|
}
|
|
29514
29514
|
remainingRepliesMap.set(command, remainingReplies);
|
|
@@ -32228,9 +32228,11 @@ var LLM_PROVIDERS = {
|
|
|
32228
32228
|
},
|
|
32229
32229
|
openrouter: {
|
|
32230
32230
|
title: "OpenRouter",
|
|
32231
|
-
// Chosen by the 2026-
|
|
32232
|
-
//
|
|
32233
|
-
|
|
32231
|
+
// Chosen by the 2026-11-01 probe: tool calls 3/3, median first token 837 ms,
|
|
32232
|
+
// and `tool_choice` in OpenRouter's supported_parameters (needed by
|
|
32233
|
+
// toolChoice "required-first-round"). amazon/nova-micro-v1, the previous
|
|
32234
|
+
// default, does not list tool_choice and skipped tools it was told to call.
|
|
32235
|
+
defaultModel: "anthropic/claude-haiku-5.5",
|
|
32234
32236
|
apiKeyEnv: "AGENT_OPENROUTER_API_KEY",
|
|
32235
32237
|
docsUrl: "https://openrouter.ai/docs/api-reference/overview"
|
|
32236
32238
|
}
|
|
@@ -33827,7 +33829,10 @@ var LLM_AGENT_CONFIG_DEFAULTS = {
|
|
|
33827
33829
|
serviceWaitMs: 2e4,
|
|
33828
33830
|
fallbackText: "Sorry, something went wrong. Please try again.",
|
|
33829
33831
|
speakChatReplies: true,
|
|
33830
|
-
toolCallLogs: "redacted"
|
|
33832
|
+
toolCallLogs: "redacted",
|
|
33833
|
+
linksMode: "extract",
|
|
33834
|
+
linksRequireToolSource: false,
|
|
33835
|
+
linksMaxPerTurn: 3
|
|
33831
33836
|
};
|
|
33832
33837
|
var PROVIDER_IDS = ["openai", "anthropic", "gemini", "openrouter"];
|
|
33833
33838
|
var ENV_NAME_RE = /^AGENT_[A-Z0-9_]{1,57}$/;
|
|
@@ -34088,6 +34093,7 @@ var TOP_KEYS = [
|
|
|
34088
34093
|
"baseUrl",
|
|
34089
34094
|
"temperature",
|
|
34090
34095
|
"maxOutputTokens",
|
|
34096
|
+
"toolChoice",
|
|
34091
34097
|
"greeting",
|
|
34092
34098
|
"bargeIn",
|
|
34093
34099
|
"speechDuringNonInterruptible",
|
|
@@ -34101,7 +34107,8 @@ var TOP_KEYS = [
|
|
|
34101
34107
|
"fallbackText",
|
|
34102
34108
|
"speakChatReplies",
|
|
34103
34109
|
"toolCallLogs",
|
|
34104
|
-
"knowledge"
|
|
34110
|
+
"knowledge",
|
|
34111
|
+
"links"
|
|
34105
34112
|
];
|
|
34106
34113
|
function validateKnowledge(c, raw, provider, topSecret) {
|
|
34107
34114
|
const k = c.object(raw, "knowledge");
|
|
@@ -34273,6 +34280,13 @@ function validateLlmAgentConfig(input) {
|
|
|
34273
34280
|
if (t !== void 0)
|
|
34274
34281
|
config2.maxOutputTokens = t;
|
|
34275
34282
|
}
|
|
34283
|
+
if (root.toolChoice !== void 0) {
|
|
34284
|
+
if (root.toolChoice === "auto" || root.toolChoice === "required-first-round") {
|
|
34285
|
+
config2.toolChoice = root.toolChoice;
|
|
34286
|
+
} else {
|
|
34287
|
+
c.err("toolChoice", 'must be one of "auto", "required-first-round"');
|
|
34288
|
+
}
|
|
34289
|
+
}
|
|
34276
34290
|
if (root.greeting !== void 0) {
|
|
34277
34291
|
const g = c.object(root.greeting, "greeting");
|
|
34278
34292
|
if (g) {
|
|
@@ -34478,6 +34492,33 @@ function validateLlmAgentConfig(input) {
|
|
|
34478
34492
|
if (b !== void 0)
|
|
34479
34493
|
config2.speakChatReplies = b;
|
|
34480
34494
|
}
|
|
34495
|
+
if (config2.toolChoice === "required-first-round" && config2.tools?.maxRounds === 1) {
|
|
34496
|
+
c.err("toolChoice", '"required-first-round" needs tools.maxRounds >= 2 (the forced tool round leaves no round to answer)');
|
|
34497
|
+
}
|
|
34498
|
+
if (root.links !== void 0) {
|
|
34499
|
+
const l = c.object(root.links, "links");
|
|
34500
|
+
if (l) {
|
|
34501
|
+
c.unknownKeys(l, ["mode", "requireToolSource", "maxPerTurn"], "links");
|
|
34502
|
+
const links = {};
|
|
34503
|
+
if (l.mode !== void 0) {
|
|
34504
|
+
if (l.mode === "extract" || l.mode === "off")
|
|
34505
|
+
links.mode = l.mode;
|
|
34506
|
+
else
|
|
34507
|
+
c.err("links.mode", 'must be one of "extract", "off"');
|
|
34508
|
+
}
|
|
34509
|
+
if (l.requireToolSource !== void 0) {
|
|
34510
|
+
const b = c.boolean(l.requireToolSource, "links.requireToolSource");
|
|
34511
|
+
if (b !== void 0)
|
|
34512
|
+
links.requireToolSource = b;
|
|
34513
|
+
}
|
|
34514
|
+
if (l.maxPerTurn !== void 0) {
|
|
34515
|
+
const n = c.number(l.maxPerTurn, "links.maxPerTurn", 1, 10, true);
|
|
34516
|
+
if (n !== void 0)
|
|
34517
|
+
links.maxPerTurn = n;
|
|
34518
|
+
}
|
|
34519
|
+
config2.links = links;
|
|
34520
|
+
}
|
|
34521
|
+
}
|
|
34481
34522
|
if (root.toolCallLogs !== void 0) {
|
|
34482
34523
|
if (root.toolCallLogs === "full" || root.toolCallLogs === "redacted" || root.toolCallLogs === "off") {
|
|
34483
34524
|
config2.toolCallLogs = root.toolCallLogs;
|
|
@@ -34529,6 +34570,11 @@ var LLM_AGENT_CONFIG_JSON_SCHEMA = {
|
|
|
34529
34570
|
maximum: 8192,
|
|
34530
34571
|
default: 512
|
|
34531
34572
|
},
|
|
34573
|
+
toolChoice: {
|
|
34574
|
+
enum: ["auto", "required-first-round"],
|
|
34575
|
+
default: "auto",
|
|
34576
|
+
description: "required-first-round: the first LLM call of every turn must call a tool (for example a docs search before any answer). Later calls in the turn are auto. Ignored when the agent has no tools. Needs tools.maxRounds >= 2."
|
|
34577
|
+
},
|
|
34532
34578
|
greeting: {
|
|
34533
34579
|
type: "object",
|
|
34534
34580
|
additionalProperties: false,
|
|
@@ -34754,6 +34800,20 @@ var LLM_AGENT_CONFIG_JSON_SCHEMA = {
|
|
|
34754
34800
|
default: "Sorry, something went wrong. Please try again."
|
|
34755
34801
|
},
|
|
34756
34802
|
speakChatReplies: { type: "boolean", default: true },
|
|
34803
|
+
links: {
|
|
34804
|
+
type: "object",
|
|
34805
|
+
additionalProperties: false,
|
|
34806
|
+
description: "Links in the reply. extract (default) keeps URLs out of speech and chat text and sends each https URL once as an assistant_content link message; off leaves the text as written.",
|
|
34807
|
+
properties: {
|
|
34808
|
+
mode: { enum: ["extract", "off"], default: "extract" },
|
|
34809
|
+
requireToolSource: {
|
|
34810
|
+
type: "boolean",
|
|
34811
|
+
default: false,
|
|
34812
|
+
description: "Send only URLs that appear in a tool result of the same turn, so the model cannot invent a link. Other URLs are still removed from speech."
|
|
34813
|
+
},
|
|
34814
|
+
maxPerTurn: { type: "integer", minimum: 1, maximum: 10, default: 3 }
|
|
34815
|
+
}
|
|
34816
|
+
},
|
|
34757
34817
|
knowledge: {
|
|
34758
34818
|
type: "object",
|
|
34759
34819
|
additionalProperties: false,
|
|
@@ -34899,6 +34959,153 @@ var ConversationHistory = class {
|
|
|
34899
34959
|
}
|
|
34900
34960
|
};
|
|
34901
34961
|
|
|
34962
|
+
// dist/llm/agent/link-extractor.js
|
|
34963
|
+
var LINK_MARK = "\uE000";
|
|
34964
|
+
var SCHEMES = ["https://", "http://"];
|
|
34965
|
+
var START_RE = /\[|https?:\/\//i;
|
|
34966
|
+
var BARE_RE = /^https?:\/\/\S*/i;
|
|
34967
|
+
var MARKDOWN_RE = /^\[([^[\]\n]{0,200})\]\((https?:\/\/[^\s()]+(?:\([^\s()]*\)[^\s()]*)*)\)/i;
|
|
34968
|
+
var MARKDOWN_PREFIX_RE = /^\[[^[\]\n]{0,200}(?:\](?:\([^\s)]*)?)?$/;
|
|
34969
|
+
var TRAILING = /* @__PURE__ */ new Set([
|
|
34970
|
+
".",
|
|
34971
|
+
",",
|
|
34972
|
+
";",
|
|
34973
|
+
":",
|
|
34974
|
+
"!",
|
|
34975
|
+
"?",
|
|
34976
|
+
"'",
|
|
34977
|
+
'"',
|
|
34978
|
+
"]",
|
|
34979
|
+
"}",
|
|
34980
|
+
">",
|
|
34981
|
+
"*",
|
|
34982
|
+
"_"
|
|
34983
|
+
]);
|
|
34984
|
+
var MAX_HOLD = 2048;
|
|
34985
|
+
function partialSchemeSuffix(buf) {
|
|
34986
|
+
const max = Math.max(...SCHEMES.map((s) => s.length)) - 1;
|
|
34987
|
+
for (let len = Math.min(max, buf.length); len > 0; len -= 1) {
|
|
34988
|
+
const tail = buf.slice(buf.length - len).toLowerCase();
|
|
34989
|
+
const before = buf[buf.length - len - 1];
|
|
34990
|
+
if (before !== void 0 && /[\p{L}\p{N}]/u.test(before))
|
|
34991
|
+
continue;
|
|
34992
|
+
if (SCHEMES.some((s) => s.startsWith(tail) && s.length > len))
|
|
34993
|
+
return len;
|
|
34994
|
+
}
|
|
34995
|
+
return 0;
|
|
34996
|
+
}
|
|
34997
|
+
function count(text, ch) {
|
|
34998
|
+
let n = 0;
|
|
34999
|
+
for (const c of text)
|
|
35000
|
+
if (c === ch)
|
|
35001
|
+
n += 1;
|
|
35002
|
+
return n;
|
|
35003
|
+
}
|
|
35004
|
+
function trimUrl(raw) {
|
|
35005
|
+
let end = raw.length;
|
|
35006
|
+
for (; ; ) {
|
|
35007
|
+
const c = raw[end - 1];
|
|
35008
|
+
if (c === void 0)
|
|
35009
|
+
break;
|
|
35010
|
+
if (TRAILING.has(c)) {
|
|
35011
|
+
end -= 1;
|
|
35012
|
+
continue;
|
|
35013
|
+
}
|
|
35014
|
+
const head = raw.slice(0, end);
|
|
35015
|
+
if (c === ")" && count(head, ")") > count(head, "(")) {
|
|
35016
|
+
end -= 1;
|
|
35017
|
+
continue;
|
|
35018
|
+
}
|
|
35019
|
+
break;
|
|
35020
|
+
}
|
|
35021
|
+
return { url: raw.slice(0, end), rest: raw.slice(end) };
|
|
35022
|
+
}
|
|
35023
|
+
function hasHost(url2) {
|
|
35024
|
+
return /^https?:\/\/[^/?#\s]/i.test(url2);
|
|
35025
|
+
}
|
|
35026
|
+
var LinkExtractor = class {
|
|
35027
|
+
buf = "";
|
|
35028
|
+
links = [];
|
|
35029
|
+
push(delta) {
|
|
35030
|
+
this.buf += delta;
|
|
35031
|
+
return this.drain(false);
|
|
35032
|
+
}
|
|
35033
|
+
end() {
|
|
35034
|
+
return this.drain(true);
|
|
35035
|
+
}
|
|
35036
|
+
/** The link for the next {@link LINK_MARK}, in text order. */
|
|
35037
|
+
takeLink() {
|
|
35038
|
+
return this.links.shift();
|
|
35039
|
+
}
|
|
35040
|
+
/** Links whose marks were never consumed (e.g. the round was cut short). */
|
|
35041
|
+
takeAll() {
|
|
35042
|
+
const all = this.links;
|
|
35043
|
+
this.links = [];
|
|
35044
|
+
return all;
|
|
35045
|
+
}
|
|
35046
|
+
add(url2, label) {
|
|
35047
|
+
const trimmed = label?.trim();
|
|
35048
|
+
this.links.push({
|
|
35049
|
+
url: url2,
|
|
35050
|
+
...trimmed ? { label: trimmed } : {},
|
|
35051
|
+
secure: /^https:\/\//i.test(url2)
|
|
35052
|
+
});
|
|
35053
|
+
}
|
|
35054
|
+
drain(final) {
|
|
35055
|
+
let out = "";
|
|
35056
|
+
for (; ; ) {
|
|
35057
|
+
const m = START_RE.exec(this.buf);
|
|
35058
|
+
if (!m) {
|
|
35059
|
+
const hold = final ? 0 : partialSchemeSuffix(this.buf);
|
|
35060
|
+
out += this.buf.slice(0, this.buf.length - hold);
|
|
35061
|
+
this.buf = this.buf.slice(this.buf.length - hold);
|
|
35062
|
+
return out;
|
|
35063
|
+
}
|
|
35064
|
+
out += this.buf.slice(0, m.index);
|
|
35065
|
+
this.buf = this.buf.slice(m.index);
|
|
35066
|
+
if (this.buf[0] === "[") {
|
|
35067
|
+
const md = MARKDOWN_RE.exec(this.buf);
|
|
35068
|
+
if (md && hasHost(md[2])) {
|
|
35069
|
+
this.add(md[2], md[1]);
|
|
35070
|
+
out += `${md[1]}${LINK_MARK}`;
|
|
35071
|
+
this.buf = this.buf.slice(md[0].length);
|
|
35072
|
+
continue;
|
|
35073
|
+
}
|
|
35074
|
+
if (!final && this.buf.length <= MAX_HOLD && MARKDOWN_PREFIX_RE.test(this.buf)) {
|
|
35075
|
+
return out;
|
|
35076
|
+
}
|
|
35077
|
+
out += "[";
|
|
35078
|
+
this.buf = this.buf.slice(1);
|
|
35079
|
+
continue;
|
|
35080
|
+
}
|
|
35081
|
+
const bare = BARE_RE.exec(this.buf);
|
|
35082
|
+
if (!final && bare[0].length === this.buf.length && this.buf.length <= MAX_HOLD) {
|
|
35083
|
+
return out;
|
|
35084
|
+
}
|
|
35085
|
+
const { url: url2, rest } = trimUrl(bare[0]);
|
|
35086
|
+
if (!hasHost(url2)) {
|
|
35087
|
+
out += bare[0];
|
|
35088
|
+
this.buf = this.buf.slice(bare[0].length);
|
|
35089
|
+
continue;
|
|
35090
|
+
}
|
|
35091
|
+
this.add(url2);
|
|
35092
|
+
out += LINK_MARK;
|
|
35093
|
+
this.buf = rest + this.buf.slice(bare[0].length);
|
|
35094
|
+
}
|
|
35095
|
+
}
|
|
35096
|
+
};
|
|
35097
|
+
function countLinkMarks(sentence) {
|
|
35098
|
+
return count(sentence, LINK_MARK);
|
|
35099
|
+
}
|
|
35100
|
+
function cleanLinkSentence(sentence) {
|
|
35101
|
+
if (!sentence.includes(LINK_MARK))
|
|
35102
|
+
return sentence;
|
|
35103
|
+
let t = sentence.replace(/(^|[.!?]\s+)(?:[\p{L}\p{N}'’-]+\s+){0,2}[\p{L}\p{N}'’-]+:\s*(?=)/gu, "$1").replace(/\s+(?:at|via)\s*(?=[\s.!?]*$)/gi, "").replace(/\s*/g, "").replace(/\(\s*\)/g, "").replace(/\s+([.,;:!?])/g, "$1").replace(/\s{2,}/g, " ").replace(/:\s*$/, ".").trim();
|
|
35104
|
+
if (!/[\p{L}\p{N}]/u.test(t))
|
|
35105
|
+
t = "";
|
|
35106
|
+
return t;
|
|
35107
|
+
}
|
|
35108
|
+
|
|
34902
35109
|
// dist/llm/agent/sentence-splitter.js
|
|
34903
35110
|
var ABBREVIATIONS = /* @__PURE__ */ new Set([
|
|
34904
35111
|
"e.g",
|
|
@@ -35076,6 +35283,26 @@ function truncateBytes(text, max) {
|
|
|
35076
35283
|
return `${buf.subarray(0, end).toString("utf8")}
|
|
35077
35284
|
[truncated]`;
|
|
35078
35285
|
}
|
|
35286
|
+
function checkContent(content) {
|
|
35287
|
+
const c = content;
|
|
35288
|
+
if (!c || c.kind !== "link") {
|
|
35289
|
+
throw configError('sendContent: content.kind must be "link"', "INVALID_CONTENT");
|
|
35290
|
+
}
|
|
35291
|
+
let url2;
|
|
35292
|
+
try {
|
|
35293
|
+
url2 = new URL(String(c.url));
|
|
35294
|
+
} catch {
|
|
35295
|
+
throw configError("sendContent: content.url is not a URL", "INVALID_CONTENT");
|
|
35296
|
+
}
|
|
35297
|
+
if (url2.protocol !== "https:") {
|
|
35298
|
+
throw configError("sendContent: content.url must be https", "INVALID_CONTENT");
|
|
35299
|
+
}
|
|
35300
|
+
if (c.label !== void 0 && typeof c.label !== "string") {
|
|
35301
|
+
throw configError("sendContent: content.label must be a string", "INVALID_CONTENT");
|
|
35302
|
+
}
|
|
35303
|
+
const label = c.label?.trim();
|
|
35304
|
+
return { kind: "link", url: String(c.url), ...label ? { label } : {} };
|
|
35305
|
+
}
|
|
35079
35306
|
function interruptionNote(played, unplayed) {
|
|
35080
35307
|
return `(The caller interrupted your previous reply after: "${played}". They did not hear: "${unplayed}".)`;
|
|
35081
35308
|
}
|
|
@@ -35122,6 +35349,9 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35122
35349
|
const toolWaitAfterMs = fillerCfg?.toolWait?.afterMs ?? D.toolWaitAfterMs;
|
|
35123
35350
|
const fillersInterruptible = fillerCfg?.interruptible ?? D.fillersInterruptible;
|
|
35124
35351
|
const coalesceMs = config2.speech?.coalesceMs ?? D.speechCoalesceMs;
|
|
35352
|
+
const linksMode = config2.links?.mode ?? D.linksMode;
|
|
35353
|
+
const linksRequireToolSource = config2.links?.requireToolSource ?? D.linksRequireToolSource;
|
|
35354
|
+
const linksMaxPerTurn = config2.links?.maxPerTurn ?? D.linksMaxPerTurn;
|
|
35125
35355
|
const legacyToolFiller = toolCallPhrases.length === 0 && toolWaitPhrases.length === 0 ? config2.tools?.filler : void 0;
|
|
35126
35356
|
let provider = opts.provider;
|
|
35127
35357
|
let knowledgeTool;
|
|
@@ -35169,6 +35399,39 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35169
35399
|
sendSpokenDelta(s.sessionId, t.turnId, text, t.inReplyTo);
|
|
35170
35400
|
}
|
|
35171
35401
|
}
|
|
35402
|
+
function sendContent(s, t, content) {
|
|
35403
|
+
if (t.controller.signal.aborted || s.ended)
|
|
35404
|
+
return false;
|
|
35405
|
+
if (t.linkUrls.has(content.url))
|
|
35406
|
+
return false;
|
|
35407
|
+
if (t.linkUrls.size >= linksMaxPerTurn) {
|
|
35408
|
+
t.linksDropped += 1;
|
|
35409
|
+
return false;
|
|
35410
|
+
}
|
|
35411
|
+
t.linkUrls.add(content.url);
|
|
35412
|
+
sendToClient(s.sessionId, {
|
|
35413
|
+
type: "assistant_content",
|
|
35414
|
+
turnId: t.turnId,
|
|
35415
|
+
content,
|
|
35416
|
+
...t.source === "voice" ? { spoken: true, ...t.inReplyTo ? { inReplyTo: t.inReplyTo } : {} } : {}
|
|
35417
|
+
});
|
|
35418
|
+
return true;
|
|
35419
|
+
}
|
|
35420
|
+
function offerLink(s, t, link) {
|
|
35421
|
+
if (!link.secure) {
|
|
35422
|
+
t.linksDropped += 1;
|
|
35423
|
+
return;
|
|
35424
|
+
}
|
|
35425
|
+
if (linksRequireToolSource && !t.toolResults.some((r) => r.includes(link.url))) {
|
|
35426
|
+
t.linksDropped += 1;
|
|
35427
|
+
return;
|
|
35428
|
+
}
|
|
35429
|
+
sendContent(s, t, {
|
|
35430
|
+
kind: "link",
|
|
35431
|
+
url: link.url,
|
|
35432
|
+
...link.label ? { label: link.label } : {}
|
|
35433
|
+
});
|
|
35434
|
+
}
|
|
35172
35435
|
function deliver(s, t, text, interruptible = true) {
|
|
35173
35436
|
flushSpeech(s, t);
|
|
35174
35437
|
t.spoken.push(text);
|
|
@@ -35557,6 +35820,8 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35557
35820
|
}
|
|
35558
35821
|
}
|
|
35559
35822
|
content = truncateBytes(content, toolMaxBytes);
|
|
35823
|
+
if (!isError)
|
|
35824
|
+
t.toolResults.push(content);
|
|
35560
35825
|
t.toolCalls.push({ name: call.name, isError, ms: now() - started });
|
|
35561
35826
|
return { callId: call.id, name: call.name, content, isError };
|
|
35562
35827
|
};
|
|
@@ -35600,12 +35865,29 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35600
35865
|
t.roundText = "";
|
|
35601
35866
|
const splitter = new SentenceSplitter();
|
|
35602
35867
|
const stripper = new ThinkingStripper();
|
|
35868
|
+
const links = linksMode === "extract" ? new LinkExtractor() : void 0;
|
|
35869
|
+
const emitModelSentence = async (sentence) => {
|
|
35870
|
+
if (!links) {
|
|
35871
|
+
await emitSentence(s, t, ctx, sentence);
|
|
35872
|
+
return;
|
|
35873
|
+
}
|
|
35874
|
+
const marks = countLinkMarks(sentence);
|
|
35875
|
+
const clean = cleanLinkSentence(sentence);
|
|
35876
|
+
if (clean)
|
|
35877
|
+
await emitSentence(s, t, ctx, clean);
|
|
35878
|
+
for (let i = 0; i < marks; i += 1) {
|
|
35879
|
+
const link = links.takeLink();
|
|
35880
|
+
if (link)
|
|
35881
|
+
offerLink(s, t, link);
|
|
35882
|
+
}
|
|
35883
|
+
};
|
|
35603
35884
|
let done;
|
|
35604
35885
|
const stream = provider.stream({
|
|
35605
35886
|
model: resolveModel(config2.provider, config2.model),
|
|
35606
35887
|
system: opts.systemPrompt,
|
|
35607
35888
|
messages,
|
|
35608
35889
|
tools: registry2 ? registry2.list().map((e) => e.spec) : [],
|
|
35890
|
+
...config2.toolChoice === "required-first-round" && t.llmCalls === 1 ? { toolChoice: "required" } : {},
|
|
35609
35891
|
temperature: config2.temperature,
|
|
35610
35892
|
maxOutputTokens: config2.maxOutputTokens ?? D.maxOutputTokens,
|
|
35611
35893
|
signal
|
|
@@ -35616,8 +35898,9 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35616
35898
|
if (ev.type === "text_delta") {
|
|
35617
35899
|
if (t.firstTokenMs === void 0)
|
|
35618
35900
|
t.firstTokenMs = now() - t.startedAt;
|
|
35619
|
-
|
|
35620
|
-
|
|
35901
|
+
const text = stripper.push(ev.text);
|
|
35902
|
+
for (const sentence of splitter.push(links ? links.push(text) : text)) {
|
|
35903
|
+
await emitModelSentence(sentence);
|
|
35621
35904
|
}
|
|
35622
35905
|
} else {
|
|
35623
35906
|
done = ev;
|
|
@@ -35628,11 +35911,14 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35628
35911
|
if (!done) {
|
|
35629
35912
|
throw new LlmProviderError("LLM_PROVIDER_ERROR", "stream ended without done");
|
|
35630
35913
|
}
|
|
35631
|
-
const
|
|
35914
|
+
const stripped = stripper.end();
|
|
35915
|
+
const tail = links ? links.push(stripped) + links.end() : stripped;
|
|
35632
35916
|
const sentences = tail ? [...splitter.push(tail), ...splitter.end()] : splitter.end();
|
|
35633
35917
|
for (const sentence of sentences) {
|
|
35634
|
-
await
|
|
35918
|
+
await emitModelSentence(sentence);
|
|
35635
35919
|
}
|
|
35920
|
+
for (const link of links?.takeAll() ?? [])
|
|
35921
|
+
offerLink(s, t, link);
|
|
35636
35922
|
t.thinkingCharsStripped += stripper.strippedChars;
|
|
35637
35923
|
const cleaned = stripThinking(done.text);
|
|
35638
35924
|
if (cleaned.strippedChars > 0) {
|
|
@@ -35663,7 +35949,9 @@ ${validated.errors.map((e) => `${e.path || "(root)"}: ${e.message}`).join("\n")}
|
|
|
35663
35949
|
...t.firstTokenMs !== void 0 ? { firstTokenMs: t.firstTokenMs } : {},
|
|
35664
35950
|
...t.inputTokens !== void 0 ? { inputTokens: t.inputTokens } : {},
|
|
35665
35951
|
...t.outputTokens !== void 0 ? { outputTokens: t.outputTokens } : {},
|
|
35666
|
-
...t.errorCode ? { errorCode: t.errorCode } : {}
|
|
35952
|
+
...t.errorCode ? { errorCode: t.errorCode } : {},
|
|
35953
|
+
...t.linkUrls.size > 0 ? { linksSent: t.linkUrls.size } : {},
|
|
35954
|
+
...t.linksDropped > 0 ? { linksDropped: t.linksDropped } : {}
|
|
35667
35955
|
};
|
|
35668
35956
|
}
|
|
35669
35957
|
function speakFallback(s, t) {
|
|
@@ -35840,7 +36128,9 @@ ${t.inputText}` : t.inputText, {
|
|
|
35840
36128
|
firstTokenMs: summary.firstTokenMs,
|
|
35841
36129
|
inputTokens: summary.inputTokens,
|
|
35842
36130
|
outputTokens: summary.outputTokens,
|
|
35843
|
-
thinkingCharsStripped: t.thinkingCharsStripped
|
|
36131
|
+
thinkingCharsStripped: t.thinkingCharsStripped,
|
|
36132
|
+
linksSent: t.linkUrls.size,
|
|
36133
|
+
linksDropped: t.linksDropped
|
|
35844
36134
|
}, s.sessionId);
|
|
35845
36135
|
}
|
|
35846
36136
|
function startTurn(s, text, source, utteranceId) {
|
|
@@ -35870,6 +36160,9 @@ ${t.inputText}` : t.inputText, {
|
|
|
35870
36160
|
pendingChars: 0,
|
|
35871
36161
|
fallbackSpoken: false,
|
|
35872
36162
|
thinkingCharsStripped: 0,
|
|
36163
|
+
linkUrls: /* @__PURE__ */ new Set(),
|
|
36164
|
+
linksDropped: 0,
|
|
36165
|
+
toolResults: [],
|
|
35873
36166
|
status: "completed"
|
|
35874
36167
|
};
|
|
35875
36168
|
const ctx = {
|
|
@@ -35884,7 +36177,8 @@ ${t.inputText}` : t.inputText, {
|
|
|
35884
36177
|
`), ...splitter.end()];
|
|
35885
36178
|
for (const part of parts)
|
|
35886
36179
|
deliver(s, t, part, o?.interruptible);
|
|
35887
|
-
}
|
|
36180
|
+
},
|
|
36181
|
+
sendContent: (content) => sendContent(s, t, checkContent(content))
|
|
35888
36182
|
};
|
|
35889
36183
|
const active = {
|
|
35890
36184
|
turnId,
|
|
@@ -35930,6 +36224,10 @@ ${t.inputText}` : t.inputText, {
|
|
|
35930
36224
|
source,
|
|
35931
36225
|
signal: new AbortController().signal,
|
|
35932
36226
|
speak: () => {
|
|
36227
|
+
},
|
|
36228
|
+
sendContent: (content) => {
|
|
36229
|
+
checkContent(content);
|
|
36230
|
+
return false;
|
|
35933
36231
|
}
|
|
35934
36232
|
};
|
|
35935
36233
|
await callHook("onTurnEnd", s.sessionId, () => hooks2.onTurnEnd(summary, ctx));
|
|
@@ -42120,10 +42418,10 @@ _a4 = AbstractChatCompletionRunner, _AbstractChatCompletionRunner_completionArri
|
|
|
42120
42418
|
if (!hasOwn(details, name)) {
|
|
42121
42419
|
continue;
|
|
42122
42420
|
}
|
|
42123
|
-
const
|
|
42124
|
-
if (typeof
|
|
42421
|
+
const count2 = details[name];
|
|
42422
|
+
if (typeof count2 === "number") {
|
|
42125
42423
|
Object.defineProperty(totalDetails, name, {
|
|
42126
|
-
value: (hasOwn(totalDetails, name) ? totalDetails[name] ?? 0 : 0) +
|
|
42424
|
+
value: (hasOwn(totalDetails, name) ? totalDetails[name] ?? 0 : 0) + count2,
|
|
42127
42425
|
enumerable: true,
|
|
42128
42426
|
configurable: true,
|
|
42129
42427
|
writable: true
|
|
@@ -51450,14 +51748,14 @@ function isPrimitiveAssistantStreamArrayDelta(accumulator, delta) {
|
|
|
51450
51748
|
return delta.every(isPrimitiveAssistantStreamValue) && accumulator.every(isPrimitiveAssistantStreamValue);
|
|
51451
51749
|
}
|
|
51452
51750
|
function countOwnAssistantStreamArrayEntries(accumulator) {
|
|
51453
|
-
let
|
|
51751
|
+
let count2 = 0;
|
|
51454
51752
|
for (const key of Object.keys(accumulator)) {
|
|
51455
51753
|
const index = Number(key);
|
|
51456
51754
|
if (Number.isSafeInteger(index) && index >= 0 && index < accumulator.length && String(index) === key) {
|
|
51457
|
-
|
|
51755
|
+
count2 += 1;
|
|
51458
51756
|
}
|
|
51459
51757
|
}
|
|
51460
|
-
return
|
|
51758
|
+
return count2;
|
|
51461
51759
|
}
|
|
51462
51760
|
function getAssistantStreamArrayOwnEntryCount(accumulator, enforceSparseHoleBudget, cachedState) {
|
|
51463
51761
|
if (!enforceSparseHoleBudget) {
|
|
@@ -59449,6 +59747,7 @@ function createOpenAiCompatibleProvider(config2) {
|
|
|
59449
59747
|
stream: true,
|
|
59450
59748
|
stream_options: { include_usage: true },
|
|
59451
59749
|
...tools2.length > 0 ? { tools: tools2 } : {},
|
|
59750
|
+
...tools2.length > 0 && req.toolChoice === "required" ? { tool_choice: "required" } : {},
|
|
59452
59751
|
...req.temperature !== void 0 ? { temperature: req.temperature } : {},
|
|
59453
59752
|
...req.maxOutputTokens !== void 0 ? config2.id === "openai" ? { max_completion_tokens: req.maxOutputTokens } : { max_tokens: req.maxOutputTokens } : {}
|
|
59454
59753
|
};
|
|
@@ -59545,7 +59844,7 @@ var voicethere_llm_default = {
|
|
|
59545
59844
|
$schema: "./node_modules/@voicethere/agent/schema/voicethere.llm.schema.json",
|
|
59546
59845
|
version: 1,
|
|
59547
59846
|
provider: "openrouter",
|
|
59548
|
-
model: "
|
|
59847
|
+
model: "anthropic/claude-haiku-5.5",
|
|
59549
59848
|
apiKeySecret: "AGENT_OPENROUTER_API_KEY",
|
|
59550
59849
|
maxOutputTokens: 300,
|
|
59551
59850
|
greeting: {
|