@mastra/client-js 1.17.2-alpha.3 → 1.18.0-alpha.10

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/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from './client.js';
2
2
  export * from './types.js';
3
3
  export * from './tools.js';
4
4
  export type { ChannelPlatformInfo, ChannelInstallationInfo, ChannelConnectOAuth, ChannelConnectDeepLink, ChannelConnectImmediate, ChannelConnectResult, } from './resources/channels.js';
5
+ export type { AgentCardSignatureKeyProviderInput, AgentCardVerificationKey, GetAgentCardOptions, VerifyAgentCardSignatureOptions, } from './resources/a2a.js';
5
6
  export { RequestContext } from '@mastra/core/request-context';
6
7
  export type { UIMessageWithMetadata } from '@mastra/core/agent';
7
8
  export type { Body, Client, ClientMethod, ClientPath, ClientRequest, ClientResponse, ClientResponseKind, ClientRoute, PathParams, QueryParams, RouteKey, RouteRequest, RouteResponse, RouteResponseType, RouteTypes, } from './route-types.generated.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,YAAY,EACV,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,UAAU,EACV,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,UAAU,GACX,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,kCAAkC,EAClC,wBAAwB,EACxB,mBAAmB,EACnB,+BAA+B,GAChC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,YAAY,EACV,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,UAAU,EACV,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,UAAU,GACX,MAAM,4BAA4B,CAAC"}
package/dist/index.js CHANGED
@@ -6,6 +6,8 @@ import { RequestContext } from '@mastra/core/request-context';
6
6
  export { RequestContext } from '@mastra/core/request-context';
7
7
  import { zodToJsonSchema as zodToJsonSchema$1 } from '@mastra/schema-compat/zod-to-json';
8
8
  import { MastraA2AError } from '@mastra/core/a2a';
9
+ import canonicalize from 'canonicalize';
10
+ import { base64url, decodeProtectedHeader, compactVerify, importX509, importSPKI, importJWK } from 'jose';
9
11
 
10
12
  // src/resources/agent.ts
11
13
  function normalizeRoutePath(path) {
@@ -464,8 +466,14 @@ var Agent = class extends BaseResource {
464
466
  const queryParams = new URLSearchParams();
465
467
  if (params?.page !== void 0) queryParams.set("page", String(params.page));
466
468
  if (params?.perPage !== void 0) queryParams.set("perPage", String(params.perPage));
467
- if (params?.orderBy) queryParams.set("orderBy", params.orderBy);
468
- if (params?.sortDirection) queryParams.set("sortDirection", params.sortDirection);
469
+ if (params?.orderBy) {
470
+ if (params.orderBy.field) {
471
+ queryParams.set("orderBy[field]", params.orderBy.field);
472
+ }
473
+ if (params.orderBy.direction) {
474
+ queryParams.set("orderBy[direction]", params.orderBy.direction);
475
+ }
476
+ }
469
477
  const queryString = queryParams.toString();
470
478
  const contextString = requestContextQueryString(requestContext);
471
479
  return this.request(
@@ -1639,6 +1647,43 @@ var Agent = class extends BaseResource {
1639
1647
  };
1640
1648
  return streamResponse;
1641
1649
  }
1650
+ /**
1651
+ * Resumes a suspended agent stream until idle with custom resume data.
1652
+ * Used to continue execution after a suspension point (e.g., workflow suspend within an agent).
1653
+ */
1654
+ async resumeStreamUntilIdle(resumeData, options) {
1655
+ const processedParams = {
1656
+ ...options,
1657
+ resumeData,
1658
+ requestContext: parseClientRequestContext(options.requestContext),
1659
+ clientTools: processClientTools(options.clientTools),
1660
+ structuredOutput: options.structuredOutput ? {
1661
+ ...options.structuredOutput,
1662
+ schema: standardSchemaToJSONSchema(toStandardSchema(options.structuredOutput.schema))
1663
+ } : void 0
1664
+ };
1665
+ let readableController;
1666
+ const readable = new ReadableStream({
1667
+ start(controller) {
1668
+ readableController = controller;
1669
+ }
1670
+ });
1671
+ const response = await this.processStreamResponse(processedParams, readableController, "resume-stream-until-idle");
1672
+ const streamResponse = new Response(readable, {
1673
+ status: response.status,
1674
+ statusText: response.statusText,
1675
+ headers: response.headers
1676
+ });
1677
+ streamResponse.processDataStream = async ({
1678
+ onChunk
1679
+ }) => {
1680
+ await processMastraStream({
1681
+ stream: streamResponse.body,
1682
+ onChunk
1683
+ });
1684
+ };
1685
+ return streamResponse;
1686
+ }
1642
1687
  /**
1643
1688
  * Approves a pending tool call and returns the complete response (non-streaming).
1644
1689
  * Used when `requireToolApproval` is enabled with generate() to allow the agent to proceed.
@@ -1860,8 +1905,22 @@ var MemoryThread = class extends BaseResource {
1860
1905
  /**
1861
1906
  * Builds the query string for agentId (if provided)
1862
1907
  */
1863
- getAgentIdQueryParam(prefix = "?") {
1864
- return this.agentId ? `${prefix}agentId=${this.agentId}` : "";
1908
+ getAgentIdQueryParam(prefix = "?", overrideAgentId) {
1909
+ const agentId = overrideAgentId ?? this.agentId;
1910
+ return agentId ? `${prefix}agentId=${agentId}` : "";
1911
+ }
1912
+ /**
1913
+ * Resolves the agentId to use for a write request. Prefers the per-call value, falls back
1914
+ * to the constructor value, and throws if neither is set.
1915
+ */
1916
+ requireAgentId(perCallAgentId, methodName) {
1917
+ const agentId = perCallAgentId ?? this.agentId;
1918
+ if (!agentId) {
1919
+ throw new Error(
1920
+ `MemoryThread.${methodName}() requires an agentId. Pass it via getMemoryThread({ threadId, agentId }) or as a parameter to ${methodName}().`
1921
+ );
1922
+ }
1923
+ return agentId;
1865
1924
  }
1866
1925
  /**
1867
1926
  * Retrieves the memory thread details
@@ -1875,25 +1934,30 @@ var MemoryThread = class extends BaseResource {
1875
1934
  }
1876
1935
  /**
1877
1936
  * Updates the memory thread properties
1878
- * @param params - Update parameters including title, metadata, and optional request context
1937
+ * @param params - Update parameters including title, metadata, and optional request context.
1938
+ * `agentId` is required by the server; pass it here if not supplied on the constructor.
1879
1939
  * @returns Promise containing updated thread details
1880
1940
  */
1881
1941
  update(params) {
1882
- const agentIdParam = this.getAgentIdQueryParam("?");
1883
- const contextParam = requestContextQueryString(params.requestContext, agentIdParam ? "&" : "?");
1942
+ const agentId = this.requireAgentId(params.agentId, "update");
1943
+ const { agentId: _omitAgentId, requestContext, ...body } = params;
1944
+ const agentIdParam = `?agentId=${agentId}`;
1945
+ const contextParam = requestContextQueryString(requestContext, "&");
1884
1946
  return this.request(`/memory/threads/${this.threadId}${agentIdParam}${contextParam}`, {
1885
1947
  method: "PATCH",
1886
- body: params
1948
+ body
1887
1949
  });
1888
1950
  }
1889
1951
  /**
1890
1952
  * Deletes the memory thread
1891
- * @param requestContext - Optional request context to pass as query parameter
1953
+ * @param opts - Optional `agentId` (required by the server when not supplied on the constructor)
1954
+ * and request context.
1892
1955
  * @returns Promise containing deletion result
1893
1956
  */
1894
- delete(requestContext) {
1895
- const agentIdParam = this.getAgentIdQueryParam("?");
1896
- const contextParam = requestContextQueryString(requestContext, agentIdParam ? "&" : "?");
1957
+ delete(opts = {}) {
1958
+ const agentId = this.requireAgentId(opts.agentId, "delete");
1959
+ const agentIdParam = `?agentId=${agentId}`;
1960
+ const contextParam = requestContextQueryString(opts.requestContext, "&");
1897
1961
  return this.request(`/memory/threads/${this.threadId}${agentIdParam}${contextParam}`, {
1898
1962
  method: "DELETE"
1899
1963
  });
@@ -1923,37 +1987,46 @@ var MemoryThread = class extends BaseResource {
1923
1987
  * Deletes one or more messages from the thread
1924
1988
  * @param messageIds - Can be a single message ID (string), array of message IDs,
1925
1989
  * message object with id property, or array of message objects
1926
- * @param requestContext - Optional request context to pass as query parameter
1990
+ * @param opts - Optional `agentId` (required by the server when not supplied on the constructor)
1991
+ * and request context. For backwards compatibility a `RequestContext` may also be
1992
+ * passed directly as the second argument.
1927
1993
  * @returns Promise containing deletion result
1928
1994
  */
1929
- deleteMessages(messageIds, requestContext) {
1930
- const queryParams = {};
1931
- if (this.agentId) queryParams.agentId = this.agentId;
1932
- const query = new URLSearchParams(queryParams);
1933
- const queryString = query.toString();
1934
- return this.request(
1935
- `/memory/messages/delete${queryString ? `?${queryString}` : ""}${requestContextQueryString(requestContext, queryString ? "&" : "?")}`,
1936
- {
1937
- method: "POST",
1938
- body: { messageIds }
1939
- }
1940
- );
1995
+ deleteMessages(messageIds, opts = {}) {
1996
+ const { agentId: explicitAgentId, requestContext } = normalizeWriteOpts(opts);
1997
+ const agentId = this.requireAgentId(explicitAgentId, "deleteMessages");
1998
+ const queryString = `agentId=${agentId}`;
1999
+ return this.request(`/memory/messages/delete?${queryString}${requestContextQueryString(requestContext, "&")}`, {
2000
+ method: "POST",
2001
+ body: { messageIds }
2002
+ });
1941
2003
  }
1942
2004
  /**
1943
2005
  * Clones the thread with all its messages to a new thread
1944
- * @param params - Clone parameters including optional new thread ID, title, metadata, and message filters
2006
+ * @param params - Clone parameters including optional new thread ID, title, metadata, and message filters.
2007
+ * `agentId` is required by the server; pass it here if not supplied on the constructor.
1945
2008
  * @returns Promise containing the cloned thread and copied messages
1946
2009
  */
1947
2010
  clone(params = {}) {
1948
- const { requestContext, ...body } = params;
1949
- const agentIdParam = this.getAgentIdQueryParam("?");
1950
- const contextParam = requestContextQueryString(requestContext, agentIdParam ? "&" : "?");
2011
+ const agentId = this.requireAgentId(params.agentId, "clone");
2012
+ const { agentId: _omitAgentId, requestContext, ...body } = params;
2013
+ const agentIdParam = `?agentId=${agentId}`;
2014
+ const contextParam = requestContextQueryString(requestContext, "&");
1951
2015
  return this.request(`/memory/threads/${this.threadId}/clone${agentIdParam}${contextParam}`, {
1952
2016
  method: "POST",
1953
2017
  body
1954
2018
  });
1955
2019
  }
1956
2020
  };
2021
+ function normalizeWriteOpts(opts) {
2022
+ if (!opts || typeof opts !== "object") return {};
2023
+ if ("agentId" in opts || "requestContext" in opts) {
2024
+ const o = opts;
2025
+ return { agentId: o.agentId, requestContext: o.requestContext };
2026
+ }
2027
+ if (Object.keys(opts).length === 0) return {};
2028
+ return { requestContext: opts };
2029
+ }
1957
2030
 
1958
2031
  // src/resources/vector.ts
1959
2032
  var Vector = class extends BaseResource {
@@ -2774,6 +2847,102 @@ async function* processA2AStream(stream) {
2774
2847
  reader.releaseLock();
2775
2848
  }
2776
2849
  }
2850
+ var DEFAULT_AGENT_CARD_SIGNATURE_ALGORITHMS = [
2851
+ "ES256",
2852
+ "ES384",
2853
+ "ES512",
2854
+ "RS256",
2855
+ "RS384",
2856
+ "RS512",
2857
+ "PS256",
2858
+ "PS384",
2859
+ "PS512"
2860
+ ];
2861
+ function stripAgentCardSignatures(agentCard) {
2862
+ const unsignedCard = structuredClone(agentCard);
2863
+ delete unsignedCard.signatures;
2864
+ return unsignedCard;
2865
+ }
2866
+ function isCryptoKey(value) {
2867
+ const cryptoKeyConstructor = globalThis.CryptoKey;
2868
+ return typeof cryptoKeyConstructor !== "undefined" && value instanceof cryptoKeyConstructor;
2869
+ }
2870
+ function isPem(value) {
2871
+ return value.includes("-----BEGIN ");
2872
+ }
2873
+ function isCertificate(value) {
2874
+ return value.includes("-----BEGIN CERTIFICATE-----");
2875
+ }
2876
+ async function importVerificationKey(key, algorithm) {
2877
+ if (isCryptoKey(key) || key instanceof Uint8Array) {
2878
+ return key;
2879
+ }
2880
+ if (key instanceof ArrayBuffer) {
2881
+ return new Uint8Array(key);
2882
+ }
2883
+ if (typeof key === "string") {
2884
+ if (algorithm.startsWith("HS")) {
2885
+ return new TextEncoder().encode(key);
2886
+ }
2887
+ if (!isPem(key)) {
2888
+ throw new Error("Expected a PEM-encoded public key or certificate string for Agent Card verification");
2889
+ }
2890
+ if (isCertificate(key)) {
2891
+ return importX509(key, algorithm);
2892
+ }
2893
+ return importSPKI(key, algorithm);
2894
+ }
2895
+ return importJWK(key, algorithm);
2896
+ }
2897
+ async function verifyAgentCardSignatureIfPresent(agentCard, options) {
2898
+ const signatures = agentCard.signatures ?? [];
2899
+ if (signatures.length === 0) {
2900
+ return agentCard;
2901
+ }
2902
+ const canonicalPayload = canonicalize(stripAgentCardSignatures(agentCard));
2903
+ if (!canonicalPayload) {
2904
+ throw new MastraClientError(200, "OK", "Failed to canonicalize A2A Agent Card for signature verification");
2905
+ }
2906
+ const allowedAlgorithms = options.algorithms ?? [...DEFAULT_AGENT_CARD_SIGNATURE_ALGORITHMS];
2907
+ const encodedPayload = base64url.encode(canonicalPayload);
2908
+ const verificationErrors = [];
2909
+ for (const [index, signature] of signatures.entries()) {
2910
+ try {
2911
+ const compactJws = `${signature.protected}.${encodedPayload}.${signature.signature}`;
2912
+ const protectedHeader = decodeProtectedHeader(compactJws);
2913
+ if (typeof protectedHeader.alg !== "string") {
2914
+ throw new Error('Agent Card signature is missing a protected "alg" header');
2915
+ }
2916
+ if (!allowedAlgorithms.includes(protectedHeader.alg)) {
2917
+ throw new Error(`Agent Card signature algorithm "${protectedHeader.alg}" is not allowed`);
2918
+ }
2919
+ const verificationKey = await options.keyProvider({
2920
+ agentCard,
2921
+ signature,
2922
+ protectedHeader,
2923
+ alg: protectedHeader.alg,
2924
+ kid: typeof protectedHeader.kid === "string" ? protectedHeader.kid : void 0,
2925
+ jku: typeof protectedHeader.jku === "string" ? protectedHeader.jku : void 0,
2926
+ index
2927
+ });
2928
+ if (!verificationKey) {
2929
+ throw new Error("No verification key was provided for Agent Card signature verification");
2930
+ }
2931
+ const importedKey = await importVerificationKey(verificationKey, protectedHeader.alg);
2932
+ await compactVerify(compactJws, importedKey, {
2933
+ algorithms: allowedAlgorithms
2934
+ });
2935
+ return agentCard;
2936
+ } catch (error) {
2937
+ verificationErrors.push(error instanceof Error ? error.message : "Unknown verification failure");
2938
+ }
2939
+ }
2940
+ throw new MastraClientError(
2941
+ 200,
2942
+ "OK",
2943
+ `A2A Agent Card signature verification failed: ${verificationErrors.join("; ")}`
2944
+ );
2945
+ }
2777
2946
 
2778
2947
  // src/resources/a2a.ts
2779
2948
  function createA2AJsonRpcError(response) {
@@ -2816,16 +2985,21 @@ var A2A = class extends BaseResource {
2816
2985
  agentId;
2817
2986
  /**
2818
2987
  * Get the agent card with metadata about the agent.
2988
+ * @param options - Optional Agent Card verification settings
2819
2989
  * @returns Promise containing the agent card information
2820
2990
  */
2821
- async getAgentCard() {
2822
- return this.request(`/.well-known/${this.agentId}/agent-card.json`);
2991
+ async getAgentCard(options) {
2992
+ const agentCard = await this.request(`/.well-known/${this.agentId}/agent-card.json`);
2993
+ if (!options?.verifySignature) {
2994
+ return agentCard;
2995
+ }
2996
+ return verifyAgentCardSignatureIfPresent(agentCard, options.verifySignature);
2823
2997
  }
2824
2998
  /**
2825
2999
  * @deprecated Use getAgentCard() instead.
2826
3000
  */
2827
- async getCard() {
2828
- return this.getAgentCard();
3001
+ async getCard(options) {
3002
+ return this.getAgentCard(options);
2829
3003
  }
2830
3004
  /**
2831
3005
  * Get the authenticated extended agent card.
@@ -3838,8 +4012,14 @@ var StoredAgent = class extends BaseResource {
3838
4012
  const queryParams = new URLSearchParams();
3839
4013
  if (params?.page !== void 0) queryParams.set("page", String(params.page));
3840
4014
  if (params?.perPage !== void 0) queryParams.set("perPage", String(params.perPage));
3841
- if (params?.orderBy) queryParams.set("orderBy", params.orderBy);
3842
- if (params?.sortDirection) queryParams.set("sortDirection", params.sortDirection);
4015
+ if (params?.orderBy) {
4016
+ if (params.orderBy.field) {
4017
+ queryParams.set("orderBy[field]", params.orderBy.field);
4018
+ }
4019
+ if (params.orderBy.direction) {
4020
+ queryParams.set("orderBy[direction]", params.orderBy.direction);
4021
+ }
4022
+ }
3843
4023
  const queryString = queryParams.toString();
3844
4024
  const contextString = requestContextQueryString(requestContext);
3845
4025
  return this.request(
@@ -3992,8 +4172,14 @@ var StoredPromptBlock = class extends BaseResource {
3992
4172
  const queryParams = new URLSearchParams();
3993
4173
  if (params?.page !== void 0) queryParams.set("page", String(params.page));
3994
4174
  if (params?.perPage !== void 0) queryParams.set("perPage", String(params.perPage));
3995
- if (params?.orderBy) queryParams.set("orderBy", params.orderBy);
3996
- if (params?.sortDirection) queryParams.set("sortDirection", params.sortDirection);
4175
+ if (params?.orderBy) {
4176
+ if (params.orderBy.field) {
4177
+ queryParams.set("orderBy[field]", params.orderBy.field);
4178
+ }
4179
+ if (params.orderBy.direction) {
4180
+ queryParams.set("orderBy[direction]", params.orderBy.direction);
4181
+ }
4182
+ }
3997
4183
  const queryString = queryParams.toString();
3998
4184
  const contextString = requestContextQueryString(requestContext, queryString ? "&" : "?");
3999
4185
  return this.request(
@@ -4194,8 +4380,14 @@ var StoredScorer = class extends BaseResource {
4194
4380
  const queryParams = new URLSearchParams();
4195
4381
  if (params?.page !== void 0) queryParams.set("page", String(params.page));
4196
4382
  if (params?.perPage !== void 0) queryParams.set("perPage", String(params.perPage));
4197
- if (params?.orderBy) queryParams.set("orderBy", params.orderBy);
4198
- if (params?.sortDirection) queryParams.set("sortDirection", params.sortDirection);
4383
+ if (params?.orderBy) {
4384
+ if (params.orderBy.field) {
4385
+ queryParams.set("orderBy[field]", params.orderBy.field);
4386
+ }
4387
+ if (params.orderBy.direction) {
4388
+ queryParams.set("orderBy[direction]", params.orderBy.direction);
4389
+ }
4390
+ }
4199
4391
  const queryString = queryParams.toString();
4200
4392
  const contextString = requestContextQueryString(requestContext);
4201
4393
  return this.request(
@@ -4871,8 +5063,14 @@ var MastraClient = class extends BaseResource {
4871
5063
  if (params.agentId) queryParams.set("agentId", params.agentId);
4872
5064
  if (params.page !== void 0) queryParams.set("page", params.page.toString());
4873
5065
  if (params.perPage !== void 0) queryParams.set("perPage", params.perPage.toString());
4874
- if (params.orderBy) queryParams.set("orderBy", params.orderBy);
4875
- if (params.sortDirection) queryParams.set("sortDirection", params.sortDirection);
5066
+ if (params.orderBy) {
5067
+ if (params.orderBy.field) {
5068
+ queryParams.set("orderBy[field]", params.orderBy.field);
5069
+ }
5070
+ if (params.orderBy.direction) {
5071
+ queryParams.set("orderBy[direction]", params.orderBy.direction);
5072
+ }
5073
+ }
4876
5074
  const queryString = queryParams.toString();
4877
5075
  const response = await this.request(
4878
5076
  `/memory/threads${queryString ? `?${queryString}` : ""}${requestContextQueryString(params.requestContext, queryString ? "&" : "?")}`
@@ -4937,13 +5135,13 @@ var MastraClient = class extends BaseResource {
4937
5135
  }
4938
5136
  return this.request(url);
4939
5137
  }
4940
- deleteThread(threadId, opts = {}) {
4941
- let url = "";
4942
- if (opts.agentId) {
4943
- url = `/memory/threads/${threadId}?agentId=${opts.agentId}${requestContextQueryString(opts.requestContext, "&")}`;
4944
- } else if (opts.networkId) {
4945
- url = `/memory/network/threads/${threadId}?networkId=${opts.networkId}${requestContextQueryString(opts.requestContext, "&")}`;
5138
+ deleteThread(threadId, opts) {
5139
+ if (!opts || !!opts.agentId === !!opts.networkId) {
5140
+ throw new Error(
5141
+ "MastraClient.deleteThread() requires exactly one of agentId or networkId. The server cannot resolve which memory store owns the thread without one, and passing both is ambiguous."
5142
+ );
4946
5143
  }
5144
+ const url = opts.agentId ? `/memory/threads/${threadId}?agentId=${opts.agentId}${requestContextQueryString(opts.requestContext, "&")}` : `/memory/network/threads/${threadId}?networkId=${opts.networkId}${requestContextQueryString(opts.requestContext, "&")}`;
4947
5145
  return this.request(url, { method: "DELETE" });
4948
5146
  }
4949
5147
  /**
@@ -6213,6 +6411,8 @@ var MastraClient = class extends BaseResource {
6213
6411
  if (params.runId) searchParams.set("runId", params.runId);
6214
6412
  if (params.threadId) searchParams.set("threadId", params.threadId);
6215
6413
  if (params.resourceId) searchParams.set("resourceId", params.resourceId);
6414
+ if (params.toolName) searchParams.set("toolName", params.toolName);
6415
+ if (params.toolCallId) searchParams.set("toolCallId", params.toolCallId);
6216
6416
  if (params.fromDate) searchParams.set("fromDate", params.fromDate.toISOString());
6217
6417
  if (params.toDate) searchParams.set("toDate", params.toDate.toISOString());
6218
6418
  if (params.dateFilterBy) searchParams.set("dateFilterBy", params.dateFilterBy);