@mastra/client-js 0.14.1 → 0.15.0-alpha.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/CHANGELOG.md +15 -0
- package/README.md +4 -4
- package/dist/client.d.ts +1 -13
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +103 -184
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +103 -184
- package/dist/index.js.map +1 -1
- package/dist/resources/agent.d.ts +24 -31
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/resources/workflow.d.ts +10 -7
- package/dist/resources/workflow.d.ts.map +1 -1
- package/dist/types.d.ts +11 -3
- 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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 0.15.0-alpha.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Breaking change to move the agent.streamVNext/generateVNext implementation to the default stream/generate. The old stream/generate have now been moved to streamLegacy and generateLegacy ([#8097](https://github.com/mastra-ai/mastra/pull/8097))
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Fix an issue preventing showing working memory and semantic recall in the playground ([#8358](https://github.com/mastra-ai/mastra/pull/8358))
|
|
12
|
+
|
|
13
|
+
- Add observe strean to get streans after workflow has been interrupted ([#8318](https://github.com/mastra-ai/mastra/pull/8318))
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`00cb6bd`](https://github.com/mastra-ai/mastra/commit/00cb6bdf78737c0fac14a5a0c7b532a11e38558a), [`869ba22`](https://github.com/mastra-ai/mastra/commit/869ba222e1d6b58fc1b65e7c9fd55ca4e01b8c2f), [`1b73665`](https://github.com/mastra-ai/mastra/commit/1b73665e8e23f5c09d49fcf3e7d709c75259259e), [`f7d7475`](https://github.com/mastra-ai/mastra/commit/f7d747507341aef60ed39e4b49318db1f86034a6), [`084b77b`](https://github.com/mastra-ai/mastra/commit/084b77b2955960e0190af8db3f77138aa83ed65c), [`a93ff84`](https://github.com/mastra-ai/mastra/commit/a93ff84b5e1af07ee236ac8873dac9b49aa5d501), [`bc5aacb`](https://github.com/mastra-ai/mastra/commit/bc5aacb646d468d325327e36117129f28cd13bf6), [`6b5af12`](https://github.com/mastra-ai/mastra/commit/6b5af12ce9e09066e0c32e821c203a6954498bea), [`bf60e4a`](https://github.com/mastra-ai/mastra/commit/bf60e4a89c515afd9570b7b79f33b95e7d07c397), [`d41aee5`](https://github.com/mastra-ai/mastra/commit/d41aee526d124e35f42720a08e64043229193679), [`e8fe13c`](https://github.com/mastra-ai/mastra/commit/e8fe13c4b4c255a42520127797ec394310f7c919), [`3ca833d`](https://github.com/mastra-ai/mastra/commit/3ca833dc994c38e3c9b4f9b4478a61cd8e07b32a), [`1edb8d1`](https://github.com/mastra-ai/mastra/commit/1edb8d1cfb963e72a12412990fb9170936c9904c), [`fbf6e32`](https://github.com/mastra-ai/mastra/commit/fbf6e324946332d0f5ed8930bf9d4d4479cefd7a), [`4753027`](https://github.com/mastra-ai/mastra/commit/4753027ee889288775c6958bdfeda03ff909af67)]:
|
|
16
|
+
- @mastra/core@0.20.0-alpha.0
|
|
17
|
+
|
|
3
18
|
## 0.14.1
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -53,10 +53,10 @@ const client = new MastraClient({
|
|
|
53
53
|
- `getAgents()`: Get all available agents
|
|
54
54
|
- `getAgent(agentId)`: Get a specific agent instance
|
|
55
55
|
- `agent.details()`: Get agent details
|
|
56
|
-
|
|
57
|
-
- `agent.
|
|
58
|
-
- `agent.stream(params)`: Stream a response
|
|
59
|
-
- `agent.
|
|
56
|
+
- `agent.generate(params)`: Generate a response
|
|
57
|
+
- `agent.generateLegacy(params)`: Legacy API for generating a response (V1 models)
|
|
58
|
+
- `agent.stream(params)`: Stream a response
|
|
59
|
+
- `agent.streamLegacy(params)`: Legacy API for streaming a response (V1 models)
|
|
60
60
|
- `agent.getTool(toolId)`: Get agent tool details
|
|
61
61
|
- `agent.evals()`: Get agent evaluations
|
|
62
62
|
- `agent.liveEvals()`: Get live evaluations
|
package/dist/client.d.ts
CHANGED
|
@@ -3,8 +3,7 @@ import type { ServerDetailInfo } from '@mastra/core/mcp';
|
|
|
3
3
|
import type { RuntimeContext } from '@mastra/core/runtime-context';
|
|
4
4
|
import { Agent, MemoryThread, Tool, Workflow, Vector, BaseResource, A2A, MCPTool, AgentBuilder } from './resources/index.js';
|
|
5
5
|
import { NetworkMemoryThread } from './resources/network-memory-thread.js';
|
|
6
|
-
import {
|
|
7
|
-
import type { ClientOptions, CreateMemoryThreadParams, CreateMemoryThreadResponse, GetAgentResponse, GetLogParams, GetLogsParams, GetLogsResponse, GetMemoryThreadParams, GetMemoryThreadResponse, GetTelemetryParams, GetTelemetryResponse, GetToolResponse, GetWorkflowResponse, SaveMessageToMemoryParams, SaveMessageToMemoryResponse, McpServerListResponse, McpServerToolListResponse, GetVNextNetworkResponse, GetNetworkMemoryThreadParams, CreateNetworkMemoryThreadParams, SaveNetworkMessageToMemoryParams, GetScorerResponse, GetScoresByScorerIdParams, GetScoresResponse, GetScoresByRunIdParams, GetScoresByEntityIdParams, GetScoresBySpanParams, SaveScoreParams, SaveScoreResponse, GetAITracesResponse, GetMemoryConfigParams, GetMemoryConfigResponse, GetMemoryThreadMessagesResponse } from './types.js';
|
|
6
|
+
import type { ClientOptions, CreateMemoryThreadParams, CreateMemoryThreadResponse, GetAgentResponse, GetLogParams, GetLogsParams, GetLogsResponse, GetMemoryThreadParams, GetMemoryThreadResponse, GetTelemetryParams, GetTelemetryResponse, GetToolResponse, GetWorkflowResponse, SaveMessageToMemoryParams, SaveMessageToMemoryResponse, McpServerListResponse, McpServerToolListResponse, GetNetworkMemoryThreadParams, CreateNetworkMemoryThreadParams, SaveNetworkMessageToMemoryParams, GetScorerResponse, GetScoresByScorerIdParams, GetScoresResponse, GetScoresByRunIdParams, GetScoresByEntityIdParams, GetScoresBySpanParams, SaveScoreParams, SaveScoreResponse, GetAITracesResponse, GetMemoryConfigParams, GetMemoryConfigResponse, GetMemoryThreadMessagesResponse } from './types.js';
|
|
8
7
|
export declare class MastraClient extends BaseResource {
|
|
9
8
|
private observability;
|
|
10
9
|
constructor(options: ClientOptions);
|
|
@@ -164,17 +163,6 @@ export declare class MastraClient extends BaseResource {
|
|
|
164
163
|
* @returns Promise containing telemetry data
|
|
165
164
|
*/
|
|
166
165
|
getTelemetry(params?: GetTelemetryParams): Promise<GetTelemetryResponse>;
|
|
167
|
-
/**
|
|
168
|
-
* Retrieves all available vNext networks
|
|
169
|
-
* @returns Promise containing map of vNext network IDs to vNext network details
|
|
170
|
-
*/
|
|
171
|
-
getVNextNetworks(): Promise<Array<GetVNextNetworkResponse>>;
|
|
172
|
-
/**
|
|
173
|
-
* Gets a vNext network instance by ID
|
|
174
|
-
* @param networkId - ID of the vNext network to retrieve
|
|
175
|
-
* @returns vNext Network instance
|
|
176
|
-
*/
|
|
177
|
-
getVNextNetwork(networkId: string): VNextNetwork;
|
|
178
166
|
/**
|
|
179
167
|
* Retrieves a list of available MCP servers.
|
|
180
168
|
* @param params - Optional parameters for pagination (limit, offset).
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EACL,KAAK,EACL,YAAY,EACZ,IAAI,EACJ,QA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AAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAqBzF;;;;OAIG;IACI,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAenF;;;;OAIG;IACI,mBAAmB,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAiBzF;;;;OAIG;IACI,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAOrE;;;OAGG;IACH,iBAAiB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAItC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAInD,WAAW,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAIvE,eAAe,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAI1E,KAAK,CAAC,MAAM,EAAE;QACZ,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,KAAK,CAAC;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,MAAM,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KACtD,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAGjD"}
|
package/dist/index.cjs
CHANGED
|
@@ -323,12 +323,6 @@ var Agent = class extends BaseResource {
|
|
|
323
323
|
details(runtimeContext) {
|
|
324
324
|
return this.request(`/api/agents/${this.agentId}${runtimeContextQueryString(runtimeContext)}`);
|
|
325
325
|
}
|
|
326
|
-
async generate(params) {
|
|
327
|
-
console.warn(
|
|
328
|
-
"Deprecation NOTICE: Generate method will switch to use generateVNext implementation the week of September 30th, 2025. Please use generateLegacy if you don't want to upgrade just yet."
|
|
329
|
-
);
|
|
330
|
-
return this.generateLegacy(params);
|
|
331
|
-
}
|
|
332
326
|
async generateLegacy(params) {
|
|
333
327
|
const processedParams = {
|
|
334
328
|
...params,
|
|
@@ -392,7 +386,7 @@ var Agent = class extends BaseResource {
|
|
|
392
386
|
}
|
|
393
387
|
return response;
|
|
394
388
|
}
|
|
395
|
-
async
|
|
389
|
+
async generate(messagesOrParams, options) {
|
|
396
390
|
let params;
|
|
397
391
|
if (typeof messagesOrParams === "object" && "messages" in messagesOrParams) {
|
|
398
392
|
params = messagesOrParams;
|
|
@@ -414,7 +408,7 @@ var Agent = class extends BaseResource {
|
|
|
414
408
|
};
|
|
415
409
|
const { runId, resourceId, threadId, runtimeContext } = processedParams;
|
|
416
410
|
const response = await this.request(
|
|
417
|
-
`/api/agents/${this.agentId}/generate
|
|
411
|
+
`/api/agents/${this.agentId}/generate`,
|
|
418
412
|
{
|
|
419
413
|
method: "POST",
|
|
420
414
|
body: processedParams
|
|
@@ -428,7 +422,7 @@ var Agent = class extends BaseResource {
|
|
|
428
422
|
resourceId,
|
|
429
423
|
threadId,
|
|
430
424
|
runtimeContext,
|
|
431
|
-
respondFn: this.
|
|
425
|
+
respondFn: this.generate.bind(this)
|
|
432
426
|
});
|
|
433
427
|
}
|
|
434
428
|
return response;
|
|
@@ -695,17 +689,6 @@ var Agent = class extends BaseResource {
|
|
|
695
689
|
});
|
|
696
690
|
onFinish?.({ message, finishReason, usage });
|
|
697
691
|
}
|
|
698
|
-
/**
|
|
699
|
-
* Streams a response from the agent
|
|
700
|
-
* @param params - Stream parameters including prompt
|
|
701
|
-
* @returns Promise containing the enhanced Response object with processDataStream method
|
|
702
|
-
*/
|
|
703
|
-
async stream(params) {
|
|
704
|
-
console.warn(
|
|
705
|
-
"Deprecation NOTICE:\nStream method will switch to use streamVNext implementation the week of September 30th, 2025. Please use streamLegacy if you don't want to upgrade just yet."
|
|
706
|
-
);
|
|
707
|
-
return this.streamLegacy(params);
|
|
708
|
-
}
|
|
709
692
|
/**
|
|
710
693
|
* Streams a response from the agent
|
|
711
694
|
* @param params - Stream parameters including prompt
|
|
@@ -988,7 +971,7 @@ var Agent = class extends BaseResource {
|
|
|
988
971
|
onFinish?.({ message, finishReason, usage });
|
|
989
972
|
}
|
|
990
973
|
async processStreamResponse_vNext(processedParams, writable) {
|
|
991
|
-
const response = await this.request(`/api/agents/${this.agentId}/stream
|
|
974
|
+
const response = await this.request(`/api/agents/${this.agentId}/stream`, {
|
|
992
975
|
method: "POST",
|
|
993
976
|
body: processedParams,
|
|
994
977
|
stream: true
|
|
@@ -1137,7 +1120,7 @@ var Agent = class extends BaseResource {
|
|
|
1137
1120
|
};
|
|
1138
1121
|
return streamResponse;
|
|
1139
1122
|
}
|
|
1140
|
-
async
|
|
1123
|
+
async stream(messagesOrParams, options) {
|
|
1141
1124
|
let params;
|
|
1142
1125
|
if (typeof messagesOrParams === "object" && "messages" in messagesOrParams) {
|
|
1143
1126
|
params = messagesOrParams;
|
|
@@ -1362,6 +1345,12 @@ var Agent = class extends BaseResource {
|
|
|
1362
1345
|
body: params
|
|
1363
1346
|
});
|
|
1364
1347
|
}
|
|
1348
|
+
async generateVNext(_messagesOrParams, _options) {
|
|
1349
|
+
throw new Error("generateVNext has been renamed to generate. Please use generate instead.");
|
|
1350
|
+
}
|
|
1351
|
+
async streamVNext(_messagesOrParams, _options) {
|
|
1352
|
+
throw new Error("streamVNext has been renamed to stream. Please use stream instead.");
|
|
1353
|
+
}
|
|
1365
1354
|
};
|
|
1366
1355
|
|
|
1367
1356
|
// src/resources/memory-thread.ts
|
|
@@ -1964,6 +1953,53 @@ var Workflow = class extends BaseResource {
|
|
|
1964
1953
|
});
|
|
1965
1954
|
return response.body.pipeThrough(transformStream);
|
|
1966
1955
|
}
|
|
1956
|
+
/**
|
|
1957
|
+
* Observes workflow vNext stream for a workflow run
|
|
1958
|
+
* @param params - Object containing the runId
|
|
1959
|
+
* @returns Promise containing the workflow execution results
|
|
1960
|
+
*/
|
|
1961
|
+
async observeStreamVNext(params) {
|
|
1962
|
+
const searchParams = new URLSearchParams();
|
|
1963
|
+
searchParams.set("runId", params.runId);
|
|
1964
|
+
const response = await this.request(
|
|
1965
|
+
`/api/workflows/${this.workflowId}/observe-streamVNext?${searchParams.toString()}`,
|
|
1966
|
+
{
|
|
1967
|
+
method: "POST",
|
|
1968
|
+
stream: true
|
|
1969
|
+
}
|
|
1970
|
+
);
|
|
1971
|
+
if (!response.ok) {
|
|
1972
|
+
throw new Error(`Failed to observe stream vNext workflow: ${response.statusText}`);
|
|
1973
|
+
}
|
|
1974
|
+
if (!response.body) {
|
|
1975
|
+
throw new Error("Response body is null");
|
|
1976
|
+
}
|
|
1977
|
+
let failedChunk = void 0;
|
|
1978
|
+
const transformStream = new TransformStream({
|
|
1979
|
+
start() {
|
|
1980
|
+
},
|
|
1981
|
+
async transform(chunk, controller) {
|
|
1982
|
+
try {
|
|
1983
|
+
const decoded = new TextDecoder().decode(chunk);
|
|
1984
|
+
const chunks = decoded.split(RECORD_SEPARATOR);
|
|
1985
|
+
for (const chunk2 of chunks) {
|
|
1986
|
+
if (chunk2) {
|
|
1987
|
+
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
1988
|
+
try {
|
|
1989
|
+
const parsedChunk = JSON.parse(newChunk);
|
|
1990
|
+
controller.enqueue(parsedChunk);
|
|
1991
|
+
failedChunk = void 0;
|
|
1992
|
+
} catch {
|
|
1993
|
+
failedChunk = newChunk;
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
} catch {
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
});
|
|
2001
|
+
return response.body.pipeThrough(transformStream);
|
|
2002
|
+
}
|
|
1967
2003
|
/**
|
|
1968
2004
|
* Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
1969
2005
|
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
@@ -1986,17 +2022,54 @@ var Workflow = class extends BaseResource {
|
|
|
1986
2022
|
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
1987
2023
|
* @returns Promise containing the workflow resume results
|
|
1988
2024
|
*/
|
|
1989
|
-
resumeStreamVNext(params) {
|
|
2025
|
+
async resumeStreamVNext(params) {
|
|
2026
|
+
const searchParams = new URLSearchParams();
|
|
2027
|
+
searchParams.set("runId", params.runId);
|
|
1990
2028
|
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
2029
|
+
const response = await this.request(
|
|
2030
|
+
`/api/workflows/${this.workflowId}/resume-stream?${searchParams.toString()}`,
|
|
2031
|
+
{
|
|
2032
|
+
method: "POST",
|
|
2033
|
+
body: {
|
|
2034
|
+
step: params.step,
|
|
2035
|
+
resumeData: params.resumeData,
|
|
2036
|
+
runtimeContext,
|
|
2037
|
+
tracingOptions: params.tracingOptions
|
|
2038
|
+
},
|
|
2039
|
+
stream: true
|
|
2040
|
+
}
|
|
2041
|
+
);
|
|
2042
|
+
if (!response.ok) {
|
|
2043
|
+
throw new Error(`Failed to stream vNext workflow: ${response.statusText}`);
|
|
2044
|
+
}
|
|
2045
|
+
if (!response.body) {
|
|
2046
|
+
throw new Error("Response body is null");
|
|
2047
|
+
}
|
|
2048
|
+
let failedChunk = void 0;
|
|
2049
|
+
const transformStream = new TransformStream({
|
|
2050
|
+
start() {
|
|
2051
|
+
},
|
|
2052
|
+
async transform(chunk, controller) {
|
|
2053
|
+
try {
|
|
2054
|
+
const decoded = new TextDecoder().decode(chunk);
|
|
2055
|
+
const chunks = decoded.split(RECORD_SEPARATOR);
|
|
2056
|
+
for (const chunk2 of chunks) {
|
|
2057
|
+
if (chunk2) {
|
|
2058
|
+
const newChunk = failedChunk ? failedChunk + chunk2 : chunk2;
|
|
2059
|
+
try {
|
|
2060
|
+
const parsedChunk = JSON.parse(newChunk);
|
|
2061
|
+
controller.enqueue(parsedChunk);
|
|
2062
|
+
failedChunk = void 0;
|
|
2063
|
+
} catch {
|
|
2064
|
+
failedChunk = newChunk;
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
} catch {
|
|
2069
|
+
}
|
|
1998
2070
|
}
|
|
1999
2071
|
});
|
|
2072
|
+
return response.body.pipeThrough(transformStream);
|
|
2000
2073
|
}
|
|
2001
2074
|
/**
|
|
2002
2075
|
* Watches workflow transitions in real-time
|
|
@@ -2664,145 +2737,6 @@ var NetworkMemoryThread = class extends BaseResource {
|
|
|
2664
2737
|
}
|
|
2665
2738
|
};
|
|
2666
2739
|
|
|
2667
|
-
// src/resources/vNextNetwork.ts
|
|
2668
|
-
var RECORD_SEPARATOR3 = "";
|
|
2669
|
-
var VNextNetwork = class extends BaseResource {
|
|
2670
|
-
constructor(options, networkId) {
|
|
2671
|
-
super(options);
|
|
2672
|
-
this.networkId = networkId;
|
|
2673
|
-
}
|
|
2674
|
-
/**
|
|
2675
|
-
* Retrieves details about the network
|
|
2676
|
-
* @param runtimeContext - Optional runtime context to pass as query parameter
|
|
2677
|
-
* @returns Promise containing vNext network details
|
|
2678
|
-
*/
|
|
2679
|
-
details(runtimeContext) {
|
|
2680
|
-
return this.request(`/api/networks/v-next/${this.networkId}${runtimeContextQueryString(runtimeContext)}`);
|
|
2681
|
-
}
|
|
2682
|
-
/**
|
|
2683
|
-
* Generates a response from the v-next network
|
|
2684
|
-
* @param params - Generation parameters including message
|
|
2685
|
-
* @returns Promise containing the generated response
|
|
2686
|
-
*/
|
|
2687
|
-
generate(params) {
|
|
2688
|
-
return this.request(`/api/networks/v-next/${this.networkId}/generate`, {
|
|
2689
|
-
method: "POST",
|
|
2690
|
-
body: {
|
|
2691
|
-
...params,
|
|
2692
|
-
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
2693
|
-
}
|
|
2694
|
-
});
|
|
2695
|
-
}
|
|
2696
|
-
/**
|
|
2697
|
-
* Generates a response from the v-next network using multiple primitives
|
|
2698
|
-
* @param params - Generation parameters including message
|
|
2699
|
-
* @returns Promise containing the generated response
|
|
2700
|
-
*/
|
|
2701
|
-
loop(params) {
|
|
2702
|
-
return this.request(`/api/networks/v-next/${this.networkId}/loop`, {
|
|
2703
|
-
method: "POST",
|
|
2704
|
-
body: {
|
|
2705
|
-
...params,
|
|
2706
|
-
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
2707
|
-
}
|
|
2708
|
-
});
|
|
2709
|
-
}
|
|
2710
|
-
async *streamProcessor(stream) {
|
|
2711
|
-
const reader = stream.getReader();
|
|
2712
|
-
let doneReading = false;
|
|
2713
|
-
let buffer = "";
|
|
2714
|
-
try {
|
|
2715
|
-
while (!doneReading) {
|
|
2716
|
-
const { done, value } = await reader.read();
|
|
2717
|
-
doneReading = done;
|
|
2718
|
-
if (done && !value) continue;
|
|
2719
|
-
try {
|
|
2720
|
-
const decoded = value ? new TextDecoder().decode(value) : "";
|
|
2721
|
-
const chunks = (buffer + decoded).split(RECORD_SEPARATOR3);
|
|
2722
|
-
buffer = chunks.pop() || "";
|
|
2723
|
-
for (const chunk of chunks) {
|
|
2724
|
-
if (chunk) {
|
|
2725
|
-
if (typeof chunk === "string") {
|
|
2726
|
-
try {
|
|
2727
|
-
const parsedChunk = JSON.parse(chunk);
|
|
2728
|
-
yield parsedChunk;
|
|
2729
|
-
} catch {
|
|
2730
|
-
}
|
|
2731
|
-
}
|
|
2732
|
-
}
|
|
2733
|
-
}
|
|
2734
|
-
} catch {
|
|
2735
|
-
}
|
|
2736
|
-
}
|
|
2737
|
-
if (buffer) {
|
|
2738
|
-
try {
|
|
2739
|
-
yield JSON.parse(buffer);
|
|
2740
|
-
} catch {
|
|
2741
|
-
}
|
|
2742
|
-
}
|
|
2743
|
-
} finally {
|
|
2744
|
-
reader.cancel().catch(() => {
|
|
2745
|
-
});
|
|
2746
|
-
}
|
|
2747
|
-
}
|
|
2748
|
-
/**
|
|
2749
|
-
* Streams a response from the v-next network
|
|
2750
|
-
* @param params - Stream parameters including message
|
|
2751
|
-
* @returns Promise containing the results
|
|
2752
|
-
*/
|
|
2753
|
-
async stream(params, onRecord) {
|
|
2754
|
-
const response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
|
|
2755
|
-
method: "POST",
|
|
2756
|
-
body: {
|
|
2757
|
-
...params,
|
|
2758
|
-
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
2759
|
-
},
|
|
2760
|
-
stream: true
|
|
2761
|
-
});
|
|
2762
|
-
if (!response.ok) {
|
|
2763
|
-
throw new Error(`Failed to stream vNext network: ${response.statusText}`);
|
|
2764
|
-
}
|
|
2765
|
-
if (!response.body) {
|
|
2766
|
-
throw new Error("Response body is null");
|
|
2767
|
-
}
|
|
2768
|
-
for await (const record of this.streamProcessor(response.body)) {
|
|
2769
|
-
if (typeof record === "string") {
|
|
2770
|
-
onRecord(JSON.parse(record));
|
|
2771
|
-
} else {
|
|
2772
|
-
onRecord(record);
|
|
2773
|
-
}
|
|
2774
|
-
}
|
|
2775
|
-
}
|
|
2776
|
-
/**
|
|
2777
|
-
* Streams a response from the v-next network loop
|
|
2778
|
-
* @param params - Stream parameters including message
|
|
2779
|
-
* @returns Promise containing the results
|
|
2780
|
-
*/
|
|
2781
|
-
async loopStream(params, onRecord) {
|
|
2782
|
-
const response = await this.request(`/api/networks/v-next/${this.networkId}/loop-stream`, {
|
|
2783
|
-
method: "POST",
|
|
2784
|
-
body: {
|
|
2785
|
-
...params,
|
|
2786
|
-
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
2787
|
-
},
|
|
2788
|
-
stream: true
|
|
2789
|
-
});
|
|
2790
|
-
if (!response.ok) {
|
|
2791
|
-
throw new Error(`Failed to stream vNext network loop: ${response.statusText}`);
|
|
2792
|
-
}
|
|
2793
|
-
if (!response.body) {
|
|
2794
|
-
throw new Error("Response body is null");
|
|
2795
|
-
}
|
|
2796
|
-
for await (const record of this.streamProcessor(response.body)) {
|
|
2797
|
-
if (typeof record === "string") {
|
|
2798
|
-
onRecord(JSON.parse(record));
|
|
2799
|
-
} else {
|
|
2800
|
-
onRecord(record);
|
|
2801
|
-
}
|
|
2802
|
-
}
|
|
2803
|
-
}
|
|
2804
|
-
};
|
|
2805
|
-
|
|
2806
2740
|
// src/client.ts
|
|
2807
2741
|
var MastraClient = class extends BaseResource {
|
|
2808
2742
|
observability;
|
|
@@ -3144,21 +3078,6 @@ var MastraClient = class extends BaseResource {
|
|
|
3144
3078
|
return this.request(`/api/telemetry`);
|
|
3145
3079
|
}
|
|
3146
3080
|
}
|
|
3147
|
-
/**
|
|
3148
|
-
* Retrieves all available vNext networks
|
|
3149
|
-
* @returns Promise containing map of vNext network IDs to vNext network details
|
|
3150
|
-
*/
|
|
3151
|
-
getVNextNetworks() {
|
|
3152
|
-
return this.request("/api/networks/v-next");
|
|
3153
|
-
}
|
|
3154
|
-
/**
|
|
3155
|
-
* Gets a vNext network instance by ID
|
|
3156
|
-
* @param networkId - ID of the vNext network to retrieve
|
|
3157
|
-
* @returns vNext Network instance
|
|
3158
|
-
*/
|
|
3159
|
-
getVNextNetwork(networkId) {
|
|
3160
|
-
return new VNextNetwork(this.options, networkId);
|
|
3161
|
-
}
|
|
3162
3081
|
/**
|
|
3163
3082
|
* Retrieves a list of available MCP servers.
|
|
3164
3083
|
* @param params - Optional parameters for pagination (limit, offset).
|