@mastra/client-js 0.1.0-alpha.14 → 0.1.0-alpha.15

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.mts CHANGED
@@ -116,6 +116,16 @@ interface GetLogParams {
116
116
  }
117
117
  type GetLogsResponse = BaseLogMessage[];
118
118
  type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
119
+ interface GetTelemetryResponse {
120
+ traces: any[];
121
+ }
122
+ interface GetTelemetryParams {
123
+ name?: string;
124
+ scope?: string;
125
+ page?: number;
126
+ perPage?: number;
127
+ attribute?: Record<string, string>;
128
+ }
119
129
 
120
130
  declare class BaseResource {
121
131
  readonly options: ClientOptions;
@@ -360,6 +370,12 @@ declare class MastraClient extends BaseResource {
360
370
  * @returns Promise containing array of log messages
361
371
  */
362
372
  getLogForRun(params: GetLogParams): Promise<GetLogsResponse>;
373
+ /**
374
+ * List of all traces (paged)
375
+ * @param params - Parameters for filtering traces
376
+ * @returns Promise containing telemetry data
377
+ */
378
+ getTelemetry(params?: GetTelemetryParams): Promise<GetTelemetryResponse>;
363
379
  }
364
380
 
365
- export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams };
381
+ export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams };
package/dist/index.mjs CHANGED
@@ -406,6 +406,24 @@ var MastraClient = class extends BaseResource {
406
406
  getLogForRun(params) {
407
407
  return this.request(`/api/logs/${params.runId}?transportId=${params.transportId}`);
408
408
  }
409
+ /**
410
+ * List of all traces (paged)
411
+ * @param params - Parameters for filtering traces
412
+ * @returns Promise containing telemetry data
413
+ */
414
+ getTelemetry(params) {
415
+ const { name, scope, page, perPage, attribute } = params || {};
416
+ const _attribute = attribute ? Object.entries(attribute).map(([key, value]) => `${key}:${value}`) : [];
417
+ const queryObj = {
418
+ name: name ?? "",
419
+ scope: scope ?? "",
420
+ page: String(page) ? String(page) : "",
421
+ perPage: perPage ? String(perPage) : "",
422
+ attribute: _attribute?.length ? _attribute : ""
423
+ };
424
+ const queryParams = new URLSearchParams(queryObj);
425
+ return this.request(`/api/telemetry?${queryParams}`);
426
+ }
409
427
  };
410
428
 
411
429
  export { MastraClient };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/client-js",
3
- "version": "0.1.0-alpha.14",
3
+ "version": "0.1.0-alpha.15",
4
4
  "description": "The official TypeScript library for the Mastra Client API",
5
5
  "author": "",
6
6
  "types": "dist/index.d.mts",
package/src/client.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ClientOptions, CreateMemoryThreadParams, CreateMemoryThreadResponse, GetAgentResponse, GetLogParams, GetLogsParams, GetLogsResponse, GetMemoryThreadParams, GetMemoryThreadResponse, GetToolResponse, GetWorkflowResponse, RequestOptions, SaveMessageToMemoryParams, SaveMessageToMemoryResponse } from './types';
1
+ import type { ClientOptions, CreateMemoryThreadParams, CreateMemoryThreadResponse, GetAgentResponse, GetLogParams, GetLogsParams, GetLogsResponse, GetMemoryThreadParams, GetMemoryThreadResponse, GetTelemetryParams, GetTelemetryResponse, GetToolResponse, GetWorkflowResponse, RequestOptions, SaveMessageToMemoryParams, SaveMessageToMemoryResponse } from './types';
2
2
  import { Agent, MemoryThread, Tool, Workflow, Vector, BaseResource } from './resources';
3
3
 
4
4
  export class MastraClient extends BaseResource {
@@ -132,4 +132,25 @@ export class MastraClient extends BaseResource {
132
132
  public getLogForRun(params: GetLogParams): Promise<GetLogsResponse> {
133
133
  return this.request(`/api/logs/${params.runId}?transportId=${params.transportId}`);
134
134
  }
135
+
136
+ /**
137
+ * List of all traces (paged)
138
+ * @param params - Parameters for filtering traces
139
+ * @returns Promise containing telemetry data
140
+ */
141
+ public getTelemetry(params?: GetTelemetryParams): Promise<GetTelemetryResponse> {
142
+ const { name, scope, page, perPage, attribute } = params || {};
143
+ const _attribute = attribute ? Object.entries(attribute).map(([key, value]) => `${key}:${value}`) : [];
144
+
145
+ const queryObj = {
146
+ name: name ?? '',
147
+ scope: scope ?? '',
148
+ page: String(page) ? String(page) : '',
149
+ perPage: perPage ? String(perPage) : '',
150
+ attribute: _attribute?.length ? _attribute : ''
151
+ }
152
+
153
+ const queryParams = new URLSearchParams(queryObj);
154
+ return this.request(`/api/telemetry?${queryParams}`);
155
+ }
135
156
  }
package/src/types.ts CHANGED
@@ -143,3 +143,15 @@ export type RequestFunction = (
143
143
  path: string,
144
144
  options?: RequestOptions
145
145
  ) => Promise<any>;
146
+
147
+ export interface GetTelemetryResponse {
148
+ traces: any[]
149
+ }
150
+
151
+ export interface GetTelemetryParams {
152
+ name?: string,
153
+ scope?: string,
154
+ page?: number,
155
+ perPage?: number,
156
+ attribute?: Record<string, string>
157
+ }