@mastra/client-js 0.0.0-break-rename-vnext-legacy-20250926163953 → 0.0.0-break-rename-vnext-legacy-20251002212351
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/CHANGELOG.md +65 -4
- package/dist/client.d.ts +2 -13
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +173 -180
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +173 -180
- package/dist/index.js.map +1 -1
- package/dist/resources/agent.d.ts +18 -5
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/resources/observability.d.ts +7 -1
- package/dist/resources/observability.d.ts.map +1 -1
- package/dist/resources/workflow.d.ts +23 -8
- package/dist/resources/workflow.d.ts.map +1 -1
- package/dist/types.d.ts +15 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/resources/vNextNetwork.d.ts +0 -43
- package/dist/resources/vNextNetwork.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -683,11 +683,6 @@ var Agent = class extends BaseResource {
|
|
|
683
683
|
});
|
|
684
684
|
onFinish?.({ message, finishReason, usage });
|
|
685
685
|
}
|
|
686
|
-
/**
|
|
687
|
-
* Streams a response from the agent
|
|
688
|
-
* @param params - Stream parameters including prompt
|
|
689
|
-
* @returns Promise containing the enhanced Response object with processDataStream method
|
|
690
|
-
*/
|
|
691
686
|
/**
|
|
692
687
|
* Streams a response from the agent
|
|
693
688
|
* @param params - Stream parameters including prompt
|
|
@@ -1022,9 +1017,11 @@ var Agent = class extends BaseResource {
|
|
|
1022
1017
|
if (toolCall) {
|
|
1023
1018
|
toolCalls.push(toolCall);
|
|
1024
1019
|
}
|
|
1020
|
+
let shouldExecuteClientTool = false;
|
|
1025
1021
|
for (const toolCall2 of toolCalls) {
|
|
1026
1022
|
const clientTool = processedParams.clientTools?.[toolCall2.toolName];
|
|
1027
1023
|
if (clientTool && clientTool.execute) {
|
|
1024
|
+
shouldExecuteClientTool = true;
|
|
1028
1025
|
const result = await clientTool.execute(
|
|
1029
1026
|
{
|
|
1030
1027
|
context: toolCall2?.args,
|
|
@@ -1073,6 +1070,11 @@ var Agent = class extends BaseResource {
|
|
|
1073
1070
|
});
|
|
1074
1071
|
}
|
|
1075
1072
|
}
|
|
1073
|
+
if (!shouldExecuteClientTool) {
|
|
1074
|
+
setTimeout(() => {
|
|
1075
|
+
writable.close();
|
|
1076
|
+
}, 0);
|
|
1077
|
+
}
|
|
1076
1078
|
} else {
|
|
1077
1079
|
setTimeout(() => {
|
|
1078
1080
|
writable.close();
|
|
@@ -1337,6 +1339,12 @@ var Agent = class extends BaseResource {
|
|
|
1337
1339
|
body: params
|
|
1338
1340
|
});
|
|
1339
1341
|
}
|
|
1342
|
+
async generateVNext(_messagesOrParams, _options) {
|
|
1343
|
+
throw new Error("generateVNext has been renamed to generate. Please use generate instead.");
|
|
1344
|
+
}
|
|
1345
|
+
async streamVNext(_messagesOrParams, _options) {
|
|
1346
|
+
throw new Error("streamVNext has been renamed to stream. Please use stream instead.");
|
|
1347
|
+
}
|
|
1340
1348
|
};
|
|
1341
1349
|
|
|
1342
1350
|
// src/resources/memory-thread.ts
|
|
@@ -1685,10 +1693,20 @@ var Workflow = class extends BaseResource {
|
|
|
1685
1693
|
return {
|
|
1686
1694
|
runId,
|
|
1687
1695
|
start: async (p) => {
|
|
1688
|
-
return this.start({
|
|
1696
|
+
return this.start({
|
|
1697
|
+
runId,
|
|
1698
|
+
inputData: p.inputData,
|
|
1699
|
+
runtimeContext: p.runtimeContext,
|
|
1700
|
+
tracingOptions: p.tracingOptions
|
|
1701
|
+
});
|
|
1689
1702
|
},
|
|
1690
1703
|
startAsync: async (p) => {
|
|
1691
|
-
return this.startAsync({
|
|
1704
|
+
return this.startAsync({
|
|
1705
|
+
runId,
|
|
1706
|
+
inputData: p.inputData,
|
|
1707
|
+
runtimeContext: p.runtimeContext,
|
|
1708
|
+
tracingOptions: p.tracingOptions
|
|
1709
|
+
});
|
|
1692
1710
|
},
|
|
1693
1711
|
watch: async (onRecord) => {
|
|
1694
1712
|
return this.watch({ runId }, onRecord);
|
|
@@ -1697,10 +1715,22 @@ var Workflow = class extends BaseResource {
|
|
|
1697
1715
|
return this.stream({ runId, inputData: p.inputData, runtimeContext: p.runtimeContext });
|
|
1698
1716
|
},
|
|
1699
1717
|
resume: async (p) => {
|
|
1700
|
-
return this.resume({
|
|
1718
|
+
return this.resume({
|
|
1719
|
+
runId,
|
|
1720
|
+
step: p.step,
|
|
1721
|
+
resumeData: p.resumeData,
|
|
1722
|
+
runtimeContext: p.runtimeContext,
|
|
1723
|
+
tracingOptions: p.tracingOptions
|
|
1724
|
+
});
|
|
1701
1725
|
},
|
|
1702
1726
|
resumeAsync: async (p) => {
|
|
1703
|
-
return this.resumeAsync({
|
|
1727
|
+
return this.resumeAsync({
|
|
1728
|
+
runId,
|
|
1729
|
+
step: p.step,
|
|
1730
|
+
resumeData: p.resumeData,
|
|
1731
|
+
runtimeContext: p.runtimeContext,
|
|
1732
|
+
tracingOptions: p.tracingOptions
|
|
1733
|
+
});
|
|
1704
1734
|
},
|
|
1705
1735
|
resumeStreamVNext: async (p) => {
|
|
1706
1736
|
return this.resumeStreamVNext({
|
|
@@ -1721,7 +1751,7 @@ var Workflow = class extends BaseResource {
|
|
|
1721
1751
|
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
1722
1752
|
return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
|
|
1723
1753
|
method: "POST",
|
|
1724
|
-
body: { inputData: params?.inputData, runtimeContext }
|
|
1754
|
+
body: { inputData: params?.inputData, runtimeContext, tracingOptions: params.tracingOptions }
|
|
1725
1755
|
});
|
|
1726
1756
|
}
|
|
1727
1757
|
/**
|
|
@@ -1733,6 +1763,7 @@ var Workflow = class extends BaseResource {
|
|
|
1733
1763
|
step,
|
|
1734
1764
|
runId,
|
|
1735
1765
|
resumeData,
|
|
1766
|
+
tracingOptions,
|
|
1736
1767
|
...rest
|
|
1737
1768
|
}) {
|
|
1738
1769
|
const runtimeContext = parseClientRuntimeContext(rest.runtimeContext);
|
|
@@ -1741,7 +1772,8 @@ var Workflow = class extends BaseResource {
|
|
|
1741
1772
|
body: {
|
|
1742
1773
|
step,
|
|
1743
1774
|
resumeData,
|
|
1744
|
-
runtimeContext
|
|
1775
|
+
runtimeContext,
|
|
1776
|
+
tracingOptions
|
|
1745
1777
|
}
|
|
1746
1778
|
});
|
|
1747
1779
|
}
|
|
@@ -1758,7 +1790,7 @@ var Workflow = class extends BaseResource {
|
|
|
1758
1790
|
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
1759
1791
|
return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
1760
1792
|
method: "POST",
|
|
1761
|
-
body: { inputData: params.inputData, runtimeContext }
|
|
1793
|
+
body: { inputData: params.inputData, runtimeContext, tracingOptions: params.tracingOptions }
|
|
1762
1794
|
});
|
|
1763
1795
|
}
|
|
1764
1796
|
/**
|
|
@@ -1776,7 +1808,7 @@ var Workflow = class extends BaseResource {
|
|
|
1776
1808
|
`/api/workflows/${this.workflowId}/stream?${searchParams.toString()}`,
|
|
1777
1809
|
{
|
|
1778
1810
|
method: "POST",
|
|
1779
|
-
body: { inputData: params.inputData, runtimeContext },
|
|
1811
|
+
body: { inputData: params.inputData, runtimeContext, tracingOptions: params.tracingOptions },
|
|
1780
1812
|
stream: true
|
|
1781
1813
|
}
|
|
1782
1814
|
);
|
|
@@ -1874,7 +1906,12 @@ var Workflow = class extends BaseResource {
|
|
|
1874
1906
|
`/api/workflows/${this.workflowId}/streamVNext?${searchParams.toString()}`,
|
|
1875
1907
|
{
|
|
1876
1908
|
method: "POST",
|
|
1877
|
-
body: {
|
|
1909
|
+
body: {
|
|
1910
|
+
inputData: params.inputData,
|
|
1911
|
+
runtimeContext,
|
|
1912
|
+
closeOnSuspend: params.closeOnSuspend,
|
|
1913
|
+
tracingOptions: params.tracingOptions
|
|
1914
|
+
},
|
|
1878
1915
|
stream: true
|
|
1879
1916
|
}
|
|
1880
1917
|
);
|
|
@@ -1910,6 +1947,53 @@ var Workflow = class extends BaseResource {
|
|
|
1910
1947
|
});
|
|
1911
1948
|
return response.body.pipeThrough(transformStream);
|
|
1912
1949
|
}
|
|
1950
|
+
/**
|
|
1951
|
+
* Observes workflow vNext stream for a workflow run
|
|
1952
|
+
* @param params - Object containing the runId
|
|
1953
|
+
* @returns Promise containing the workflow execution results
|
|
1954
|
+
*/
|
|
1955
|
+
async observeStreamVNext(params) {
|
|
1956
|
+
const searchParams = new URLSearchParams();
|
|
1957
|
+
searchParams.set("runId", params.runId);
|
|
1958
|
+
const response = await this.request(
|
|
1959
|
+
`/api/workflows/${this.workflowId}/observe-streamVNext?${searchParams.toString()}`,
|
|
1960
|
+
{
|
|
1961
|
+
method: "POST",
|
|
1962
|
+
stream: true
|
|
1963
|
+
}
|
|
1964
|
+
);
|
|
1965
|
+
if (!response.ok) {
|
|
1966
|
+
throw new Error(`Failed to observe stream vNext workflow: ${response.statusText}`);
|
|
1967
|
+
}
|
|
1968
|
+
if (!response.body) {
|
|
1969
|
+
throw new Error("Response body is null");
|
|
1970
|
+
}
|
|
1971
|
+
let failedChunk = void 0;
|
|
1972
|
+
const transformStream = new TransformStream({
|
|
1973
|
+
start() {
|
|
1974
|
+
},
|
|
1975
|
+
async transform(chunk, controller) {
|
|
1976
|
+
try {
|
|
1977
|
+
const decoded = new TextDecoder().decode(chunk);
|
|
1978
|
+
const chunks = decoded.split(RECORD_SEPARATOR);
|
|
1979
|
+
for (const chunk2 of chunks) {
|
|
1980
|
+
if (chunk2) {
|
|
1981
|
+
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
1982
|
+
try {
|
|
1983
|
+
const parsedChunk = JSON.parse(newChunk);
|
|
1984
|
+
controller.enqueue(parsedChunk);
|
|
1985
|
+
failedChunk = void 0;
|
|
1986
|
+
} catch {
|
|
1987
|
+
failedChunk = newChunk;
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
} catch {
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
});
|
|
1995
|
+
return response.body.pipeThrough(transformStream);
|
|
1996
|
+
}
|
|
1913
1997
|
/**
|
|
1914
1998
|
* Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
1915
1999
|
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
@@ -1922,7 +2006,8 @@ var Workflow = class extends BaseResource {
|
|
|
1922
2006
|
body: {
|
|
1923
2007
|
step: params.step,
|
|
1924
2008
|
resumeData: params.resumeData,
|
|
1925
|
-
runtimeContext
|
|
2009
|
+
runtimeContext,
|
|
2010
|
+
tracingOptions: params.tracingOptions
|
|
1926
2011
|
}
|
|
1927
2012
|
});
|
|
1928
2013
|
}
|
|
@@ -1931,16 +2016,54 @@ var Workflow = class extends BaseResource {
|
|
|
1931
2016
|
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
1932
2017
|
* @returns Promise containing the workflow resume results
|
|
1933
2018
|
*/
|
|
1934
|
-
resumeStreamVNext(params) {
|
|
2019
|
+
async resumeStreamVNext(params) {
|
|
2020
|
+
const searchParams = new URLSearchParams();
|
|
2021
|
+
searchParams.set("runId", params.runId);
|
|
1935
2022
|
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
2023
|
+
const response = await this.request(
|
|
2024
|
+
`/api/workflows/${this.workflowId}/resume-stream?${searchParams.toString()}`,
|
|
2025
|
+
{
|
|
2026
|
+
method: "POST",
|
|
2027
|
+
body: {
|
|
2028
|
+
step: params.step,
|
|
2029
|
+
resumeData: params.resumeData,
|
|
2030
|
+
runtimeContext,
|
|
2031
|
+
tracingOptions: params.tracingOptions
|
|
2032
|
+
},
|
|
2033
|
+
stream: true
|
|
2034
|
+
}
|
|
2035
|
+
);
|
|
2036
|
+
if (!response.ok) {
|
|
2037
|
+
throw new Error(`Failed to stream vNext workflow: ${response.statusText}`);
|
|
2038
|
+
}
|
|
2039
|
+
if (!response.body) {
|
|
2040
|
+
throw new Error("Response body is null");
|
|
2041
|
+
}
|
|
2042
|
+
let failedChunk = void 0;
|
|
2043
|
+
const transformStream = new TransformStream({
|
|
2044
|
+
start() {
|
|
2045
|
+
},
|
|
2046
|
+
async transform(chunk, controller) {
|
|
2047
|
+
try {
|
|
2048
|
+
const decoded = new TextDecoder().decode(chunk);
|
|
2049
|
+
const chunks = decoded.split(RECORD_SEPARATOR);
|
|
2050
|
+
for (const chunk2 of chunks) {
|
|
2051
|
+
if (chunk2) {
|
|
2052
|
+
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
2053
|
+
try {
|
|
2054
|
+
const parsedChunk = JSON.parse(newChunk);
|
|
2055
|
+
controller.enqueue(parsedChunk);
|
|
2056
|
+
failedChunk = void 0;
|
|
2057
|
+
} catch {
|
|
2058
|
+
failedChunk = newChunk;
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
} catch {
|
|
2063
|
+
}
|
|
1942
2064
|
}
|
|
1943
2065
|
});
|
|
2066
|
+
return response.body.pipeThrough(transformStream);
|
|
1944
2067
|
}
|
|
1945
2068
|
/**
|
|
1946
2069
|
* Watches workflow transitions in real-time
|
|
@@ -2518,6 +2641,25 @@ var Observability = class extends BaseResource {
|
|
|
2518
2641
|
const queryString = searchParams.toString();
|
|
2519
2642
|
return this.request(`/api/observability/traces${queryString ? `?${queryString}` : ""}`);
|
|
2520
2643
|
}
|
|
2644
|
+
/**
|
|
2645
|
+
* Retrieves scores by trace ID and span ID
|
|
2646
|
+
* @param params - Parameters containing trace ID, span ID, and pagination options
|
|
2647
|
+
* @returns Promise containing scores and pagination info
|
|
2648
|
+
*/
|
|
2649
|
+
getScoresBySpan(params) {
|
|
2650
|
+
const { traceId, spanId, page, perPage } = params;
|
|
2651
|
+
const searchParams = new URLSearchParams();
|
|
2652
|
+
if (page !== void 0) {
|
|
2653
|
+
searchParams.set("page", String(page));
|
|
2654
|
+
}
|
|
2655
|
+
if (perPage !== void 0) {
|
|
2656
|
+
searchParams.set("perPage", String(perPage));
|
|
2657
|
+
}
|
|
2658
|
+
const queryString = searchParams.toString();
|
|
2659
|
+
return this.request(
|
|
2660
|
+
`/api/observability/traces/${encodeURIComponent(traceId)}/${encodeURIComponent(spanId)}/scores${queryString ? `?${queryString}` : ""}`
|
|
2661
|
+
);
|
|
2662
|
+
}
|
|
2521
2663
|
score(params) {
|
|
2522
2664
|
return this.request(`/api/observability/traces/score`, {
|
|
2523
2665
|
method: "POST",
|
|
@@ -2589,145 +2731,6 @@ var NetworkMemoryThread = class extends BaseResource {
|
|
|
2589
2731
|
}
|
|
2590
2732
|
};
|
|
2591
2733
|
|
|
2592
|
-
// src/resources/vNextNetwork.ts
|
|
2593
|
-
var RECORD_SEPARATOR3 = "";
|
|
2594
|
-
var VNextNetwork = class extends BaseResource {
|
|
2595
|
-
constructor(options, networkId) {
|
|
2596
|
-
super(options);
|
|
2597
|
-
this.networkId = networkId;
|
|
2598
|
-
}
|
|
2599
|
-
/**
|
|
2600
|
-
* Retrieves details about the network
|
|
2601
|
-
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
2602
|
-
* @returns Promise containing vNext network details
|
|
2603
|
-
*/
|
|
2604
|
-
details(runtimeContext) {
|
|
2605
|
-
return this.request(`/api/networks/v-next/${this.networkId}${runtimeContextQueryString(runtimeContext)}`);
|
|
2606
|
-
}
|
|
2607
|
-
/**
|
|
2608
|
-
* Generates a response from the v-next network
|
|
2609
|
-
* @param params - Generation parameters including message
|
|
2610
|
-
* @returns Promise containing the generated response
|
|
2611
|
-
*/
|
|
2612
|
-
generate(params) {
|
|
2613
|
-
return this.request(`/api/networks/v-next/${this.networkId}/generate`, {
|
|
2614
|
-
method: "POST",
|
|
2615
|
-
body: {
|
|
2616
|
-
...params,
|
|
2617
|
-
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
2618
|
-
}
|
|
2619
|
-
});
|
|
2620
|
-
}
|
|
2621
|
-
/**
|
|
2622
|
-
* Generates a response from the v-next network using multiple primitives
|
|
2623
|
-
* @param params - Generation parameters including message
|
|
2624
|
-
* @returns Promise containing the generated response
|
|
2625
|
-
*/
|
|
2626
|
-
loop(params) {
|
|
2627
|
-
return this.request(`/api/networks/v-next/${this.networkId}/loop`, {
|
|
2628
|
-
method: "POST",
|
|
2629
|
-
body: {
|
|
2630
|
-
...params,
|
|
2631
|
-
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
2632
|
-
}
|
|
2633
|
-
});
|
|
2634
|
-
}
|
|
2635
|
-
async *streamProcessor(stream) {
|
|
2636
|
-
const reader = stream.getReader();
|
|
2637
|
-
let doneReading = false;
|
|
2638
|
-
let buffer = "";
|
|
2639
|
-
try {
|
|
2640
|
-
while (!doneReading) {
|
|
2641
|
-
const { done, value } = await reader.read();
|
|
2642
|
-
doneReading = done;
|
|
2643
|
-
if (done && !value) continue;
|
|
2644
|
-
try {
|
|
2645
|
-
const decoded = value ? new TextDecoder().decode(value) : "";
|
|
2646
|
-
const chunks = (buffer + decoded).split(RECORD_SEPARATOR3);
|
|
2647
|
-
buffer = chunks.pop() || "";
|
|
2648
|
-
for (const chunk of chunks) {
|
|
2649
|
-
if (chunk) {
|
|
2650
|
-
if (typeof chunk === "string") {
|
|
2651
|
-
try {
|
|
2652
|
-
const parsedChunk = JSON.parse(chunk);
|
|
2653
|
-
yield parsedChunk;
|
|
2654
|
-
} catch {
|
|
2655
|
-
}
|
|
2656
|
-
}
|
|
2657
|
-
}
|
|
2658
|
-
}
|
|
2659
|
-
} catch {
|
|
2660
|
-
}
|
|
2661
|
-
}
|
|
2662
|
-
if (buffer) {
|
|
2663
|
-
try {
|
|
2664
|
-
yield JSON.parse(buffer);
|
|
2665
|
-
} catch {
|
|
2666
|
-
}
|
|
2667
|
-
}
|
|
2668
|
-
} finally {
|
|
2669
|
-
reader.cancel().catch(() => {
|
|
2670
|
-
});
|
|
2671
|
-
}
|
|
2672
|
-
}
|
|
2673
|
-
/**
|
|
2674
|
-
* Streams a response from the v-next network
|
|
2675
|
-
* @param params - Stream parameters including message
|
|
2676
|
-
* @returns Promise containing the results
|
|
2677
|
-
*/
|
|
2678
|
-
async stream(params, onRecord) {
|
|
2679
|
-
const response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
|
|
2680
|
-
method: "POST",
|
|
2681
|
-
body: {
|
|
2682
|
-
...params,
|
|
2683
|
-
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
2684
|
-
},
|
|
2685
|
-
stream: true
|
|
2686
|
-
});
|
|
2687
|
-
if (!response.ok) {
|
|
2688
|
-
throw new Error(`Failed to stream vNext network: ${response.statusText}`);
|
|
2689
|
-
}
|
|
2690
|
-
if (!response.body) {
|
|
2691
|
-
throw new Error("Response body is null");
|
|
2692
|
-
}
|
|
2693
|
-
for await (const record of this.streamProcessor(response.body)) {
|
|
2694
|
-
if (typeof record === "string") {
|
|
2695
|
-
onRecord(JSON.parse(record));
|
|
2696
|
-
} else {
|
|
2697
|
-
onRecord(record);
|
|
2698
|
-
}
|
|
2699
|
-
}
|
|
2700
|
-
}
|
|
2701
|
-
/**
|
|
2702
|
-
* Streams a response from the v-next network loop
|
|
2703
|
-
* @param params - Stream parameters including message
|
|
2704
|
-
* @returns Promise containing the results
|
|
2705
|
-
*/
|
|
2706
|
-
async loopStream(params, onRecord) {
|
|
2707
|
-
const response = await this.request(`/api/networks/v-next/${this.networkId}/loop-stream`, {
|
|
2708
|
-
method: "POST",
|
|
2709
|
-
body: {
|
|
2710
|
-
...params,
|
|
2711
|
-
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
2712
|
-
},
|
|
2713
|
-
stream: true
|
|
2714
|
-
});
|
|
2715
|
-
if (!response.ok) {
|
|
2716
|
-
throw new Error(`Failed to stream vNext network loop: ${response.statusText}`);
|
|
2717
|
-
}
|
|
2718
|
-
if (!response.body) {
|
|
2719
|
-
throw new Error("Response body is null");
|
|
2720
|
-
}
|
|
2721
|
-
for await (const record of this.streamProcessor(response.body)) {
|
|
2722
|
-
if (typeof record === "string") {
|
|
2723
|
-
onRecord(JSON.parse(record));
|
|
2724
|
-
} else {
|
|
2725
|
-
onRecord(record);
|
|
2726
|
-
}
|
|
2727
|
-
}
|
|
2728
|
-
}
|
|
2729
|
-
};
|
|
2730
|
-
|
|
2731
2734
|
// src/client.ts
|
|
2732
2735
|
var MastraClient = class extends BaseResource {
|
|
2733
2736
|
observability;
|
|
@@ -3069,21 +3072,6 @@ var MastraClient = class extends BaseResource {
|
|
|
3069
3072
|
return this.request(`/api/telemetry`);
|
|
3070
3073
|
}
|
|
3071
3074
|
}
|
|
3072
|
-
/**
|
|
3073
|
-
* Retrieves all available vNext networks
|
|
3074
|
-
* @returns Promise containing map of vNext network IDs to vNext network details
|
|
3075
|
-
*/
|
|
3076
|
-
getVNextNetworks() {
|
|
3077
|
-
return this.request("/api/networks/v-next");
|
|
3078
|
-
}
|
|
3079
|
-
/**
|
|
3080
|
-
* Gets a vNext network instance by ID
|
|
3081
|
-
* @param networkId - ID of the vNext network to retrieve
|
|
3082
|
-
* @returns vNext Network instance
|
|
3083
|
-
*/
|
|
3084
|
-
getVNextNetwork(networkId) {
|
|
3085
|
-
return new VNextNetwork(this.options, networkId);
|
|
3086
|
-
}
|
|
3087
3075
|
/**
|
|
3088
3076
|
* Retrieves a list of available MCP servers.
|
|
3089
3077
|
* @param params - Optional parameters for pagination (limit, offset).
|
|
@@ -3188,7 +3176,7 @@ var MastraClient = class extends BaseResource {
|
|
|
3188
3176
|
* @returns Promise containing the scorer
|
|
3189
3177
|
*/
|
|
3190
3178
|
getScorer(scorerId) {
|
|
3191
|
-
return this.request(`/api/scores/scorers/${scorerId}`);
|
|
3179
|
+
return this.request(`/api/scores/scorers/${encodeURIComponent(scorerId)}`);
|
|
3192
3180
|
}
|
|
3193
3181
|
getScoresByScorerId(params) {
|
|
3194
3182
|
const { page, perPage, scorerId, entityId, entityType } = params;
|
|
@@ -3206,7 +3194,7 @@ var MastraClient = class extends BaseResource {
|
|
|
3206
3194
|
searchParams.set("perPage", String(perPage));
|
|
3207
3195
|
}
|
|
3208
3196
|
const queryString = searchParams.toString();
|
|
3209
|
-
return this.request(`/api/scores/scorer/${scorerId}${queryString ? `?${queryString}` : ""}`);
|
|
3197
|
+
return this.request(`/api/scores/scorer/${encodeURIComponent(scorerId)}${queryString ? `?${queryString}` : ""}`);
|
|
3210
3198
|
}
|
|
3211
3199
|
/**
|
|
3212
3200
|
* Retrieves scores by run ID
|
|
@@ -3223,7 +3211,7 @@ var MastraClient = class extends BaseResource {
|
|
|
3223
3211
|
searchParams.set("perPage", String(perPage));
|
|
3224
3212
|
}
|
|
3225
3213
|
const queryString = searchParams.toString();
|
|
3226
|
-
return this.request(`/api/scores/run/${runId}${queryString ? `?${queryString}` : ""}`);
|
|
3214
|
+
return this.request(`/api/scores/run/${encodeURIComponent(runId)}${queryString ? `?${queryString}` : ""}`);
|
|
3227
3215
|
}
|
|
3228
3216
|
/**
|
|
3229
3217
|
* Retrieves scores by entity ID and type
|
|
@@ -3240,7 +3228,9 @@ var MastraClient = class extends BaseResource {
|
|
|
3240
3228
|
searchParams.set("perPage", String(perPage));
|
|
3241
3229
|
}
|
|
3242
3230
|
const queryString = searchParams.toString();
|
|
3243
|
-
return this.request(
|
|
3231
|
+
return this.request(
|
|
3232
|
+
`/api/scores/entity/${encodeURIComponent(entityType)}/${encodeURIComponent(entityId)}${queryString ? `?${queryString}` : ""}`
|
|
3233
|
+
);
|
|
3244
3234
|
}
|
|
3245
3235
|
/**
|
|
3246
3236
|
* Saves a score
|
|
@@ -3266,6 +3256,9 @@ var MastraClient = class extends BaseResource {
|
|
|
3266
3256
|
getAITraces(params) {
|
|
3267
3257
|
return this.observability.getTraces(params);
|
|
3268
3258
|
}
|
|
3259
|
+
getScoresBySpan(params) {
|
|
3260
|
+
return this.observability.getScoresBySpan(params);
|
|
3261
|
+
}
|
|
3269
3262
|
score(params) {
|
|
3270
3263
|
return this.observability.score(params);
|
|
3271
3264
|
}
|