@mastra/client-js 0.0.0-llamaindex-extract-20250416163822 → 0.0.0-main-test-20251105183450

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 (65) hide show
  1. package/CHANGELOG.md +2783 -2
  2. package/LICENSE.md +11 -42
  3. package/README.md +12 -15
  4. package/dist/client.d.ts +254 -0
  5. package/dist/client.d.ts.map +1 -0
  6. package/dist/example.d.ts +2 -0
  7. package/dist/example.d.ts.map +1 -0
  8. package/dist/index.cjs +2722 -268
  9. package/dist/index.cjs.map +1 -0
  10. package/dist/index.d.ts +5 -585
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +2717 -269
  13. package/dist/index.js.map +1 -0
  14. package/dist/resources/a2a.d.ts +41 -0
  15. package/dist/resources/a2a.d.ts.map +1 -0
  16. package/dist/resources/agent-builder.d.ts +186 -0
  17. package/dist/resources/agent-builder.d.ts.map +1 -0
  18. package/dist/resources/agent.d.ts +181 -0
  19. package/dist/resources/agent.d.ts.map +1 -0
  20. package/dist/resources/base.d.ts +13 -0
  21. package/dist/resources/base.d.ts.map +1 -0
  22. package/dist/resources/index.d.ts +11 -0
  23. package/dist/resources/index.d.ts.map +1 -0
  24. package/dist/resources/mcp-tool.d.ts +28 -0
  25. package/dist/resources/mcp-tool.d.ts.map +1 -0
  26. package/dist/resources/memory-thread.d.ts +53 -0
  27. package/dist/resources/memory-thread.d.ts.map +1 -0
  28. package/dist/resources/observability.d.ts +35 -0
  29. package/dist/resources/observability.d.ts.map +1 -0
  30. package/dist/resources/tool.d.ts +24 -0
  31. package/dist/resources/tool.d.ts.map +1 -0
  32. package/dist/resources/vector.d.ts +51 -0
  33. package/dist/resources/vector.d.ts.map +1 -0
  34. package/dist/resources/workflow.d.ts +216 -0
  35. package/dist/resources/workflow.d.ts.map +1 -0
  36. package/dist/tools.d.ts +22 -0
  37. package/dist/tools.d.ts.map +1 -0
  38. package/dist/types.d.ts +450 -0
  39. package/dist/types.d.ts.map +1 -0
  40. package/dist/utils/index.d.ts +11 -0
  41. package/dist/utils/index.d.ts.map +1 -0
  42. package/dist/utils/process-client-tools.d.ts +3 -0
  43. package/dist/utils/process-client-tools.d.ts.map +1 -0
  44. package/dist/utils/process-mastra-stream.d.ts +11 -0
  45. package/dist/utils/process-mastra-stream.d.ts.map +1 -0
  46. package/dist/utils/zod-to-json-schema.d.ts +3 -0
  47. package/dist/utils/zod-to-json-schema.d.ts.map +1 -0
  48. package/package.json +44 -18
  49. package/dist/index.d.cts +0 -585
  50. package/eslint.config.js +0 -6
  51. package/src/client.ts +0 -223
  52. package/src/example.ts +0 -65
  53. package/src/index.test.ts +0 -710
  54. package/src/index.ts +0 -2
  55. package/src/resources/agent.ts +0 -205
  56. package/src/resources/base.ts +0 -70
  57. package/src/resources/index.ts +0 -7
  58. package/src/resources/memory-thread.ts +0 -60
  59. package/src/resources/network.ts +0 -92
  60. package/src/resources/tool.ts +0 -32
  61. package/src/resources/vector.ts +0 -83
  62. package/src/resources/workflow.ts +0 -215
  63. package/src/types.ts +0 -224
  64. package/tsconfig.json +0 -5
  65. package/vitest.config.js +0 -8
@@ -1,215 +0,0 @@
1
- import type { GetWorkflowResponse, ClientOptions, WorkflowRunResult } from '../types';
2
-
3
- import { BaseResource } from './base';
4
-
5
- const RECORD_SEPARATOR = '\x1E';
6
-
7
- export class Workflow extends BaseResource {
8
- constructor(
9
- options: ClientOptions,
10
- private workflowId: string,
11
- ) {
12
- super(options);
13
- }
14
-
15
- /**
16
- * Retrieves details about the workflow
17
- * @returns Promise containing workflow details including steps and graphs
18
- */
19
- details(): Promise<GetWorkflowResponse> {
20
- return this.request(`/api/workflows/${this.workflowId}`);
21
- }
22
-
23
- /**
24
- * @deprecated Use `startAsync` instead
25
- * Executes the workflow with the provided parameters
26
- * @param params - Parameters required for workflow execution
27
- * @returns Promise containing the workflow execution results
28
- */
29
- execute(params: Record<string, any>): Promise<WorkflowRunResult> {
30
- return this.request(`/api/workflows/${this.workflowId}/execute`, {
31
- method: 'POST',
32
- body: params,
33
- });
34
- }
35
-
36
- /**
37
- * Creates a new workflow run
38
- * @returns Promise containing the generated run ID
39
- */
40
- createRun(params?: { runId?: string }): Promise<{ runId: string }> {
41
- const searchParams = new URLSearchParams();
42
-
43
- if (!!params?.runId) {
44
- searchParams.set('runId', params.runId);
45
- }
46
-
47
- return this.request(`/api/workflows/${this.workflowId}/createRun?${searchParams.toString()}`, {
48
- method: 'POST',
49
- });
50
- }
51
-
52
- /**
53
- * Starts a workflow run synchronously without waiting for the workflow to complete
54
- * @param params - Object containing the runId and triggerData
55
- * @returns Promise containing success message
56
- */
57
- start(params: { runId: string; triggerData: Record<string, any> }): Promise<{ message: string }> {
58
- return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
59
- method: 'POST',
60
- body: params?.triggerData,
61
- });
62
- }
63
-
64
- /**
65
- * Resumes a suspended workflow step synchronously without waiting for the workflow to complete
66
- * @param stepId - ID of the step to resume
67
- * @param runId - ID of the workflow run
68
- * @param context - Context to resume the workflow with
69
- * @returns Promise containing the workflow resume results
70
- */
71
- resume({
72
- stepId,
73
- runId,
74
- context,
75
- }: {
76
- stepId: string;
77
- runId: string;
78
- context: Record<string, any>;
79
- }): Promise<{ message: string }> {
80
- return this.request(`/api/workflows/${this.workflowId}/resume?runId=${runId}`, {
81
- method: 'POST',
82
- body: {
83
- stepId,
84
- context,
85
- },
86
- });
87
- }
88
-
89
- /**
90
- * Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
91
- * @param params - Object containing the optional runId and triggerData
92
- * @returns Promise containing the workflow execution results
93
- */
94
- startAsync(params: { runId?: string; triggerData: Record<string, any> }): Promise<WorkflowRunResult> {
95
- const searchParams = new URLSearchParams();
96
-
97
- if (!!params?.runId) {
98
- searchParams.set('runId', params.runId);
99
- }
100
-
101
- return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
102
- method: 'POST',
103
- body: params?.triggerData,
104
- });
105
- }
106
-
107
- /**
108
- * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
109
- * @param params - Object containing the runId, stepId, and context
110
- * @returns Promise containing the workflow resume results
111
- */
112
- resumeAsync(params: { runId: string; stepId: string; context: Record<string, any> }): Promise<WorkflowRunResult> {
113
- return this.request(`/api/workflows/${this.workflowId}/resume-async?runId=${params.runId}`, {
114
- method: 'POST',
115
- body: {
116
- stepId: params.stepId,
117
- context: params.context,
118
- },
119
- });
120
- }
121
-
122
- /**
123
- * Creates an async generator that processes a readable stream and yields records
124
- * separated by the Record Separator character (\x1E)
125
- *
126
- * @param stream - The readable stream to process
127
- * @returns An async generator that yields parsed records
128
- */
129
- private async *streamProcessor(stream: ReadableStream): AsyncGenerator<WorkflowRunResult, void, unknown> {
130
- const reader = stream.getReader();
131
-
132
- // Track if we've finished reading from the stream
133
- let doneReading = false;
134
- // Buffer to accumulate partial chunks
135
- let buffer = '';
136
-
137
- try {
138
- while (!doneReading) {
139
- // Read the next chunk from the stream
140
- const { done, value } = await reader.read();
141
- doneReading = done;
142
-
143
- // Skip processing if we're done and there's no value
144
- if (done && !value) continue;
145
-
146
- try {
147
- // Decode binary data to text
148
- const decoded = value ? new TextDecoder().decode(value) : '';
149
-
150
- // Split the combined buffer and new data by record separator
151
- const chunks = (buffer + decoded).split(RECORD_SEPARATOR);
152
-
153
- // The last chunk might be incomplete, so save it for the next iteration
154
- buffer = chunks.pop() || '';
155
-
156
- // Process complete chunks
157
- for (const chunk of chunks) {
158
- if (chunk) {
159
- // Only process non-empty chunks
160
- if (typeof chunk === 'string') {
161
- try {
162
- const parsedChunk = JSON.parse(chunk);
163
- yield parsedChunk;
164
- } catch {
165
- // Silently ignore parsing errors to maintain stream processing
166
- // This allows the stream to continue even if one record is malformed
167
- }
168
- }
169
- }
170
- }
171
- } catch (error) {
172
- // Silently ignore parsing errors to maintain stream processing
173
- // This allows the stream to continue even if one record is malformed
174
- }
175
- }
176
-
177
- // Process any remaining data in the buffer after stream is done
178
- if (buffer) {
179
- try {
180
- yield JSON.parse(buffer);
181
- } catch {
182
- // Ignore parsing error for final chunk
183
- }
184
- }
185
- } finally {
186
- // Always ensure we clean up the reader
187
- reader.cancel().catch(() => {
188
- // Ignore cancel errors
189
- });
190
- }
191
- }
192
-
193
- /**
194
- * Watches workflow transitions in real-time
195
- * @param runId - Optional run ID to filter the watch stream
196
- * @returns AsyncGenerator that yields parsed records from the workflow watch stream
197
- */
198
- async watch({ runId }: { runId?: string }, onRecord: (record: WorkflowRunResult) => void) {
199
- const response: Response = await this.request(`/api/workflows/${this.workflowId}/watch?runId=${runId}`, {
200
- stream: true,
201
- });
202
-
203
- if (!response.ok) {
204
- throw new Error(`Failed to watch workflow: ${response.statusText}`);
205
- }
206
-
207
- if (!response.body) {
208
- throw new Error('Response body is null');
209
- }
210
-
211
- for await (const record of this.streamProcessor(response.body)) {
212
- onRecord(record);
213
- }
214
- }
215
- }
package/src/types.ts DELETED
@@ -1,224 +0,0 @@
1
- import type {
2
- MessageType,
3
- AiMessageType,
4
- CoreMessage,
5
- QueryResult,
6
- StepAction,
7
- StepGraph,
8
- StorageThreadType,
9
- BaseLogMessage,
10
- WorkflowRunResult as CoreWorkflowRunResult,
11
- } from '@mastra/core';
12
-
13
- import type { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
14
- import type { JSONSchema7 } from 'json-schema';
15
- import type { ZodSchema } from 'zod';
16
-
17
- export interface ClientOptions {
18
- /** Base URL for API requests */
19
- baseUrl: string;
20
- /** Number of retry attempts for failed requests */
21
- retries?: number;
22
- /** Initial backoff time in milliseconds between retries */
23
- backoffMs?: number;
24
- /** Maximum backoff time in milliseconds between retries */
25
- maxBackoffMs?: number;
26
- /** Custom headers to include with requests */
27
- headers?: Record<string, string>;
28
- /** Abort signal for request */
29
- }
30
-
31
- export interface RequestOptions {
32
- method?: string;
33
- headers?: Record<string, string>;
34
- body?: any;
35
- stream?: boolean;
36
- signal?: AbortSignal;
37
- }
38
-
39
- export interface GetAgentResponse {
40
- name: string;
41
- instructions: string;
42
- tools: Record<string, GetToolResponse>;
43
- provider: string;
44
- modelId: string;
45
- }
46
-
47
- export type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
48
- messages: string | string[] | CoreMessage[] | AiMessageType[];
49
- } & Partial<AgentGenerateOptions<T>>;
50
-
51
- export type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
52
- messages: string | string[] | CoreMessage[] | AiMessageType[];
53
- } & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry'>;
54
-
55
- export interface GetEvalsByAgentIdResponse extends GetAgentResponse {
56
- evals: any[];
57
- }
58
-
59
- export interface GetToolResponse {
60
- id: string;
61
- description: string;
62
- inputSchema: string;
63
- outputSchema: string;
64
- }
65
-
66
- export interface GetWorkflowResponse {
67
- name: string;
68
- triggerSchema: string;
69
- steps: Record<string, StepAction<any, any, any, any>>;
70
- stepGraph: StepGraph;
71
- stepSubscriberGraph: Record<string, StepGraph>;
72
- workflowId?: string;
73
- }
74
-
75
- export type WorkflowRunResult = {
76
- activePaths: Record<string, { status: string; suspendPayload?: any; stepPath: string[] }>;
77
- results: CoreWorkflowRunResult<any, any, any>['results'];
78
- timestamp: number;
79
- runId: string;
80
- };
81
- export interface UpsertVectorParams {
82
- indexName: string;
83
- vectors: number[][];
84
- metadata?: Record<string, any>[];
85
- ids?: string[];
86
- }
87
- export interface CreateIndexParams {
88
- indexName: string;
89
- dimension: number;
90
- metric?: 'cosine' | 'euclidean' | 'dotproduct';
91
- }
92
-
93
- export interface QueryVectorParams {
94
- indexName: string;
95
- queryVector: number[];
96
- topK?: number;
97
- filter?: Record<string, any>;
98
- includeVector?: boolean;
99
- }
100
-
101
- export interface QueryVectorResponse {
102
- results: QueryResult[];
103
- }
104
-
105
- export interface GetVectorIndexResponse {
106
- dimension: number;
107
- metric: 'cosine' | 'euclidean' | 'dotproduct';
108
- count: number;
109
- }
110
-
111
- export interface SaveMessageToMemoryParams {
112
- messages: MessageType[];
113
- agentId: string;
114
- }
115
-
116
- export type SaveMessageToMemoryResponse = MessageType[];
117
-
118
- export interface CreateMemoryThreadParams {
119
- title: string;
120
- metadata: Record<string, any>;
121
- resourceid: string;
122
- threadId: string;
123
- agentId: string;
124
- }
125
-
126
- export type CreateMemoryThreadResponse = StorageThreadType;
127
-
128
- export interface GetMemoryThreadParams {
129
- resourceId: string;
130
- agentId: string;
131
- }
132
-
133
- export type GetMemoryThreadResponse = StorageThreadType[];
134
-
135
- export interface UpdateMemoryThreadParams {
136
- title: string;
137
- metadata: Record<string, any>;
138
- resourceid: string;
139
- }
140
-
141
- export interface GetMemoryThreadMessagesResponse {
142
- messages: CoreMessage[];
143
- uiMessages: AiMessageType[];
144
- }
145
-
146
- export interface GetLogsParams {
147
- transportId: string;
148
- }
149
-
150
- export interface GetLogParams {
151
- runId: string;
152
- transportId: string;
153
- }
154
-
155
- export type GetLogsResponse = BaseLogMessage[];
156
-
157
- export type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
158
-
159
- type SpanStatus = {
160
- code: number;
161
- };
162
-
163
- type SpanOther = {
164
- droppedAttributesCount: number;
165
- droppedEventsCount: number;
166
- droppedLinksCount: number;
167
- };
168
-
169
- type SpanEventAttributes = {
170
- key: string;
171
- value: { [key: string]: string | number | boolean | null };
172
- };
173
-
174
- type SpanEvent = {
175
- attributes: SpanEventAttributes[];
176
- name: string;
177
- timeUnixNano: string;
178
- droppedAttributesCount: number;
179
- };
180
-
181
- type Span = {
182
- id: string;
183
- parentSpanId: string | null;
184
- traceId: string;
185
- name: string;
186
- scope: string;
187
- kind: number;
188
- status: SpanStatus;
189
- events: SpanEvent[];
190
- links: any[];
191
- attributes: Record<string, string | number | boolean | null>;
192
- startTime: number;
193
- endTime: number;
194
- duration: number;
195
- other: SpanOther;
196
- createdAt: string;
197
- };
198
-
199
- export interface GetTelemetryResponse {
200
- traces: Span[];
201
- }
202
-
203
- export interface GetTelemetryParams {
204
- name?: string;
205
- scope?: string;
206
- page?: number;
207
- perPage?: number;
208
- attribute?: Record<string, string>;
209
- }
210
-
211
- export interface GetNetworkResponse {
212
- name: string;
213
- instructions: string;
214
- agents: Array<{
215
- name: string;
216
- provider: string;
217
- modelId: string;
218
- }>;
219
- routingModel: {
220
- provider: string;
221
- modelId: string;
222
- };
223
- state?: Record<string, any>;
224
- }
package/tsconfig.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.node.json",
3
- "include": ["src/**/*"],
4
- "exclude": ["node_modules", "**/*.test.ts"]
5
- }
package/vitest.config.js DELETED
@@ -1,8 +0,0 @@
1
- import { defineConfig } from 'vitest/config';
2
-
3
- export default defineConfig({
4
- test: {
5
- environment: 'node',
6
- include: ['src/**/*.test.ts'],
7
- },
8
- });