echo-ai-sdk-ts 2.6.1 → 2.6.2
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/LICENSE +21 -0
- package/dist/index.js +34 -33
- package/dist/index.mjs +34 -33
- package/package.json +2 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Echo AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.js
CHANGED
|
@@ -662,10 +662,10 @@ function ReadableStreamToAsyncIterable(stream) {
|
|
|
662
662
|
return {
|
|
663
663
|
async next() {
|
|
664
664
|
try {
|
|
665
|
-
const
|
|
666
|
-
if (
|
|
665
|
+
const result = await reader.read();
|
|
666
|
+
if (result?.done)
|
|
667
667
|
reader.releaseLock();
|
|
668
|
-
return
|
|
668
|
+
return result;
|
|
669
669
|
} catch (e) {
|
|
670
670
|
reader.releaseLock();
|
|
671
671
|
throw e;
|
|
@@ -1375,9 +1375,9 @@ var Stream = class _Stream {
|
|
|
1375
1375
|
return {
|
|
1376
1376
|
next: () => {
|
|
1377
1377
|
if (queue.length === 0) {
|
|
1378
|
-
const
|
|
1379
|
-
left.push(
|
|
1380
|
-
right.push(
|
|
1378
|
+
const result = iterator.next();
|
|
1379
|
+
left.push(result);
|
|
1380
|
+
right.push(result);
|
|
1381
1381
|
}
|
|
1382
1382
|
return queue.shift();
|
|
1383
1383
|
}
|
|
@@ -6288,17 +6288,17 @@ Uploads.Parts = Parts;
|
|
|
6288
6288
|
// node_modules/openai/lib/Util.mjs
|
|
6289
6289
|
var allSettledWithThrow = async (promises) => {
|
|
6290
6290
|
const results = await Promise.allSettled(promises);
|
|
6291
|
-
const rejected = results.filter((
|
|
6291
|
+
const rejected = results.filter((result) => result.status === "rejected");
|
|
6292
6292
|
if (rejected.length) {
|
|
6293
|
-
for (const
|
|
6294
|
-
console.error(
|
|
6293
|
+
for (const result of rejected) {
|
|
6294
|
+
console.error(result.reason);
|
|
6295
6295
|
}
|
|
6296
6296
|
throw new Error(`${rejected.length} promise(s) failed - see the above errors`);
|
|
6297
6297
|
}
|
|
6298
6298
|
const values = [];
|
|
6299
|
-
for (const
|
|
6300
|
-
if (
|
|
6301
|
-
values.push(
|
|
6299
|
+
for (const result of results) {
|
|
6300
|
+
if (result.status === "fulfilled") {
|
|
6301
|
+
values.push(result.value);
|
|
6302
6302
|
}
|
|
6303
6303
|
}
|
|
6304
6304
|
return values;
|
|
@@ -7690,10 +7690,10 @@ function ReadableStreamToAsyncIterable2(stream) {
|
|
|
7690
7690
|
return {
|
|
7691
7691
|
async next() {
|
|
7692
7692
|
try {
|
|
7693
|
-
const
|
|
7694
|
-
if (
|
|
7693
|
+
const result = await reader.read();
|
|
7694
|
+
if (result?.done)
|
|
7695
7695
|
reader.releaseLock();
|
|
7696
|
-
return
|
|
7696
|
+
return result;
|
|
7697
7697
|
} catch (e) {
|
|
7698
7698
|
reader.releaseLock();
|
|
7699
7699
|
throw e;
|
|
@@ -8036,9 +8036,9 @@ var Stream2 = class _Stream {
|
|
|
8036
8036
|
return {
|
|
8037
8037
|
next: () => {
|
|
8038
8038
|
if (queue.length === 0) {
|
|
8039
|
-
const
|
|
8040
|
-
left.push(
|
|
8041
|
-
right.push(
|
|
8039
|
+
const result = iterator.next();
|
|
8040
|
+
left.push(result);
|
|
8041
|
+
right.push(result);
|
|
8042
8042
|
}
|
|
8043
8043
|
return queue.shift();
|
|
8044
8044
|
}
|
|
@@ -10157,11 +10157,11 @@ async function generateToolResponse(params, lastMessage = params.messages.at(-1)
|
|
|
10157
10157
|
if ("parse" in tool && tool.parse) {
|
|
10158
10158
|
input = tool.parse(input);
|
|
10159
10159
|
}
|
|
10160
|
-
const
|
|
10160
|
+
const result = await tool.run(input);
|
|
10161
10161
|
return {
|
|
10162
10162
|
type: "tool_result",
|
|
10163
10163
|
tool_use_id: toolUse.id,
|
|
10164
|
-
content:
|
|
10164
|
+
content: result
|
|
10165
10165
|
};
|
|
10166
10166
|
} catch (error) {
|
|
10167
10167
|
return {
|
|
@@ -12502,8 +12502,8 @@ function createTool(options) {
|
|
|
12502
12502
|
schema: options.schema,
|
|
12503
12503
|
execute: async (args) => {
|
|
12504
12504
|
const parsed = options.schema.parse(args);
|
|
12505
|
-
const
|
|
12506
|
-
return typeof
|
|
12505
|
+
const result = await options.execute(parsed);
|
|
12506
|
+
return typeof result === "string" ? result : JSON.stringify(result);
|
|
12507
12507
|
},
|
|
12508
12508
|
getMcpSchema: () => {
|
|
12509
12509
|
const jsonSchema = (0, import_zod_to_json_schema.zodToJsonSchema)(options.schema, "toolParams");
|
|
@@ -12522,6 +12522,7 @@ function createTool(options) {
|
|
|
12522
12522
|
|
|
12523
12523
|
// src/tools/builtin.ts
|
|
12524
12524
|
var import_zod = require("zod");
|
|
12525
|
+
var import_expr_eval = require("expr-eval");
|
|
12525
12526
|
var calculatorTool = createTool({
|
|
12526
12527
|
name: "calculator",
|
|
12527
12528
|
description: "Useful for performing mathematical calculations. Provide a valid JavaScript mathematical expression as a string.",
|
|
@@ -12530,7 +12531,7 @@ var calculatorTool = createTool({
|
|
|
12530
12531
|
}),
|
|
12531
12532
|
execute: async ({ expression }) => {
|
|
12532
12533
|
try {
|
|
12533
|
-
const result =
|
|
12534
|
+
const result = import_expr_eval.Parser.evaluate(expression);
|
|
12534
12535
|
return String(result);
|
|
12535
12536
|
} catch (e) {
|
|
12536
12537
|
return `Calculation error: ${e.message}`;
|
|
@@ -12839,12 +12840,12 @@ var OpenAIWhisperSTT = class extends BaseSTTProvider {
|
|
|
12839
12840
|
response_format: "verbose_json",
|
|
12840
12841
|
timestamp_granularities: ["segment"]
|
|
12841
12842
|
});
|
|
12842
|
-
const
|
|
12843
|
+
const result = response2;
|
|
12843
12844
|
return {
|
|
12844
|
-
text:
|
|
12845
|
-
language:
|
|
12846
|
-
duration:
|
|
12847
|
-
segments:
|
|
12845
|
+
text: result.text,
|
|
12846
|
+
language: result.language,
|
|
12847
|
+
duration: result.duration,
|
|
12848
|
+
segments: result.segments?.map((s) => ({
|
|
12848
12849
|
start: s.start,
|
|
12849
12850
|
end: s.end,
|
|
12850
12851
|
text: s.text,
|
|
@@ -13804,9 +13805,9 @@ var CustomerSupportBot = class {
|
|
|
13804
13805
|
body: import_zod4.z.any().optional().describe("Request body for POST requests")
|
|
13805
13806
|
}),
|
|
13806
13807
|
execute: async ({ endpoint, method, body }) => {
|
|
13807
|
-
const
|
|
13808
|
-
if (!
|
|
13809
|
-
return JSON.stringify(
|
|
13808
|
+
const result = method === "POST" ? await connector.post(endpoint, body) : await connector.get(endpoint);
|
|
13809
|
+
if (!result.ok) return `API returned error (${result.status}): ${JSON.stringify(result.data)}`;
|
|
13810
|
+
return JSON.stringify(result.data, null, 2);
|
|
13810
13811
|
}
|
|
13811
13812
|
}));
|
|
13812
13813
|
}
|
|
@@ -13859,8 +13860,8 @@ Your role:
|
|
|
13859
13860
|
this.analytics.recordQuery(sessionId, activeMessage);
|
|
13860
13861
|
const startTime = Date.now();
|
|
13861
13862
|
for (const mw of this.middlewares) {
|
|
13862
|
-
const
|
|
13863
|
-
if (typeof
|
|
13863
|
+
const result = await mw({ sessionId, message: activeMessage, bot: this });
|
|
13864
|
+
if (typeof result === "string") return result;
|
|
13864
13865
|
}
|
|
13865
13866
|
if (this.handoff) {
|
|
13866
13867
|
const trigger = this.handoff.shouldEscalate(sessionId, activeMessage);
|
package/dist/index.mjs
CHANGED
|
@@ -569,10 +569,10 @@ function ReadableStreamToAsyncIterable(stream) {
|
|
|
569
569
|
return {
|
|
570
570
|
async next() {
|
|
571
571
|
try {
|
|
572
|
-
const
|
|
573
|
-
if (
|
|
572
|
+
const result = await reader.read();
|
|
573
|
+
if (result?.done)
|
|
574
574
|
reader.releaseLock();
|
|
575
|
-
return
|
|
575
|
+
return result;
|
|
576
576
|
} catch (e) {
|
|
577
577
|
reader.releaseLock();
|
|
578
578
|
throw e;
|
|
@@ -1282,9 +1282,9 @@ var Stream = class _Stream {
|
|
|
1282
1282
|
return {
|
|
1283
1283
|
next: () => {
|
|
1284
1284
|
if (queue.length === 0) {
|
|
1285
|
-
const
|
|
1286
|
-
left.push(
|
|
1287
|
-
right.push(
|
|
1285
|
+
const result = iterator.next();
|
|
1286
|
+
left.push(result);
|
|
1287
|
+
right.push(result);
|
|
1288
1288
|
}
|
|
1289
1289
|
return queue.shift();
|
|
1290
1290
|
}
|
|
@@ -6195,17 +6195,17 @@ Uploads.Parts = Parts;
|
|
|
6195
6195
|
// node_modules/openai/lib/Util.mjs
|
|
6196
6196
|
var allSettledWithThrow = async (promises) => {
|
|
6197
6197
|
const results = await Promise.allSettled(promises);
|
|
6198
|
-
const rejected = results.filter((
|
|
6198
|
+
const rejected = results.filter((result) => result.status === "rejected");
|
|
6199
6199
|
if (rejected.length) {
|
|
6200
|
-
for (const
|
|
6201
|
-
console.error(
|
|
6200
|
+
for (const result of rejected) {
|
|
6201
|
+
console.error(result.reason);
|
|
6202
6202
|
}
|
|
6203
6203
|
throw new Error(`${rejected.length} promise(s) failed - see the above errors`);
|
|
6204
6204
|
}
|
|
6205
6205
|
const values = [];
|
|
6206
|
-
for (const
|
|
6207
|
-
if (
|
|
6208
|
-
values.push(
|
|
6206
|
+
for (const result of results) {
|
|
6207
|
+
if (result.status === "fulfilled") {
|
|
6208
|
+
values.push(result.value);
|
|
6209
6209
|
}
|
|
6210
6210
|
}
|
|
6211
6211
|
return values;
|
|
@@ -7597,10 +7597,10 @@ function ReadableStreamToAsyncIterable2(stream) {
|
|
|
7597
7597
|
return {
|
|
7598
7598
|
async next() {
|
|
7599
7599
|
try {
|
|
7600
|
-
const
|
|
7601
|
-
if (
|
|
7600
|
+
const result = await reader.read();
|
|
7601
|
+
if (result?.done)
|
|
7602
7602
|
reader.releaseLock();
|
|
7603
|
-
return
|
|
7603
|
+
return result;
|
|
7604
7604
|
} catch (e) {
|
|
7605
7605
|
reader.releaseLock();
|
|
7606
7606
|
throw e;
|
|
@@ -7943,9 +7943,9 @@ var Stream2 = class _Stream {
|
|
|
7943
7943
|
return {
|
|
7944
7944
|
next: () => {
|
|
7945
7945
|
if (queue.length === 0) {
|
|
7946
|
-
const
|
|
7947
|
-
left.push(
|
|
7948
|
-
right.push(
|
|
7946
|
+
const result = iterator.next();
|
|
7947
|
+
left.push(result);
|
|
7948
|
+
right.push(result);
|
|
7949
7949
|
}
|
|
7950
7950
|
return queue.shift();
|
|
7951
7951
|
}
|
|
@@ -10064,11 +10064,11 @@ async function generateToolResponse(params, lastMessage = params.messages.at(-1)
|
|
|
10064
10064
|
if ("parse" in tool && tool.parse) {
|
|
10065
10065
|
input = tool.parse(input);
|
|
10066
10066
|
}
|
|
10067
|
-
const
|
|
10067
|
+
const result = await tool.run(input);
|
|
10068
10068
|
return {
|
|
10069
10069
|
type: "tool_result",
|
|
10070
10070
|
tool_use_id: toolUse.id,
|
|
10071
|
-
content:
|
|
10071
|
+
content: result
|
|
10072
10072
|
};
|
|
10073
10073
|
} catch (error) {
|
|
10074
10074
|
return {
|
|
@@ -12409,8 +12409,8 @@ function createTool(options) {
|
|
|
12409
12409
|
schema: options.schema,
|
|
12410
12410
|
execute: async (args) => {
|
|
12411
12411
|
const parsed = options.schema.parse(args);
|
|
12412
|
-
const
|
|
12413
|
-
return typeof
|
|
12412
|
+
const result = await options.execute(parsed);
|
|
12413
|
+
return typeof result === "string" ? result : JSON.stringify(result);
|
|
12414
12414
|
},
|
|
12415
12415
|
getMcpSchema: () => {
|
|
12416
12416
|
const jsonSchema = zodToJsonSchema(options.schema, "toolParams");
|
|
@@ -12429,6 +12429,7 @@ function createTool(options) {
|
|
|
12429
12429
|
|
|
12430
12430
|
// src/tools/builtin.ts
|
|
12431
12431
|
import { z } from "zod";
|
|
12432
|
+
import { Parser } from "expr-eval";
|
|
12432
12433
|
var calculatorTool = createTool({
|
|
12433
12434
|
name: "calculator",
|
|
12434
12435
|
description: "Useful for performing mathematical calculations. Provide a valid JavaScript mathematical expression as a string.",
|
|
@@ -12437,7 +12438,7 @@ var calculatorTool = createTool({
|
|
|
12437
12438
|
}),
|
|
12438
12439
|
execute: async ({ expression }) => {
|
|
12439
12440
|
try {
|
|
12440
|
-
const result =
|
|
12441
|
+
const result = Parser.evaluate(expression);
|
|
12441
12442
|
return String(result);
|
|
12442
12443
|
} catch (e) {
|
|
12443
12444
|
return `Calculation error: ${e.message}`;
|
|
@@ -12746,12 +12747,12 @@ var OpenAIWhisperSTT = class extends BaseSTTProvider {
|
|
|
12746
12747
|
response_format: "verbose_json",
|
|
12747
12748
|
timestamp_granularities: ["segment"]
|
|
12748
12749
|
});
|
|
12749
|
-
const
|
|
12750
|
+
const result = response2;
|
|
12750
12751
|
return {
|
|
12751
|
-
text:
|
|
12752
|
-
language:
|
|
12753
|
-
duration:
|
|
12754
|
-
segments:
|
|
12752
|
+
text: result.text,
|
|
12753
|
+
language: result.language,
|
|
12754
|
+
duration: result.duration,
|
|
12755
|
+
segments: result.segments?.map((s) => ({
|
|
12755
12756
|
start: s.start,
|
|
12756
12757
|
end: s.end,
|
|
12757
12758
|
text: s.text,
|
|
@@ -13711,9 +13712,9 @@ var CustomerSupportBot = class {
|
|
|
13711
13712
|
body: z4.any().optional().describe("Request body for POST requests")
|
|
13712
13713
|
}),
|
|
13713
13714
|
execute: async ({ endpoint, method, body }) => {
|
|
13714
|
-
const
|
|
13715
|
-
if (!
|
|
13716
|
-
return JSON.stringify(
|
|
13715
|
+
const result = method === "POST" ? await connector.post(endpoint, body) : await connector.get(endpoint);
|
|
13716
|
+
if (!result.ok) return `API returned error (${result.status}): ${JSON.stringify(result.data)}`;
|
|
13717
|
+
return JSON.stringify(result.data, null, 2);
|
|
13717
13718
|
}
|
|
13718
13719
|
}));
|
|
13719
13720
|
}
|
|
@@ -13766,8 +13767,8 @@ Your role:
|
|
|
13766
13767
|
this.analytics.recordQuery(sessionId, activeMessage);
|
|
13767
13768
|
const startTime = Date.now();
|
|
13768
13769
|
for (const mw of this.middlewares) {
|
|
13769
|
-
const
|
|
13770
|
-
if (typeof
|
|
13770
|
+
const result = await mw({ sessionId, message: activeMessage, bot: this });
|
|
13771
|
+
if (typeof result === "string") return result;
|
|
13771
13772
|
}
|
|
13772
13773
|
if (this.handoff) {
|
|
13773
13774
|
const trigger = this.handoff.shouldEscalate(sessionId, activeMessage);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "echo-ai-sdk-ts",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"description": "Echo AI SDK: Tier 5 Cloud Native (AWS Bedrock/SageMaker, GCP Vertex, Azure OpenAI/ML)",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"@huggingface/inference": "^4.13.15",
|
|
19
19
|
"cors": "^2.8.5",
|
|
20
20
|
"cross-fetch": "^4.1.0",
|
|
21
|
+
"expr-eval": "^2.0.2",
|
|
21
22
|
"express": "^4.18.2",
|
|
22
23
|
"zod": "^3.25.76",
|
|
23
24
|
"zod-to-json-schema": "^3.25.1"
|