@mastra/client-js 0.10.24-alpha.0 → 0.11.0-alpha.2

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.
Files changed (58) hide show
  1. package/.turbo/turbo-build.log +7 -7
  2. package/CHANGELOG.md +24 -0
  3. package/dist/adapters/agui.d.ts +1 -1
  4. package/dist/adapters/agui.d.ts.map +1 -1
  5. package/dist/client.d.ts +5 -1
  6. package/dist/client.d.ts.map +1 -1
  7. package/dist/index.cjs +117 -53
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.js +117 -53
  10. package/dist/index.js.map +1 -1
  11. package/dist/resources/agent.d.ts +10 -11
  12. package/dist/resources/agent.d.ts.map +1 -1
  13. package/dist/resources/base.d.ts.map +1 -1
  14. package/dist/resources/index.d.ts +1 -0
  15. package/dist/resources/index.d.ts.map +1 -1
  16. package/dist/resources/memory-thread.d.ts +1 -1
  17. package/dist/resources/memory-thread.d.ts.map +1 -1
  18. package/dist/resources/network-memory-thread.d.ts +1 -1
  19. package/dist/resources/network-memory-thread.d.ts.map +1 -1
  20. package/dist/resources/network.d.ts +1 -1
  21. package/dist/resources/network.d.ts.map +1 -1
  22. package/dist/resources/observability.d.ts +19 -0
  23. package/dist/resources/observability.d.ts.map +1 -0
  24. package/dist/resources/tool.d.ts.map +1 -1
  25. package/dist/resources/vNextNetwork.d.ts +1 -1
  26. package/dist/resources/vNextNetwork.d.ts.map +1 -1
  27. package/dist/types.d.ts +16 -1
  28. package/dist/types.d.ts.map +1 -1
  29. package/dist/utils/process-client-tools.d.ts.map +1 -1
  30. package/dist/utils/zod-to-json-schema.d.ts +2 -104
  31. package/dist/utils/zod-to-json-schema.d.ts.map +1 -1
  32. package/eslint.config.js +6 -1
  33. package/integration-tests/src/mastra/index.ts +2 -2
  34. package/package.json +6 -4
  35. package/src/adapters/agui.test.ts +0 -29
  36. package/src/adapters/agui.ts +1 -1
  37. package/src/client.ts +13 -0
  38. package/src/example.ts +1 -1
  39. package/src/index.test.ts +29 -2
  40. package/src/resources/agent.ts +30 -31
  41. package/src/resources/base.ts +2 -1
  42. package/src/resources/index.ts +1 -0
  43. package/src/resources/memory-thread.test.ts +1 -1
  44. package/src/resources/memory-thread.ts +1 -1
  45. package/src/resources/network-memory-thread.test.ts +1 -1
  46. package/src/resources/network-memory-thread.ts +1 -1
  47. package/src/resources/network.ts +1 -1
  48. package/src/resources/observability.ts +53 -0
  49. package/src/resources/tool.ts +1 -1
  50. package/src/resources/vNextNetwork.ts +2 -2
  51. package/src/resources/workflow.ts +1 -1
  52. package/src/types.ts +27 -16
  53. package/src/utils/process-client-tools.ts +1 -1
  54. package/src/utils/process-mastra-stream.test.ts +2 -2
  55. package/src/utils/zod-to-json-schema.ts +22 -3
  56. package/src/v2-messages.test.ts +1 -1
  57. package/tsconfig.json +2 -2
  58. package/tsup.config.ts +1 -1
package/src/index.test.ts CHANGED
@@ -1,8 +1,8 @@
1
+ import type { ServerDetailInfo } from '@mastra/core/mcp';
2
+ import type { ScoringEntityType, ScoringSource } from '@mastra/core/scores';
1
3
  import { describe, expect, beforeEach, it, vi } from 'vitest';
2
4
  import { MastraClient } from './client';
3
5
  import type { McpServerListResponse } from './types';
4
- import type { ServerDetailInfo } from '@mastra/core/mcp';
5
- import { ScoringEntityType, ScoringSource } from '@mastra/core/scores';
6
6
 
7
7
  // Mock fetch globally
8
8
  global.fetch = vi.fn();
@@ -384,6 +384,7 @@ d:{"finishReason":"stop","usage":{"promptTokens":2,"completionTokens":2}}
384
384
  while (true) {
385
385
  const { value, done } = await reader.read();
386
386
  if (done) break;
387
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
387
388
  output += new TextDecoder().decode(value);
388
389
  }
389
390
  }
@@ -869,11 +870,19 @@ d:{"finishReason":"stop","usage":{"promptTokens":2,"completionTokens":2}}
869
870
  backoffMs: 100,
870
871
  maxBackoffMs: 1000,
871
872
  headers: { 'Custom-Header': 'value' },
873
+ credentials: 'same-origin',
872
874
  });
873
875
 
874
876
  (global.fetch as any)
875
877
  .mockRejectedValueOnce(new Error('Network error'))
876
878
  .mockRejectedValueOnce(new Error('Network error'))
879
+ .mockResolvedValueOnce({
880
+ ok: true,
881
+ headers: {
882
+ get: () => 'application/json',
883
+ },
884
+ json: async () => ({ success: true }),
885
+ })
877
886
  .mockResolvedValueOnce({
878
887
  ok: true,
879
888
  headers: {
@@ -891,6 +900,24 @@ d:{"finishReason":"stop","usage":{"promptTokens":2,"completionTokens":2}}
891
900
  headers: expect.objectContaining({
892
901
  'Custom-Header': 'value',
893
902
  }),
903
+ credentials: 'same-origin',
904
+ }),
905
+ );
906
+
907
+ // ensure custom headers and credentials are overridable per request
908
+ const result2 = await customClient.request('/test', {
909
+ headers: { 'Custom-Header': 'new-value' },
910
+ credentials: 'include',
911
+ });
912
+ expect(result2).toEqual({ success: true });
913
+ expect(global.fetch).toHaveBeenCalledTimes(4);
914
+ expect(global.fetch).toHaveBeenCalledWith(
915
+ 'http://localhost:4111/test',
916
+ expect.objectContaining({
917
+ headers: expect.objectContaining({
918
+ 'Custom-Header': 'new-value',
919
+ }),
920
+ credentials: 'include',
894
921
  }),
895
922
  );
896
923
  });
@@ -1,21 +1,21 @@
1
- import {
2
- parsePartialJson,
3
- processDataStream,
4
- type JSONValue,
5
- type ReasoningUIPart,
6
- type TextUIPart,
7
- type ToolInvocation,
8
- type ToolInvocationUIPart,
9
- type UIMessage,
10
- type UseChatOptions,
1
+ import { parsePartialJson, processDataStream } from '@ai-sdk/ui-utils';
2
+ import type {
3
+ JSONValue,
4
+ ReasoningUIPart,
5
+ TextUIPart,
6
+ ToolInvocation,
7
+ ToolInvocationUIPart,
8
+ UIMessage,
9
+ UseChatOptions,
11
10
  } from '@ai-sdk/ui-utils';
12
- import { Tool, type CoreMessage, type OutputSchema } from '@mastra/core';
13
- import { type GenerateReturn } from '@mastra/core/llm';
14
- import type { JSONSchema7 } from 'json-schema';
15
- import { ZodSchema } from 'zod';
16
- import { zodToJsonSchema } from '../utils/zod-to-json-schema';
17
- import { processClientTools } from '../utils/process-client-tools';
18
11
  import { v4 as uuid } from '@lukeed/uuid';
12
+ import type { MessageListInput } from '@mastra/core/agent/message-list';
13
+ import type { GenerateReturn, CoreMessage } from '@mastra/core/llm';
14
+ import type { RuntimeContext } from '@mastra/core/runtime-context';
15
+ import type { OutputSchema, MastraModelOutput } from '@mastra/core/stream';
16
+ import type { Tool } from '@mastra/core/tools';
17
+ import type { JSONSchema7 } from 'json-schema';
18
+ import type { ZodType } from 'zod';
19
19
 
20
20
  import type {
21
21
  GenerateParams,
@@ -28,12 +28,11 @@ import type {
28
28
  StreamVNextParams,
29
29
  } from '../types';
30
30
 
31
- import { BaseResource } from './base';
32
- import type { RuntimeContext } from '@mastra/core/runtime-context';
33
31
  import { parseClientRuntimeContext } from '../utils';
32
+ import { processClientTools } from '../utils/process-client-tools';
34
33
  import { processMastraStream } from '../utils/process-mastra-stream';
35
- import type { MastraModelOutput } from '@mastra/core/stream';
36
- import type { MessageListInput } from '@mastra/core/agent/message-list';
34
+ import { zodToJsonSchema } from '../utils/zod-to-json-schema';
35
+ import { BaseResource } from './base';
37
36
 
38
37
  async function executeToolCallAndRespond({
39
38
  response,
@@ -195,15 +194,15 @@ export class Agent extends BaseResource {
195
194
  async generate(
196
195
  params: GenerateParams<undefined> & { output?: never; experimental_output?: never },
197
196
  ): Promise<GenerateReturn<any, undefined, undefined>>;
198
- async generate<Output extends JSONSchema7 | ZodSchema>(
197
+ async generate<Output extends JSONSchema7 | ZodType>(
199
198
  params: GenerateParams<Output> & { output: Output; experimental_output?: never },
200
199
  ): Promise<GenerateReturn<any, Output, undefined>>;
201
- async generate<StructuredOutput extends JSONSchema7 | ZodSchema>(
200
+ async generate<StructuredOutput extends JSONSchema7 | ZodType>(
202
201
  params: GenerateParams<StructuredOutput> & { output?: never; experimental_output: StructuredOutput },
203
202
  ): Promise<GenerateReturn<any, undefined, StructuredOutput>>;
204
203
  async generate<
205
- Output extends JSONSchema7 | ZodSchema | undefined = undefined,
206
- StructuredOutput extends JSONSchema7 | ZodSchema | undefined = undefined,
204
+ Output extends JSONSchema7 | ZodType | undefined = undefined,
205
+ StructuredOutput extends JSONSchema7 | ZodType | undefined = undefined,
207
206
  >(params: GenerateParams<Output>): Promise<GenerateReturn<any, Output, StructuredOutput>> {
208
207
  const processedParams = {
209
208
  ...params,
@@ -277,8 +276,8 @@ export class Agent extends BaseResource {
277
276
  return response;
278
277
  }
279
278
 
280
- async generateVNext<OUTPUT extends OutputSchema | undefined = undefined>(
281
- params: StreamVNextParams<OUTPUT>,
279
+ async generateVNext<T extends OutputSchema | undefined = undefined>(
280
+ params: StreamVNextParams<T>,
282
281
  ): Promise<ReturnType<MastraModelOutput['getFullOutput']>> {
283
282
  const processedParams = {
284
283
  ...params,
@@ -662,7 +661,7 @@ export class Agent extends BaseResource {
662
661
  * @param params - Stream parameters including prompt
663
662
  * @returns Promise containing the enhanced Response object with processDataStream method
664
663
  */
665
- async stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(
664
+ async stream<T extends JSONSchema7 | ZodType | undefined = undefined>(
666
665
  params: StreamParams<T>,
667
666
  ): Promise<
668
667
  Response & {
@@ -1188,8 +1187,8 @@ export class Agent extends BaseResource {
1188
1187
  return response;
1189
1188
  }
1190
1189
 
1191
- async streamVNext<OUTPUT extends OutputSchema | undefined = undefined>(
1192
- params: StreamVNextParams<OUTPUT>,
1190
+ async streamVNext<T extends OutputSchema | undefined = undefined>(
1191
+ params: StreamVNextParams<T>,
1193
1192
  ): Promise<
1194
1193
  Response & {
1195
1194
  processDataStream: ({
@@ -1258,9 +1257,7 @@ export class Agent extends BaseResource {
1258
1257
 
1259
1258
  try {
1260
1259
  let toolCalls: ToolInvocation[] = [];
1261
- let finishReasonToolCalls = false;
1262
1260
  let messages: UIMessage[] = [];
1263
- let hasProcessedToolCalls = false;
1264
1261
 
1265
1262
  // Use tee() to split the stream into two branches
1266
1263
  const [streamForWritable, streamForProcessing] = response.body.tee();
@@ -1373,6 +1370,8 @@ export class Agent extends BaseResource {
1373
1370
  }
1374
1371
  } else {
1375
1372
  setTimeout(() => {
1373
+ // We can't close the stream in this function, we have to wait until it's done
1374
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
1376
1375
  writable.close();
1377
1376
  }, 0);
1378
1377
  }
@@ -15,7 +15,7 @@ export class BaseResource {
15
15
  */
16
16
  public async request<T>(path: string, options: RequestOptions = {}): Promise<T> {
17
17
  let lastError: Error | null = null;
18
- const { baseUrl, retries = 3, backoffMs = 100, maxBackoffMs = 1000, headers = {} } = this.options;
18
+ const { baseUrl, retries = 3, backoffMs = 100, maxBackoffMs = 1000, headers = {}, credentials } = this.options;
19
19
 
20
20
  let delay = backoffMs;
21
21
 
@@ -35,6 +35,7 @@ export class BaseResource {
35
35
  // 'x-mastra-client-type': 'js',
36
36
  },
37
37
  signal: this.options.abortSignal,
38
+ credentials: options.credentials ?? credentials,
38
39
  body:
39
40
  options.body instanceof FormData ? options.body : options.body ? JSON.stringify(options.body) : undefined,
40
41
  });
@@ -8,3 +8,4 @@ export * from './base';
8
8
  export * from './workflow';
9
9
  export * from './a2a';
10
10
  export * from './mcp-tool';
11
+ export * from './observability';
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, beforeEach, it, vi } from 'vitest';
2
- import { MemoryThread } from './memory-thread';
3
2
  import type { ClientOptions } from '../types';
3
+ import { MemoryThread } from './memory-thread';
4
4
 
5
5
  // Mock fetch globally
6
6
  global.fetch = vi.fn();
@@ -1,4 +1,4 @@
1
- import type { StorageThreadType } from '@mastra/core';
1
+ import type { StorageThreadType } from '@mastra/core/memory';
2
2
 
3
3
  import type {
4
4
  GetMemoryThreadMessagesResponse,
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, beforeEach, it, vi } from 'vitest';
2
- import { NetworkMemoryThread } from './network-memory-thread';
3
2
  import type { ClientOptions } from '../types';
3
+ import { NetworkMemoryThread } from './network-memory-thread';
4
4
 
5
5
  // Mock fetch globally
6
6
  global.fetch = vi.fn();
@@ -1,4 +1,4 @@
1
- import type { StorageThreadType } from '@mastra/core';
1
+ import type { StorageThreadType } from '@mastra/core/memory';
2
2
 
3
3
  import type {
4
4
  GetMemoryThreadMessagesResponse,
@@ -1,5 +1,5 @@
1
1
  import { processDataStream } from '@ai-sdk/ui-utils';
2
- import type { GenerateReturn } from '@mastra/core';
2
+ import type { GenerateReturn } from '@mastra/core/llm';
3
3
  import type { JSONSchema7 } from 'json-schema';
4
4
  import type { ZodSchema } from 'zod';
5
5
  import type { GenerateParams, ClientOptions, StreamParams, GetNetworkResponse } from '../types';
@@ -0,0 +1,53 @@
1
+ import type { AITraceRecord, AITracesPaginatedArg } from '@mastra/core/storage';
2
+ import type { ClientOptions, GetAITracesResponse } from '../types';
3
+ import { BaseResource } from './base';
4
+
5
+ export class Observability extends BaseResource {
6
+ constructor(options: ClientOptions) {
7
+ super(options);
8
+ }
9
+
10
+ /**
11
+ * Retrieves a specific AI trace by ID
12
+ * @param traceId - ID of the trace to retrieve
13
+ * @returns Promise containing the AI trace with all its spans
14
+ */
15
+ getTrace(traceId: string): Promise<AITraceRecord> {
16
+ return this.request(`/api/observability/traces/${traceId}`);
17
+ }
18
+
19
+ /**
20
+ * Retrieves paginated list of AI traces with optional filtering
21
+ * @param params - Parameters for pagination and filtering
22
+ * @returns Promise containing paginated traces and pagination info
23
+ */
24
+ getTraces(params: AITracesPaginatedArg): Promise<GetAITracesResponse> {
25
+ const { pagination, filters } = params;
26
+ const { page, perPage, dateRange } = pagination || {};
27
+ const { name, spanType } = filters || {};
28
+ const searchParams = new URLSearchParams();
29
+
30
+ if (page !== undefined) {
31
+ searchParams.set('page', String(page));
32
+ }
33
+ if (perPage !== undefined) {
34
+ searchParams.set('perPage', String(perPage));
35
+ }
36
+ if (name) {
37
+ searchParams.set('name', name);
38
+ }
39
+ if (spanType !== undefined) {
40
+ searchParams.set('spanType', String(spanType));
41
+ }
42
+ if (dateRange) {
43
+ const dateRangeStr = JSON.stringify({
44
+ start: dateRange.start instanceof Date ? dateRange.start.toISOString() : dateRange.start,
45
+ end: dateRange.end instanceof Date ? dateRange.end.toISOString() : dateRange.end,
46
+ });
47
+ searchParams.set('dateRange', dateRangeStr);
48
+ }
49
+
50
+ const queryString = searchParams.toString();
51
+ return this.request(`/api/observability/traces${queryString ? `?${queryString}` : ''}`);
52
+ }
53
+ }
@@ -1,8 +1,8 @@
1
1
  import type { RuntimeContext } from '@mastra/core/runtime-context';
2
2
  import type { GetToolResponse, ClientOptions } from '../types';
3
3
 
4
- import { BaseResource } from './base';
5
4
  import { parseClientRuntimeContext } from '../utils';
5
+ import { BaseResource } from './base';
6
6
 
7
7
  export class Tool extends BaseResource {
8
8
  constructor(
@@ -1,3 +1,4 @@
1
+ import type { RuntimeContext } from '@mastra/core/runtime-context';
1
2
  import type { WatchEvent } from '@mastra/core/workflows';
2
3
 
3
4
  import type {
@@ -9,9 +10,8 @@ import type {
9
10
  LoopStreamVNextNetworkParams,
10
11
  } from '../types';
11
12
 
12
- import { BaseResource } from './base';
13
13
  import { parseClientRuntimeContext } from '../utils';
14
- import type { RuntimeContext } from '@mastra/core/runtime-context';
14
+ import { BaseResource } from './base';
15
15
 
16
16
  const RECORD_SEPARATOR = '\x1E';
17
17
 
@@ -320,7 +320,7 @@ export class Workflow extends BaseResource {
320
320
  const parsedChunk = JSON.parse(newChunk);
321
321
  controller.enqueue(parsedChunk);
322
322
  failedChunk = undefined;
323
- } catch (error) {
323
+ } catch {
324
324
  failedChunk = newChunk;
325
325
  }
326
326
  }
package/src/types.ts CHANGED
@@ -1,17 +1,3 @@
1
- import type {
2
- MastraMessageV1,
3
- AiMessageType,
4
- CoreMessage,
5
- QueryResult,
6
- StorageThreadType,
7
- WorkflowRuns,
8
- WorkflowRun,
9
- LegacyWorkflowRuns,
10
- StorageGetMessagesArg,
11
- PaginationInfo,
12
- MastraMessageV2,
13
- OutputSchema,
14
- } from '@mastra/core';
15
1
  import type {
16
2
  AgentExecutionOptions,
17
3
  AgentGenerateOptions,
@@ -20,11 +6,23 @@ import type {
20
6
  UIMessageWithMetadata,
21
7
  } from '@mastra/core/agent';
22
8
  import type { MessageListInput } from '@mastra/core/agent/message-list';
9
+ import type { CoreMessage } from '@mastra/core/llm';
23
10
  import type { BaseLogMessage, LogLevel } from '@mastra/core/logger';
24
-
25
11
  import type { MCPToolType, ServerInfo } from '@mastra/core/mcp';
12
+ import type { AiMessageType, MastraMessageV1, MastraMessageV2, StorageThreadType } from '@mastra/core/memory';
26
13
  import type { RuntimeContext } from '@mastra/core/runtime-context';
27
- import type { MastraScorer, MastraScorerEntry, ScoreRowData } from '@mastra/core/scores';
14
+ import type { MastraScorerEntry, ScoreRowData } from '@mastra/core/scores';
15
+ import type {
16
+ AITraceRecord,
17
+ AISpanRecord,
18
+ LegacyWorkflowRuns,
19
+ StorageGetMessagesArg,
20
+ PaginationInfo,
21
+ WorkflowRun,
22
+ WorkflowRuns,
23
+ } from '@mastra/core/storage';
24
+ import type { OutputSchema } from '@mastra/core/stream';
25
+ import type { QueryResult } from '@mastra/core/vector';
28
26
  import type { Workflow, WatchEvent, WorkflowResult } from '@mastra/core/workflows';
29
27
  import type {
30
28
  StepAction,
@@ -47,6 +45,8 @@ export interface ClientOptions {
47
45
  headers?: Record<string, string>;
48
46
  /** Abort signal for request */
49
47
  abortSignal?: AbortSignal;
48
+ /** Credentials mode for requests. See https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials for more info. */
49
+ credentials?: 'omit' | 'same-origin' | 'include';
50
50
  }
51
51
 
52
52
  export interface RequestOptions {
@@ -54,6 +54,8 @@ export interface RequestOptions {
54
54
  headers?: Record<string, string>;
55
55
  body?: any;
56
56
  stream?: boolean;
57
+ /** Credentials mode for requests. See https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials for more info. */
58
+ credentials?: 'omit' | 'same-origin' | 'include';
57
59
  }
58
60
 
59
61
  type WithoutMethods<T> = {
@@ -521,3 +523,12 @@ export type GetScorerResponse = MastraScorerEntry & {
521
523
  export interface GetScorersResponse {
522
524
  scorers: Array<GetScorerResponse>;
523
525
  }
526
+
527
+ export interface GetAITraceResponse {
528
+ trace: AITraceRecord;
529
+ }
530
+
531
+ export interface GetAITracesResponse {
532
+ spans: AISpanRecord[];
533
+ pagination: PaginationInfo;
534
+ }
@@ -1,6 +1,6 @@
1
+ import type { ToolsInput } from '@mastra/core/agent';
1
2
  import { isVercelTool } from '@mastra/core/tools/is-vercel-tool';
2
3
  import { zodToJsonSchema } from './zod-to-json-schema';
3
- import type { ToolsInput } from '@mastra/core/agent';
4
4
 
5
5
  export function processClientTools(clientTools: ToolsInput | undefined): ToolsInput | undefined {
6
6
  if (!clientTools) {
@@ -1,7 +1,7 @@
1
+ import { ReadableStream } from 'stream/web';
2
+ import type { ChunkType } from '@mastra/core/stream';
1
3
  import { describe, expect, it, vi, beforeEach } from 'vitest';
2
4
  import { processMastraStream } from './process-mastra-stream';
3
- import type { ChunkType } from '@mastra/core/stream';
4
- import { ReadableStream } from 'stream/web';
5
5
 
6
6
  describe('processMastraStream', () => {
7
7
  let mockOnChunk: ReturnType<typeof vi.fn>;
@@ -1,10 +1,29 @@
1
- import { ZodSchema } from 'zod';
1
+ import { z } from 'zod';
2
+ import type { ZodType } from 'zod';
2
3
  import originalZodToJsonSchema from 'zod-to-json-schema';
3
4
 
4
- export function zodToJsonSchema<T extends ZodSchema | any>(zodSchema: T) {
5
- if (!(zodSchema instanceof ZodSchema)) {
5
+ function isZodType(value: unknown): value is ZodType {
6
+ // Check if it's a Zod schema by looking for common Zod properties and methods
7
+ return (
8
+ typeof value === 'object' &&
9
+ value !== null &&
10
+ '_def' in value &&
11
+ 'parse' in value &&
12
+ typeof (value as any).parse === 'function' &&
13
+ 'safeParse' in value &&
14
+ typeof (value as any).safeParse === 'function'
15
+ );
16
+ }
17
+
18
+ export function zodToJsonSchema<T extends ZodType | any>(zodSchema: T) {
19
+ if (!isZodType(zodSchema)) {
6
20
  return zodSchema;
7
21
  }
8
22
 
23
+ if ('toJSONSchema' in z) {
24
+ // @ts-expect-error - zod v4 type
25
+ return z.toJSONSchema(zodSchema);
26
+ }
27
+
9
28
  return originalZodToJsonSchema(zodSchema, { $refStrategy: 'none' });
10
29
  }
@@ -1,5 +1,5 @@
1
+ import type { MastraMessageV1, MastraMessageV2 } from '@mastra/core/memory';
1
2
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import type { MastraMessageV1, MastraMessageV2 } from '@mastra/core';
3
3
  import { MastraClient } from './client';
4
4
 
5
5
  describe('V2 Message Format Support', () => {
package/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "extends": "../../tsconfig.node.json",
3
- "include": ["src/**/*", "tsup.config.ts"],
4
- "exclude": ["node_modules", "**/*.test.ts"]
3
+ "include": ["src/**/*", "tsup.config.ts", "integration-tests/**/*"],
4
+ "exclude": ["node_modules", "integration-tests/node_modules", "src/example.ts", "**/*.test.ts"]
5
5
  }
package/tsup.config.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { defineConfig } from 'tsup';
2
1
  import { generateTypes } from '@internal/types-builder';
2
+ import { defineConfig } from 'tsup';
3
3
 
4
4
  export default defineConfig({
5
5
  entry: ['src/index.ts'],