@mastra/client-js 1.56.0-alpha.11 → 1.56.0-alpha.12
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/dist/client.d.ts +40 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +71 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +71 -0
- package/dist/index.js.map +1 -1
- package/dist/route-types.generated.d.ts +298 -122
- package/dist/route-types.generated.d.ts.map +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -7896,6 +7896,77 @@ var MastraClient = class extends BaseResource {
|
|
|
7896
7896
|
});
|
|
7897
7897
|
}
|
|
7898
7898
|
/**
|
|
7899
|
+
* Lists the event types an MCP server declares (experimental).
|
|
7900
|
+
* `testEmit` is true when the server serves {@link emitMcpServerEvent} (under `mastra dev`).
|
|
7901
|
+
* @param serverId - The ID of the MCP server.
|
|
7902
|
+
*/
|
|
7903
|
+
getMcpServerEvents(serverId) {
|
|
7904
|
+
return this.request(`/mcp/${encodeURIComponent(serverId)}/events`);
|
|
7905
|
+
}
|
|
7906
|
+
/**
|
|
7907
|
+
* Reads occurrences of an MCP server event type, like the `events/poll` MCP request (experimental).
|
|
7908
|
+
* Pass the returned `cursor` to the next call to resume.
|
|
7909
|
+
* @param serverId - The ID of the MCP server.
|
|
7910
|
+
* @param eventName - The event type name.
|
|
7911
|
+
* @param body - Event arguments, resume cursor and page size.
|
|
7912
|
+
*/
|
|
7913
|
+
pollMcpServerEvent(serverId, eventName, body = {}) {
|
|
7914
|
+
return this.request(`/mcp/${encodeURIComponent(serverId)}/events/${encodeURIComponent(eventName)}/poll`, {
|
|
7915
|
+
method: "POST",
|
|
7916
|
+
body
|
|
7917
|
+
});
|
|
7918
|
+
}
|
|
7919
|
+
/**
|
|
7920
|
+
* Streams occurrences of a push-capable MCP server event type (experimental).
|
|
7921
|
+
* Yields an `active` frame first, then `event`, `heartbeat` and `error` frames, and ends
|
|
7922
|
+
* when the server ends the stream. Abort `options.signal` or break out of the loop to stop.
|
|
7923
|
+
*
|
|
7924
|
+
* @example
|
|
7925
|
+
* ```typescript
|
|
7926
|
+
* const controller = new AbortController();
|
|
7927
|
+
* for await (const frame of client.streamMcpServerEvent('tickets', 'ticket.created', {}, { signal: controller.signal })) {
|
|
7928
|
+
* if (frame.type === 'event') console.log(frame.occurrence.data);
|
|
7929
|
+
* }
|
|
7930
|
+
* ```
|
|
7931
|
+
*/
|
|
7932
|
+
async *streamMcpServerEvent(serverId, eventName, body = {}, options = {}) {
|
|
7933
|
+
const response = await this.request(`/mcp/${encodeURIComponent(serverId)}/events/${encodeURIComponent(eventName)}/stream`, {
|
|
7934
|
+
method: "POST",
|
|
7935
|
+
body,
|
|
7936
|
+
stream: true,
|
|
7937
|
+
signal: options.signal,
|
|
7938
|
+
retries: 0
|
|
7939
|
+
});
|
|
7940
|
+
if (!response.body) throw new Error("Response body is null");
|
|
7941
|
+
const reader = response.body.pipeThrough(createSseJsonTransform()).getReader();
|
|
7942
|
+
const cancel = () => void reader.cancel().catch(() => {});
|
|
7943
|
+
options.signal?.addEventListener("abort", cancel, { once: true });
|
|
7944
|
+
try {
|
|
7945
|
+
while (true) {
|
|
7946
|
+
const { value, done } = await reader.read();
|
|
7947
|
+
if (done) return;
|
|
7948
|
+
yield value;
|
|
7949
|
+
}
|
|
7950
|
+
} finally {
|
|
7951
|
+
options.signal?.removeEventListener("abort", cancel);
|
|
7952
|
+
await reader.cancel().catch(() => {});
|
|
7953
|
+
}
|
|
7954
|
+
}
|
|
7955
|
+
/**
|
|
7956
|
+
* Emits a test occurrence of an emit-fed MCP server event type (experimental).
|
|
7957
|
+
* Only served under `mastra dev`; other servers respond 404. The occurrence's
|
|
7958
|
+
* `eventId` starts with `mastra-test-`.
|
|
7959
|
+
* @param serverId - The ID of the MCP server.
|
|
7960
|
+
* @param eventName - The event type name.
|
|
7961
|
+
* @param data - The event payload; validated against the event's payload schema.
|
|
7962
|
+
*/
|
|
7963
|
+
emitMcpServerEvent(serverId, eventName, data) {
|
|
7964
|
+
return this.request(`/mcp/${encodeURIComponent(serverId)}/events/${encodeURIComponent(eventName)}/emit`, {
|
|
7965
|
+
method: "POST",
|
|
7966
|
+
body: { data }
|
|
7967
|
+
});
|
|
7968
|
+
}
|
|
7969
|
+
/**
|
|
7899
7970
|
* Gets an A2A client for interacting with an agent via the A2A protocol
|
|
7900
7971
|
* @param agentId - ID of the agent to interact with
|
|
7901
7972
|
* @returns A2A client instance
|