@mastra/client-js 0.0.0-tool-call-parts-20250630193309 → 0.0.0-transpile-packages-20250730132657

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.
@@ -115,10 +115,10 @@ export class Workflow extends BaseResource {
115
115
  if (params?.toDate) {
116
116
  searchParams.set('toDate', params.toDate.toISOString());
117
117
  }
118
- if (params?.limit) {
118
+ if (params?.limit !== null && params?.limit !== undefined && !isNaN(Number(params?.limit))) {
119
119
  searchParams.set('limit', String(params.limit));
120
120
  }
121
- if (params?.offset) {
121
+ if (params?.offset !== null && params?.offset !== undefined && !isNaN(Number(params?.offset))) {
122
122
  searchParams.set('offset', String(params.offset));
123
123
  }
124
124
  if (params?.resourceId) {
@@ -150,6 +150,29 @@ export class Workflow extends BaseResource {
150
150
  return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/execution-result`);
151
151
  }
152
152
 
153
+ /**
154
+ * Cancels a specific workflow run by its ID
155
+ * @param runId - The ID of the workflow run to cancel
156
+ * @returns Promise containing a success message
157
+ */
158
+ cancelRun(runId: string): Promise<{ message: string }> {
159
+ return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/cancel`, {
160
+ method: 'POST',
161
+ });
162
+ }
163
+
164
+ /**
165
+ * Sends an event to a specific workflow run by its ID
166
+ * @param params - Object containing the runId, event and data
167
+ * @returns Promise containing a success message
168
+ */
169
+ sendRunEvent(params: { runId: string; event: string; data: unknown }): Promise<{ message: string }> {
170
+ return this.request(`/api/workflows/${this.workflowId}/runs/${params.runId}/send-event`, {
171
+ method: 'POST',
172
+ body: { event: params.event, data: params.data },
173
+ });
174
+ }
175
+
153
176
  /**
154
177
  * Creates a new workflow run
155
178
  * @param params - Optional object containing the optional runId
@@ -167,6 +190,15 @@ export class Workflow extends BaseResource {
167
190
  });
168
191
  }
169
192
 
193
+ /**
194
+ * Creates a new workflow run (alias for createRun)
195
+ * @param params - Optional object containing the optional runId
196
+ * @returns Promise containing the runId of the created run
197
+ */
198
+ createRunAsync(params?: { runId?: string }): Promise<{ runId: string }> {
199
+ return this.createRun(params);
200
+ }
201
+
170
202
  /**
171
203
  * Starts a workflow run synchronously without waiting for the workflow to complete
172
204
  * @param params - Object containing the runId, inputData and runtimeContext
@@ -266,6 +298,9 @@ export class Workflow extends BaseResource {
266
298
  throw new Error('Response body is null');
267
299
  }
268
300
 
301
+ //using undefined instead of empty string to avoid parsing errors
302
+ let failedChunk: string | undefined = undefined;
303
+
269
304
  // Create a transform stream that processes the response body
270
305
  const transformStream = new TransformStream<ArrayBuffer, { type: string; payload: any }>({
271
306
  start() {},
@@ -280,11 +315,13 @@ export class Workflow extends BaseResource {
280
315
  // Process each chunk
281
316
  for (const chunk of chunks) {
282
317
  if (chunk) {
318
+ const newChunk: string = failedChunk ? failedChunk + chunk : chunk;
283
319
  try {
284
- const parsedChunk = JSON.parse(chunk);
320
+ const parsedChunk = JSON.parse(newChunk);
285
321
  controller.enqueue(parsedChunk);
286
- } catch {
287
- // Silently ignore parsing errors
322
+ failedChunk = undefined;
323
+ } catch (error) {
324
+ failedChunk = newChunk;
288
325
  }
289
326
  }
290
327
  }
package/src/types.ts CHANGED
@@ -7,12 +7,16 @@ import type {
7
7
  WorkflowRuns,
8
8
  WorkflowRun,
9
9
  LegacyWorkflowRuns,
10
+ StorageGetMessagesArg,
11
+ PaginationInfo,
12
+ MastraMessageV2,
10
13
  } from '@mastra/core';
11
14
  import type { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
12
15
  import type { BaseLogMessage, LogLevel } from '@mastra/core/logger';
13
16
 
14
17
  import type { MCPToolType, ServerInfo } from '@mastra/core/mcp';
15
18
  import type { RuntimeContext } from '@mastra/core/runtime-context';
19
+ import type { MastraScorer, MastraScorerEntry, ScoreRowData } from '@mastra/core/scores';
16
20
  import type { Workflow, WatchEvent, WorkflowResult } from '@mastra/core/workflows';
17
21
  import type {
18
22
  StepAction,
@@ -34,6 +38,7 @@ export interface ClientOptions {
34
38
  /** Custom headers to include with requests */
35
39
  headers?: Record<string, string>;
36
40
  /** Abort signal for request */
41
+ abortSignal?: AbortSignal;
37
42
  }
38
43
 
39
44
  export interface RequestOptions {
@@ -41,7 +46,6 @@ export interface RequestOptions {
41
46
  headers?: Record<string, string>;
42
47
  body?: any;
43
48
  stream?: boolean;
44
- signal?: AbortSignal;
45
49
  }
46
50
 
47
51
  type WithoutMethods<T> = {
@@ -71,7 +75,9 @@ export type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undef
71
75
  experimental_output?: T;
72
76
  runtimeContext?: RuntimeContext | Record<string, any>;
73
77
  clientTools?: ToolsInput;
74
- } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
78
+ } & WithoutMethods<
79
+ Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>
80
+ >;
75
81
 
76
82
  export type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
77
83
  messages: string | string[] | CoreMessage[] | AiMessageType[];
@@ -79,7 +85,9 @@ export type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefin
79
85
  experimental_output?: T;
80
86
  runtimeContext?: RuntimeContext | Record<string, any>;
81
87
  clientTools?: ToolsInput;
82
- } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
88
+ } & WithoutMethods<
89
+ Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>
90
+ >;
83
91
 
84
92
  export interface GetEvalsByAgentIdResponse extends GetAgentResponse {
85
93
  evals: any[];
@@ -140,6 +148,17 @@ export interface GetWorkflowResponse {
140
148
  suspendSchema: string;
141
149
  };
142
150
  };
151
+ allSteps: {
152
+ [key: string]: {
153
+ id: string;
154
+ description: string;
155
+ inputSchema: string;
156
+ outputSchema: string;
157
+ resumeSchema: string;
158
+ suspendSchema: string;
159
+ isWorkflow: boolean;
160
+ };
161
+ };
143
162
  stepGraph: Workflow['serializedStepGraph'];
144
163
  inputSchema: string;
145
164
  outputSchema: string;
@@ -233,11 +252,17 @@ export interface GetMemoryThreadMessagesParams {
233
252
  limit?: number;
234
253
  }
235
254
 
255
+ export type GetMemoryThreadMessagesPaginatedParams = Omit<StorageGetMessagesArg, 'threadConfig' | 'threadId'>;
256
+
236
257
  export interface GetMemoryThreadMessagesResponse {
237
258
  messages: CoreMessage[];
238
259
  uiMessages: AiMessageType[];
239
260
  }
240
261
 
262
+ export type GetMemoryThreadMessagesPaginatedResponse = PaginationInfo & {
263
+ messages: MastraMessageV1[] | MastraMessageV2[];
264
+ };
265
+
241
266
  export interface GetLogsParams {
242
267
  transportId: string;
243
268
  fromDate?: Date;
@@ -375,6 +400,7 @@ export interface GenerateOrStreamVNextNetworkParams {
375
400
  message: string;
376
401
  threadId?: string;
377
402
  resourceId?: string;
403
+ runtimeContext?: RuntimeContext | Record<string, any>;
378
404
  }
379
405
 
380
406
  export interface LoopStreamVNextNetworkParams {
@@ -382,12 +408,23 @@ export interface LoopStreamVNextNetworkParams {
382
408
  threadId?: string;
383
409
  resourceId?: string;
384
410
  maxIterations?: number;
411
+ runtimeContext?: RuntimeContext | Record<string, any>;
385
412
  }
386
413
 
387
414
  export interface LoopVNextNetworkResponse {
388
415
  status: 'success';
389
416
  result: {
390
- text: string;
417
+ task: string;
418
+ resourceId: string;
419
+ resourceType: 'agent' | 'workflow' | 'none' | 'tool';
420
+ result: string;
421
+ iteration: number;
422
+ isOneOff: boolean;
423
+ prompt: string;
424
+ threadId?: string | undefined;
425
+ threadResourceId?: string | undefined;
426
+ isComplete?: boolean | undefined;
427
+ completionReason?: string | undefined;
391
428
  };
392
429
  steps: WorkflowResult<any, any>['steps'];
393
430
  }
@@ -409,3 +446,57 @@ export interface McpToolInfo {
409
446
  export interface McpServerToolListResponse {
410
447
  tools: McpToolInfo[];
411
448
  }
449
+
450
+ export type ClientScoreRowData = Omit<ScoreRowData, 'createdAt' | 'updatedAt'> & {
451
+ createdAt: string;
452
+ updatedAt: string;
453
+ };
454
+
455
+ // Scores-related types
456
+ export interface GetScoresByRunIdParams {
457
+ runId: string;
458
+ page?: number;
459
+ perPage?: number;
460
+ }
461
+
462
+ export interface GetScoresByScorerIdParams {
463
+ scorerId: string;
464
+ entityId?: string;
465
+ entityType?: string;
466
+ page?: number;
467
+ perPage?: number;
468
+ }
469
+
470
+ export interface GetScoresByEntityIdParams {
471
+ entityId: string;
472
+ entityType: string;
473
+ page?: number;
474
+ perPage?: number;
475
+ }
476
+
477
+ export interface SaveScoreParams {
478
+ score: ScoreRowData;
479
+ }
480
+
481
+ export interface GetScoresResponse {
482
+ pagination: {
483
+ total: number;
484
+ page: number;
485
+ perPage: number;
486
+ hasMore: boolean;
487
+ };
488
+ scores: ClientScoreRowData[];
489
+ }
490
+
491
+ export interface SaveScoreResponse {
492
+ score: ClientScoreRowData;
493
+ }
494
+
495
+ export type GetScorerResponse = MastraScorerEntry & {
496
+ agentIds: string[];
497
+ workflowIds: string[];
498
+ };
499
+
500
+ export interface GetScorersResponse {
501
+ scorers: Array<GetScorerResponse>;
502
+ }
@@ -1,4 +1,4 @@
1
- import { isVercelTool } from '@mastra/core/tools';
1
+ import { isVercelTool } from '@mastra/core/tools/is-vercel-tool';
2
2
  import { zodToJsonSchema } from './zod-to-json-schema';
3
3
  import type { ToolsInput } from '@mastra/core/agent';
4
4
 
@@ -1,19 +0,0 @@
1
-
2
- > @mastra/client-js@0.10.7 build /home/runner/work/mastra/mastra/client-sdks/client-js
3
- > tsup src/index.ts --format esm,cjs --dts --clean --treeshake=smallest --splitting
4
-
5
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.5.0
8
- CLI Target: es2022
9
- CLI Cleaning output folder
10
- ESM Build start
11
- CJS Build start
12
- ESM dist/index.js 67.20 KB
13
- ESM ⚡️ Build success in 2103ms
14
- CJS dist/index.cjs 67.49 KB
15
- CJS ⚡️ Build success in 2120ms
16
- DTS Build start
17
- DTS ⚡️ Build success in 15225ms
18
- DTS dist/index.d.ts 39.72 KB
19
- DTS dist/index.d.cts 39.72 KB