@mastra/client-js 0.13.2 → 0.14.0-alpha.1
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 +28 -0
- package/dist/client.d.ts +3 -13
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +92 -244
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +92 -244
- package/dist/index.js.map +1 -1
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/resources/index.d.ts +0 -1
- package/dist/resources/index.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 +13 -1
- package/dist/resources/workflow.d.ts.map +1 -1
- package/dist/types.d.ts +7 -21
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/resources/legacy-workflow.d.ts +0 -90
- package/dist/resources/legacy-workflow.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -223,11 +223,7 @@ async function executeToolCallAndRespond({
|
|
|
223
223
|
}
|
|
224
224
|
);
|
|
225
225
|
const updatedMessages = [
|
|
226
|
-
|
|
227
|
-
role: "user",
|
|
228
|
-
content: params.messages
|
|
229
|
-
},
|
|
230
|
-
...response.response.messages,
|
|
226
|
+
...response.response.messages || [],
|
|
231
227
|
{
|
|
232
228
|
role: "tool",
|
|
233
229
|
content: [
|
|
@@ -368,10 +364,6 @@ var Agent = class extends BaseResource {
|
|
|
368
364
|
}
|
|
369
365
|
);
|
|
370
366
|
const updatedMessages = [
|
|
371
|
-
{
|
|
372
|
-
role: "user",
|
|
373
|
-
content: params.messages
|
|
374
|
-
},
|
|
375
367
|
...response.response.messages,
|
|
376
368
|
{
|
|
377
369
|
role: "tool",
|
|
@@ -1042,9 +1034,11 @@ var Agent = class extends BaseResource {
|
|
|
1042
1034
|
if (toolCall) {
|
|
1043
1035
|
toolCalls.push(toolCall);
|
|
1044
1036
|
}
|
|
1037
|
+
let shouldExecuteClientTool = false;
|
|
1045
1038
|
for (const toolCall2 of toolCalls) {
|
|
1046
1039
|
const clientTool = processedParams.clientTools?.[toolCall2.toolName];
|
|
1047
1040
|
if (clientTool && clientTool.execute) {
|
|
1041
|
+
shouldExecuteClientTool = true;
|
|
1048
1042
|
const result = await clientTool.execute(
|
|
1049
1043
|
{
|
|
1050
1044
|
context: toolCall2?.args,
|
|
@@ -1081,9 +1075,7 @@ var Agent = class extends BaseResource {
|
|
|
1081
1075
|
toolInvocation.state = "result";
|
|
1082
1076
|
toolInvocation.result = result;
|
|
1083
1077
|
}
|
|
1084
|
-
const
|
|
1085
|
-
const messageArray = Array.isArray(originalMessages) ? originalMessages : [originalMessages];
|
|
1086
|
-
const updatedMessages = lastMessage != null ? [...messageArray, ...messages.filter((m) => m.id !== lastMessage.id), lastMessage] : [...messageArray, ...messages];
|
|
1078
|
+
const updatedMessages = lastMessage != null ? [...messages.filter((m) => m.id !== lastMessage.id), lastMessage] : [...messages];
|
|
1087
1079
|
this.processStreamResponse_vNext(
|
|
1088
1080
|
{
|
|
1089
1081
|
...processedParams,
|
|
@@ -1095,6 +1087,11 @@ var Agent = class extends BaseResource {
|
|
|
1095
1087
|
});
|
|
1096
1088
|
}
|
|
1097
1089
|
}
|
|
1090
|
+
if (!shouldExecuteClientTool) {
|
|
1091
|
+
setTimeout(() => {
|
|
1092
|
+
writable.close();
|
|
1093
|
+
}, 0);
|
|
1094
|
+
}
|
|
1098
1095
|
} else {
|
|
1099
1096
|
setTimeout(() => {
|
|
1100
1097
|
writable.close();
|
|
@@ -1259,12 +1256,10 @@ var Agent = class extends BaseResource {
|
|
|
1259
1256
|
} finally {
|
|
1260
1257
|
writer.releaseLock();
|
|
1261
1258
|
}
|
|
1262
|
-
const originalMessages = processedParams.messages;
|
|
1263
|
-
const messageArray = Array.isArray(originalMessages) ? originalMessages : [originalMessages];
|
|
1264
1259
|
this.processStreamResponse(
|
|
1265
1260
|
{
|
|
1266
1261
|
...processedParams,
|
|
1267
|
-
messages: [...
|
|
1262
|
+
messages: [...messages.filter((m) => m.id !== lastMessage.id), lastMessage]
|
|
1268
1263
|
},
|
|
1269
1264
|
writable
|
|
1270
1265
|
).catch((error) => {
|
|
@@ -1511,193 +1506,6 @@ var Vector = class extends BaseResource {
|
|
|
1511
1506
|
}
|
|
1512
1507
|
};
|
|
1513
1508
|
|
|
1514
|
-
// src/resources/legacy-workflow.ts
|
|
1515
|
-
var RECORD_SEPARATOR = "";
|
|
1516
|
-
var LegacyWorkflow = class extends BaseResource {
|
|
1517
|
-
constructor(options, workflowId) {
|
|
1518
|
-
super(options);
|
|
1519
|
-
this.workflowId = workflowId;
|
|
1520
|
-
}
|
|
1521
|
-
/**
|
|
1522
|
-
* Retrieves details about the legacy workflow
|
|
1523
|
-
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1524
|
-
* @returns Promise containing legacy workflow details including steps and graphs
|
|
1525
|
-
*/
|
|
1526
|
-
details(runtimeContext) {
|
|
1527
|
-
return this.request(`/api/workflows/legacy/${this.workflowId}${runtimeContextQueryString(runtimeContext)}`);
|
|
1528
|
-
}
|
|
1529
|
-
/**
|
|
1530
|
-
* Retrieves all runs for a legacy workflow
|
|
1531
|
-
* @param params - Parameters for filtering runs
|
|
1532
|
-
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
1533
|
-
* @returns Promise containing legacy workflow runs array
|
|
1534
|
-
*/
|
|
1535
|
-
runs(params, runtimeContext) {
|
|
1536
|
-
const runtimeContextParam = base64RuntimeContext(parseClientRuntimeContext(runtimeContext));
|
|
1537
|
-
const searchParams = new URLSearchParams();
|
|
1538
|
-
if (params?.fromDate) {
|
|
1539
|
-
searchParams.set("fromDate", params.fromDate.toISOString());
|
|
1540
|
-
}
|
|
1541
|
-
if (params?.toDate) {
|
|
1542
|
-
searchParams.set("toDate", params.toDate.toISOString());
|
|
1543
|
-
}
|
|
1544
|
-
if (params?.limit) {
|
|
1545
|
-
searchParams.set("limit", String(params.limit));
|
|
1546
|
-
}
|
|
1547
|
-
if (params?.offset) {
|
|
1548
|
-
searchParams.set("offset", String(params.offset));
|
|
1549
|
-
}
|
|
1550
|
-
if (params?.resourceId) {
|
|
1551
|
-
searchParams.set("resourceId", params.resourceId);
|
|
1552
|
-
}
|
|
1553
|
-
if (runtimeContextParam) {
|
|
1554
|
-
searchParams.set("runtimeContext", runtimeContextParam);
|
|
1555
|
-
}
|
|
1556
|
-
if (searchParams.size) {
|
|
1557
|
-
return this.request(`/api/workflows/legacy/${this.workflowId}/runs?${searchParams}`);
|
|
1558
|
-
} else {
|
|
1559
|
-
return this.request(`/api/workflows/legacy/${this.workflowId}/runs`);
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
/**
|
|
1563
|
-
* Creates a new legacy workflow run
|
|
1564
|
-
* @returns Promise containing the generated run ID
|
|
1565
|
-
*/
|
|
1566
|
-
createRun(params) {
|
|
1567
|
-
const searchParams = new URLSearchParams();
|
|
1568
|
-
if (!!params?.runId) {
|
|
1569
|
-
searchParams.set("runId", params.runId);
|
|
1570
|
-
}
|
|
1571
|
-
return this.request(`/api/workflows/legacy/${this.workflowId}/create-run?${searchParams.toString()}`, {
|
|
1572
|
-
method: "POST"
|
|
1573
|
-
});
|
|
1574
|
-
}
|
|
1575
|
-
/**
|
|
1576
|
-
* Starts a legacy workflow run synchronously without waiting for the workflow to complete
|
|
1577
|
-
* @param params - Object containing the runId and triggerData
|
|
1578
|
-
* @returns Promise containing success message
|
|
1579
|
-
*/
|
|
1580
|
-
start(params) {
|
|
1581
|
-
return this.request(`/api/workflows/legacy/${this.workflowId}/start?runId=${params.runId}`, {
|
|
1582
|
-
method: "POST",
|
|
1583
|
-
body: params?.triggerData
|
|
1584
|
-
});
|
|
1585
|
-
}
|
|
1586
|
-
/**
|
|
1587
|
-
* Resumes a suspended legacy workflow step synchronously without waiting for the workflow to complete
|
|
1588
|
-
* @param stepId - ID of the step to resume
|
|
1589
|
-
* @param runId - ID of the legacy workflow run
|
|
1590
|
-
* @param context - Context to resume the legacy workflow with
|
|
1591
|
-
* @returns Promise containing the legacy workflow resume results
|
|
1592
|
-
*/
|
|
1593
|
-
resume({
|
|
1594
|
-
stepId,
|
|
1595
|
-
runId,
|
|
1596
|
-
context
|
|
1597
|
-
}) {
|
|
1598
|
-
return this.request(`/api/workflows/legacy/${this.workflowId}/resume?runId=${runId}`, {
|
|
1599
|
-
method: "POST",
|
|
1600
|
-
body: {
|
|
1601
|
-
stepId,
|
|
1602
|
-
context
|
|
1603
|
-
}
|
|
1604
|
-
});
|
|
1605
|
-
}
|
|
1606
|
-
/**
|
|
1607
|
-
* Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
|
|
1608
|
-
* @param params - Object containing the optional runId and triggerData
|
|
1609
|
-
* @returns Promise containing the workflow execution results
|
|
1610
|
-
*/
|
|
1611
|
-
startAsync(params) {
|
|
1612
|
-
const searchParams = new URLSearchParams();
|
|
1613
|
-
if (!!params?.runId) {
|
|
1614
|
-
searchParams.set("runId", params.runId);
|
|
1615
|
-
}
|
|
1616
|
-
return this.request(`/api/workflows/legacy/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
1617
|
-
method: "POST",
|
|
1618
|
-
body: params?.triggerData
|
|
1619
|
-
});
|
|
1620
|
-
}
|
|
1621
|
-
/**
|
|
1622
|
-
* Resumes a suspended legacy workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
1623
|
-
* @param params - Object containing the runId, stepId, and context
|
|
1624
|
-
* @returns Promise containing the workflow resume results
|
|
1625
|
-
*/
|
|
1626
|
-
resumeAsync(params) {
|
|
1627
|
-
return this.request(`/api/workflows/legacy/${this.workflowId}/resume-async?runId=${params.runId}`, {
|
|
1628
|
-
method: "POST",
|
|
1629
|
-
body: {
|
|
1630
|
-
stepId: params.stepId,
|
|
1631
|
-
context: params.context
|
|
1632
|
-
}
|
|
1633
|
-
});
|
|
1634
|
-
}
|
|
1635
|
-
/**
|
|
1636
|
-
* Creates an async generator that processes a readable stream and yields records
|
|
1637
|
-
* separated by the Record Separator character (\x1E)
|
|
1638
|
-
*
|
|
1639
|
-
* @param stream - The readable stream to process
|
|
1640
|
-
* @returns An async generator that yields parsed records
|
|
1641
|
-
*/
|
|
1642
|
-
async *streamProcessor(stream) {
|
|
1643
|
-
const reader = stream.getReader();
|
|
1644
|
-
let doneReading = false;
|
|
1645
|
-
let buffer = "";
|
|
1646
|
-
try {
|
|
1647
|
-
while (!doneReading) {
|
|
1648
|
-
const { done, value } = await reader.read();
|
|
1649
|
-
doneReading = done;
|
|
1650
|
-
if (done && !value) continue;
|
|
1651
|
-
try {
|
|
1652
|
-
const decoded = value ? new TextDecoder().decode(value) : "";
|
|
1653
|
-
const chunks = (buffer + decoded).split(RECORD_SEPARATOR);
|
|
1654
|
-
buffer = chunks.pop() || "";
|
|
1655
|
-
for (const chunk of chunks) {
|
|
1656
|
-
if (chunk) {
|
|
1657
|
-
if (typeof chunk === "string") {
|
|
1658
|
-
try {
|
|
1659
|
-
const parsedChunk = JSON.parse(chunk);
|
|
1660
|
-
yield parsedChunk;
|
|
1661
|
-
} catch {
|
|
1662
|
-
}
|
|
1663
|
-
}
|
|
1664
|
-
}
|
|
1665
|
-
}
|
|
1666
|
-
} catch {
|
|
1667
|
-
}
|
|
1668
|
-
}
|
|
1669
|
-
if (buffer) {
|
|
1670
|
-
try {
|
|
1671
|
-
yield JSON.parse(buffer);
|
|
1672
|
-
} catch {
|
|
1673
|
-
}
|
|
1674
|
-
}
|
|
1675
|
-
} finally {
|
|
1676
|
-
reader.cancel().catch(() => {
|
|
1677
|
-
});
|
|
1678
|
-
}
|
|
1679
|
-
}
|
|
1680
|
-
/**
|
|
1681
|
-
* Watches legacy workflow transitions in real-time
|
|
1682
|
-
* @param runId - Optional run ID to filter the watch stream
|
|
1683
|
-
* @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
|
|
1684
|
-
*/
|
|
1685
|
-
async watch({ runId }, onRecord) {
|
|
1686
|
-
const response = await this.request(`/api/workflows/legacy/${this.workflowId}/watch?runId=${runId}`, {
|
|
1687
|
-
stream: true
|
|
1688
|
-
});
|
|
1689
|
-
if (!response.ok) {
|
|
1690
|
-
throw new Error(`Failed to watch legacy workflow: ${response.statusText}`);
|
|
1691
|
-
}
|
|
1692
|
-
if (!response.body) {
|
|
1693
|
-
throw new Error("Response body is null");
|
|
1694
|
-
}
|
|
1695
|
-
for await (const record of this.streamProcessor(response.body)) {
|
|
1696
|
-
onRecord(record);
|
|
1697
|
-
}
|
|
1698
|
-
}
|
|
1699
|
-
};
|
|
1700
|
-
|
|
1701
1509
|
// src/resources/tool.ts
|
|
1702
1510
|
var Tool = class extends BaseResource {
|
|
1703
1511
|
constructor(options, toolId) {
|
|
@@ -1734,7 +1542,7 @@ var Tool = class extends BaseResource {
|
|
|
1734
1542
|
};
|
|
1735
1543
|
|
|
1736
1544
|
// src/resources/workflow.ts
|
|
1737
|
-
var
|
|
1545
|
+
var RECORD_SEPARATOR = "";
|
|
1738
1546
|
var Workflow = class extends BaseResource {
|
|
1739
1547
|
constructor(options, workflowId) {
|
|
1740
1548
|
super(options);
|
|
@@ -1758,7 +1566,7 @@ var Workflow = class extends BaseResource {
|
|
|
1758
1566
|
if (done && !value) continue;
|
|
1759
1567
|
try {
|
|
1760
1568
|
const decoded = value ? new TextDecoder().decode(value) : "";
|
|
1761
|
-
const chunks = (buffer + decoded).split(
|
|
1569
|
+
const chunks = (buffer + decoded).split(RECORD_SEPARATOR);
|
|
1762
1570
|
buffer = chunks.pop() || "";
|
|
1763
1571
|
for (const chunk of chunks) {
|
|
1764
1572
|
if (chunk) {
|
|
@@ -1896,10 +1704,20 @@ var Workflow = class extends BaseResource {
|
|
|
1896
1704
|
return {
|
|
1897
1705
|
runId,
|
|
1898
1706
|
start: async (p) => {
|
|
1899
|
-
return this.start({
|
|
1707
|
+
return this.start({
|
|
1708
|
+
runId,
|
|
1709
|
+
inputData: p.inputData,
|
|
1710
|
+
runtimeContext: p.runtimeContext,
|
|
1711
|
+
tracingOptions: p.tracingOptions
|
|
1712
|
+
});
|
|
1900
1713
|
},
|
|
1901
1714
|
startAsync: async (p) => {
|
|
1902
|
-
return this.startAsync({
|
|
1715
|
+
return this.startAsync({
|
|
1716
|
+
runId,
|
|
1717
|
+
inputData: p.inputData,
|
|
1718
|
+
runtimeContext: p.runtimeContext,
|
|
1719
|
+
tracingOptions: p.tracingOptions
|
|
1720
|
+
});
|
|
1903
1721
|
},
|
|
1904
1722
|
watch: async (onRecord) => {
|
|
1905
1723
|
return this.watch({ runId }, onRecord);
|
|
@@ -1908,10 +1726,22 @@ var Workflow = class extends BaseResource {
|
|
|
1908
1726
|
return this.stream({ runId, inputData: p.inputData, runtimeContext: p.runtimeContext });
|
|
1909
1727
|
},
|
|
1910
1728
|
resume: async (p) => {
|
|
1911
|
-
return this.resume({
|
|
1729
|
+
return this.resume({
|
|
1730
|
+
runId,
|
|
1731
|
+
step: p.step,
|
|
1732
|
+
resumeData: p.resumeData,
|
|
1733
|
+
runtimeContext: p.runtimeContext,
|
|
1734
|
+
tracingOptions: p.tracingOptions
|
|
1735
|
+
});
|
|
1912
1736
|
},
|
|
1913
1737
|
resumeAsync: async (p) => {
|
|
1914
|
-
return this.resumeAsync({
|
|
1738
|
+
return this.resumeAsync({
|
|
1739
|
+
runId,
|
|
1740
|
+
step: p.step,
|
|
1741
|
+
resumeData: p.resumeData,
|
|
1742
|
+
runtimeContext: p.runtimeContext,
|
|
1743
|
+
tracingOptions: p.tracingOptions
|
|
1744
|
+
});
|
|
1915
1745
|
},
|
|
1916
1746
|
resumeStreamVNext: async (p) => {
|
|
1917
1747
|
return this.resumeStreamVNext({
|
|
@@ -1932,7 +1762,7 @@ var Workflow = class extends BaseResource {
|
|
|
1932
1762
|
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
1933
1763
|
return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
|
|
1934
1764
|
method: "POST",
|
|
1935
|
-
body: { inputData: params?.inputData, runtimeContext }
|
|
1765
|
+
body: { inputData: params?.inputData, runtimeContext, tracingOptions: params.tracingOptions }
|
|
1936
1766
|
});
|
|
1937
1767
|
}
|
|
1938
1768
|
/**
|
|
@@ -1944,6 +1774,7 @@ var Workflow = class extends BaseResource {
|
|
|
1944
1774
|
step,
|
|
1945
1775
|
runId,
|
|
1946
1776
|
resumeData,
|
|
1777
|
+
tracingOptions,
|
|
1947
1778
|
...rest
|
|
1948
1779
|
}) {
|
|
1949
1780
|
const runtimeContext = parseClientRuntimeContext(rest.runtimeContext);
|
|
@@ -1952,7 +1783,8 @@ var Workflow = class extends BaseResource {
|
|
|
1952
1783
|
body: {
|
|
1953
1784
|
step,
|
|
1954
1785
|
resumeData,
|
|
1955
|
-
runtimeContext
|
|
1786
|
+
runtimeContext,
|
|
1787
|
+
tracingOptions
|
|
1956
1788
|
}
|
|
1957
1789
|
});
|
|
1958
1790
|
}
|
|
@@ -1969,7 +1801,7 @@ var Workflow = class extends BaseResource {
|
|
|
1969
1801
|
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
1970
1802
|
return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
1971
1803
|
method: "POST",
|
|
1972
|
-
body: { inputData: params.inputData, runtimeContext }
|
|
1804
|
+
body: { inputData: params.inputData, runtimeContext, tracingOptions: params.tracingOptions }
|
|
1973
1805
|
});
|
|
1974
1806
|
}
|
|
1975
1807
|
/**
|
|
@@ -1987,7 +1819,7 @@ var Workflow = class extends BaseResource {
|
|
|
1987
1819
|
`/api/workflows/${this.workflowId}/stream?${searchParams.toString()}`,
|
|
1988
1820
|
{
|
|
1989
1821
|
method: "POST",
|
|
1990
|
-
body: { inputData: params.inputData, runtimeContext },
|
|
1822
|
+
body: { inputData: params.inputData, runtimeContext, tracingOptions: params.tracingOptions },
|
|
1991
1823
|
stream: true
|
|
1992
1824
|
}
|
|
1993
1825
|
);
|
|
@@ -2004,7 +1836,7 @@ var Workflow = class extends BaseResource {
|
|
|
2004
1836
|
async transform(chunk, controller) {
|
|
2005
1837
|
try {
|
|
2006
1838
|
const decoded = new TextDecoder().decode(chunk);
|
|
2007
|
-
const chunks = decoded.split(
|
|
1839
|
+
const chunks = decoded.split(RECORD_SEPARATOR);
|
|
2008
1840
|
for (const chunk2 of chunks) {
|
|
2009
1841
|
if (chunk2) {
|
|
2010
1842
|
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
@@ -2051,7 +1883,7 @@ var Workflow = class extends BaseResource {
|
|
|
2051
1883
|
async transform(chunk, controller) {
|
|
2052
1884
|
try {
|
|
2053
1885
|
const decoded = new TextDecoder().decode(chunk);
|
|
2054
|
-
const chunks = decoded.split(
|
|
1886
|
+
const chunks = decoded.split(RECORD_SEPARATOR);
|
|
2055
1887
|
for (const chunk2 of chunks) {
|
|
2056
1888
|
if (chunk2) {
|
|
2057
1889
|
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
@@ -2085,7 +1917,12 @@ var Workflow = class extends BaseResource {
|
|
|
2085
1917
|
`/api/workflows/${this.workflowId}/streamVNext?${searchParams.toString()}`,
|
|
2086
1918
|
{
|
|
2087
1919
|
method: "POST",
|
|
2088
|
-
body: {
|
|
1920
|
+
body: {
|
|
1921
|
+
inputData: params.inputData,
|
|
1922
|
+
runtimeContext,
|
|
1923
|
+
closeOnSuspend: params.closeOnSuspend,
|
|
1924
|
+
tracingOptions: params.tracingOptions
|
|
1925
|
+
},
|
|
2089
1926
|
stream: true
|
|
2090
1927
|
}
|
|
2091
1928
|
);
|
|
@@ -2102,7 +1939,7 @@ var Workflow = class extends BaseResource {
|
|
|
2102
1939
|
async transform(chunk, controller) {
|
|
2103
1940
|
try {
|
|
2104
1941
|
const decoded = new TextDecoder().decode(chunk);
|
|
2105
|
-
const chunks = decoded.split(
|
|
1942
|
+
const chunks = decoded.split(RECORD_SEPARATOR);
|
|
2106
1943
|
for (const chunk2 of chunks) {
|
|
2107
1944
|
if (chunk2) {
|
|
2108
1945
|
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
@@ -2133,7 +1970,8 @@ var Workflow = class extends BaseResource {
|
|
|
2133
1970
|
body: {
|
|
2134
1971
|
step: params.step,
|
|
2135
1972
|
resumeData: params.resumeData,
|
|
2136
|
-
runtimeContext
|
|
1973
|
+
runtimeContext,
|
|
1974
|
+
tracingOptions: params.tracingOptions
|
|
2137
1975
|
}
|
|
2138
1976
|
});
|
|
2139
1977
|
}
|
|
@@ -2149,7 +1987,8 @@ var Workflow = class extends BaseResource {
|
|
|
2149
1987
|
body: {
|
|
2150
1988
|
step: params.step,
|
|
2151
1989
|
resumeData: params.resumeData,
|
|
2152
|
-
runtimeContext
|
|
1990
|
+
runtimeContext,
|
|
1991
|
+
tracingOptions: params.tracingOptions
|
|
2153
1992
|
}
|
|
2154
1993
|
});
|
|
2155
1994
|
}
|
|
@@ -2189,7 +2028,7 @@ var Workflow = class extends BaseResource {
|
|
|
2189
2028
|
async start(controller) {
|
|
2190
2029
|
try {
|
|
2191
2030
|
for await (const record of records) {
|
|
2192
|
-
const json = JSON.stringify(record) +
|
|
2031
|
+
const json = JSON.stringify(record) + RECORD_SEPARATOR;
|
|
2193
2032
|
controller.enqueue(encoder.encode(json));
|
|
2194
2033
|
}
|
|
2195
2034
|
controller.close();
|
|
@@ -2312,7 +2151,7 @@ var MCPTool = class extends BaseResource {
|
|
|
2312
2151
|
};
|
|
2313
2152
|
|
|
2314
2153
|
// src/resources/agent-builder.ts
|
|
2315
|
-
var
|
|
2154
|
+
var RECORD_SEPARATOR2 = "";
|
|
2316
2155
|
var AgentBuilder = class extends BaseResource {
|
|
2317
2156
|
constructor(options, actionId) {
|
|
2318
2157
|
super(options);
|
|
@@ -2452,7 +2291,7 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2452
2291
|
if (done && !value) continue;
|
|
2453
2292
|
try {
|
|
2454
2293
|
const decoded = value ? new TextDecoder().decode(value) : "";
|
|
2455
|
-
const chunks = (buffer + decoded).split(
|
|
2294
|
+
const chunks = (buffer + decoded).split(RECORD_SEPARATOR2);
|
|
2456
2295
|
buffer = chunks.pop() || "";
|
|
2457
2296
|
for (const chunk of chunks) {
|
|
2458
2297
|
if (chunk) {
|
|
@@ -2509,7 +2348,7 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2509
2348
|
async transform(chunk, controller) {
|
|
2510
2349
|
try {
|
|
2511
2350
|
const decoded = new TextDecoder().decode(chunk);
|
|
2512
|
-
const chunks = decoded.split(
|
|
2351
|
+
const chunks = decoded.split(RECORD_SEPARATOR2);
|
|
2513
2352
|
for (const chunk2 of chunks) {
|
|
2514
2353
|
if (chunk2) {
|
|
2515
2354
|
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
@@ -2558,7 +2397,7 @@ var AgentBuilder = class extends BaseResource {
|
|
|
2558
2397
|
async transform(chunk, controller) {
|
|
2559
2398
|
try {
|
|
2560
2399
|
const decoded = new TextDecoder().decode(chunk);
|
|
2561
|
-
const chunks = decoded.split(
|
|
2400
|
+
const chunks = decoded.split(RECORD_SEPARATOR2);
|
|
2562
2401
|
for (const chunk2 of chunks) {
|
|
2563
2402
|
if (chunk2) {
|
|
2564
2403
|
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
@@ -2729,6 +2568,25 @@ var Observability = class extends BaseResource {
|
|
|
2729
2568
|
const queryString = searchParams.toString();
|
|
2730
2569
|
return this.request(`/api/observability/traces${queryString ? `?${queryString}` : ""}`);
|
|
2731
2570
|
}
|
|
2571
|
+
/**
|
|
2572
|
+
* Retrieves scores by trace ID and span ID
|
|
2573
|
+
* @param params - Parameters containing trace ID, span ID, and pagination options
|
|
2574
|
+
* @returns Promise containing scores and pagination info
|
|
2575
|
+
*/
|
|
2576
|
+
getScoresBySpan(params) {
|
|
2577
|
+
const { traceId, spanId, page, perPage } = params;
|
|
2578
|
+
const searchParams = new URLSearchParams();
|
|
2579
|
+
if (page !== void 0) {
|
|
2580
|
+
searchParams.set("page", String(page));
|
|
2581
|
+
}
|
|
2582
|
+
if (perPage !== void 0) {
|
|
2583
|
+
searchParams.set("perPage", String(perPage));
|
|
2584
|
+
}
|
|
2585
|
+
const queryString = searchParams.toString();
|
|
2586
|
+
return this.request(
|
|
2587
|
+
`/api/observability/traces/${encodeURIComponent(traceId)}/${encodeURIComponent(spanId)}/scores${queryString ? `?${queryString}` : ""}`
|
|
2588
|
+
);
|
|
2589
|
+
}
|
|
2732
2590
|
score(params) {
|
|
2733
2591
|
return this.request(`/api/observability/traces/score`, {
|
|
2734
2592
|
method: "POST",
|
|
@@ -2801,7 +2659,7 @@ var NetworkMemoryThread = class extends BaseResource {
|
|
|
2801
2659
|
};
|
|
2802
2660
|
|
|
2803
2661
|
// src/resources/vNextNetwork.ts
|
|
2804
|
-
var
|
|
2662
|
+
var RECORD_SEPARATOR3 = "";
|
|
2805
2663
|
var VNextNetwork = class extends BaseResource {
|
|
2806
2664
|
constructor(options, networkId) {
|
|
2807
2665
|
super(options);
|
|
@@ -2854,7 +2712,7 @@ var VNextNetwork = class extends BaseResource {
|
|
|
2854
2712
|
if (done && !value) continue;
|
|
2855
2713
|
try {
|
|
2856
2714
|
const decoded = value ? new TextDecoder().decode(value) : "";
|
|
2857
|
-
const chunks = (buffer + decoded).split(
|
|
2715
|
+
const chunks = (buffer + decoded).split(RECORD_SEPARATOR3);
|
|
2858
2716
|
buffer = chunks.pop() || "";
|
|
2859
2717
|
for (const chunk of chunks) {
|
|
2860
2718
|
if (chunk) {
|
|
@@ -3100,21 +2958,6 @@ var MastraClient = class extends BaseResource {
|
|
|
3100
2958
|
getTool(toolId) {
|
|
3101
2959
|
return new Tool(this.options, toolId);
|
|
3102
2960
|
}
|
|
3103
|
-
/**
|
|
3104
|
-
* Retrieves all available legacy workflows
|
|
3105
|
-
* @returns Promise containing map of legacy workflow IDs to legacy workflow details
|
|
3106
|
-
*/
|
|
3107
|
-
getLegacyWorkflows() {
|
|
3108
|
-
return this.request("/api/workflows/legacy");
|
|
3109
|
-
}
|
|
3110
|
-
/**
|
|
3111
|
-
* Gets a legacy workflow instance by ID
|
|
3112
|
-
* @param workflowId - ID of the legacy workflow to retrieve
|
|
3113
|
-
* @returns Legacy Workflow instance
|
|
3114
|
-
*/
|
|
3115
|
-
getLegacyWorkflow(workflowId) {
|
|
3116
|
-
return new LegacyWorkflow(this.options, workflowId);
|
|
3117
|
-
}
|
|
3118
2961
|
/**
|
|
3119
2962
|
* Retrieves all available workflows
|
|
3120
2963
|
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
@@ -3414,7 +3257,7 @@ var MastraClient = class extends BaseResource {
|
|
|
3414
3257
|
* @returns Promise containing the scorer
|
|
3415
3258
|
*/
|
|
3416
3259
|
getScorer(scorerId) {
|
|
3417
|
-
return this.request(`/api/scores/scorers/${scorerId}`);
|
|
3260
|
+
return this.request(`/api/scores/scorers/${encodeURIComponent(scorerId)}`);
|
|
3418
3261
|
}
|
|
3419
3262
|
getScoresByScorerId(params) {
|
|
3420
3263
|
const { page, perPage, scorerId, entityId, entityType } = params;
|
|
@@ -3432,7 +3275,7 @@ var MastraClient = class extends BaseResource {
|
|
|
3432
3275
|
searchParams.set("perPage", String(perPage));
|
|
3433
3276
|
}
|
|
3434
3277
|
const queryString = searchParams.toString();
|
|
3435
|
-
return this.request(`/api/scores/scorer/${scorerId}${queryString ? `?${queryString}` : ""}`);
|
|
3278
|
+
return this.request(`/api/scores/scorer/${encodeURIComponent(scorerId)}${queryString ? `?${queryString}` : ""}`);
|
|
3436
3279
|
}
|
|
3437
3280
|
/**
|
|
3438
3281
|
* Retrieves scores by run ID
|
|
@@ -3449,7 +3292,7 @@ var MastraClient = class extends BaseResource {
|
|
|
3449
3292
|
searchParams.set("perPage", String(perPage));
|
|
3450
3293
|
}
|
|
3451
3294
|
const queryString = searchParams.toString();
|
|
3452
|
-
return this.request(`/api/scores/run/${runId}${queryString ? `?${queryString}` : ""}`);
|
|
3295
|
+
return this.request(`/api/scores/run/${encodeURIComponent(runId)}${queryString ? `?${queryString}` : ""}`);
|
|
3453
3296
|
}
|
|
3454
3297
|
/**
|
|
3455
3298
|
* Retrieves scores by entity ID and type
|
|
@@ -3466,7 +3309,9 @@ var MastraClient = class extends BaseResource {
|
|
|
3466
3309
|
searchParams.set("perPage", String(perPage));
|
|
3467
3310
|
}
|
|
3468
3311
|
const queryString = searchParams.toString();
|
|
3469
|
-
return this.request(
|
|
3312
|
+
return this.request(
|
|
3313
|
+
`/api/scores/entity/${encodeURIComponent(entityType)}/${encodeURIComponent(entityId)}${queryString ? `?${queryString}` : ""}`
|
|
3314
|
+
);
|
|
3470
3315
|
}
|
|
3471
3316
|
/**
|
|
3472
3317
|
* Saves a score
|
|
@@ -3492,6 +3337,9 @@ var MastraClient = class extends BaseResource {
|
|
|
3492
3337
|
getAITraces(params) {
|
|
3493
3338
|
return this.observability.getTraces(params);
|
|
3494
3339
|
}
|
|
3340
|
+
getScoresBySpan(params) {
|
|
3341
|
+
return this.observability.getScoresBySpan(params);
|
|
3342
|
+
}
|
|
3495
3343
|
score(params) {
|
|
3496
3344
|
return this.observability.score(params);
|
|
3497
3345
|
}
|