freestyle-sandboxes 0.0.96 → 0.1.0
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/README.md +39 -48
- package/index.cjs +4362 -0
- package/index.d.cts +9401 -0
- package/index.d.mts +9401 -0
- package/index.mjs +4348 -0
- package/package.json +16 -109
- package/dist/ai/inde.d.cts +0 -75
- package/dist/ai/inde.d.mts +0 -75
- package/dist/ai/index.cjs +0 -13
- package/dist/ai/index.d.cts +0 -75
- package/dist/ai/index.d.mts +0 -75
- package/dist/ai/index.mjs +0 -4
- package/dist/expo/inde.d.cts +0 -6
- package/dist/expo/inde.d.mts +0 -6
- package/dist/expo/index.cjs +0 -319
- package/dist/expo/index.d.cts +0 -6
- package/dist/expo/index.d.mts +0 -6
- package/dist/expo/index.mjs +0 -297
- package/dist/inde.d.cts +0 -373
- package/dist/inde.d.mts +0 -373
- package/dist/index-BKAG8L-o.mjs +0 -3061
- package/dist/index-DuOpIaWc.cjs +0 -3068
- package/dist/index.cjs +0 -1329
- package/dist/index.d-9H_wnIbz.d.ts +0 -4223
- package/dist/index.d.cts +0 -373
- package/dist/index.d.mts +0 -373
- package/dist/index.mjs +0 -1327
- package/dist/langgraph/inde.d.cts +0 -4180
- package/dist/langgraph/inde.d.mts +0 -4180
- package/dist/langgraph/index.cjs +0 -17155
- package/dist/langgraph/index.d.cts +0 -4180
- package/dist/langgraph/index.d.mts +0 -4180
- package/dist/langgraph/index.mjs +0 -17153
- package/dist/mastra/inde.d.cts +0 -2623
- package/dist/mastra/inde.d.mts +0 -2623
- package/dist/mastra/index.cjs +0 -55
- package/dist/mastra/index.d.cts +0 -2623
- package/dist/mastra/index.d.mts +0 -2623
- package/dist/mastra/index.mjs +0 -53
- package/dist/react/dev-server/index..d.cts +0 -33
- package/dist/react/dev-server/index..d.mts +0 -33
- package/dist/react/dev-server/index.cjs +0 -148
- package/dist/react/dev-server/index.d.cts +0 -33
- package/dist/react/dev-server/index.d.mts +0 -33
- package/dist/react/dev-server/index.mjs +0 -145
- package/dist/types.gen-CJa21P0C.d.ts +0 -1902
- package/dist/types.gen-DKjMRuu5.d.ts +0 -1898
- package/dist/utils/inde.d.cts +0 -10
- package/dist/utils/inde.d.mts +0 -10
- package/dist/utils/index.cjs +0 -100
- package/dist/utils/index.d.cts +0 -10
- package/dist/utils/index.d.mts +0 -10
- package/dist/utils/index.mjs +0 -75
- package/openapi/index.ts +0 -3
- package/openapi/sdk.gen.ts +0 -929
- package/openapi/types.gen.ts +0 -2234
- package/openapi-ts.config.ts +0 -7
- package/openapi.json +0 -1
- package/src/ai/index.ts +0 -164
- package/src/dev-server.ts +0 -95
- package/src/expo/_expo_internals.ts +0 -389
- package/src/expo/index.ts +0 -26
- package/src/index.ts +0 -1459
- package/src/langgraph/index.ts +0 -33
- package/src/mastra/index.ts +0 -38
- package/src/react/dev-server/index.tsx +0 -195
- package/src/react/dev-server/types.ts +0 -5
- package/src/utils/index.ts +0 -97
- package/tsconfig.json +0 -8
package/dist/mastra/inde.d.cts
DELETED
|
@@ -1,2623 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { z, ZodSchema } from 'zod';
|
|
3
|
-
import { S as SpanAttributes, H as HrTime, b as SpanKind, c as SpanContext, d as SpanStatus, L as Link, e as Tracer, f as Span, T as Tool$1, g as LanguageModel, h as LanguageModelV1, C as CoreMessage$1, U as UserContent, A as AssistantContent, i as ToolContent, E as EmbeddingModel, a as ToolExecutionOptions, M as Message, J as JSONSchema7, j as TelemetrySettings, k as generateText, G as GenerateTextResult, l as generateObject, m as GenerateObjectResult, s as streamText, n as StreamTextResult, o as streamObject, p as StreamObjectResult, D as DeepPartial, q as CoreUserMessage } from '../index.d-9H_wnIbz.js';
|
|
4
|
-
import { Transform } from 'stream';
|
|
5
|
-
import { EventEmitter } from 'events';
|
|
6
|
-
import { ServerResponse, IncomingMessage } from 'http';
|
|
7
|
-
import { WorkerOptions } from 'worker_threads';
|
|
8
|
-
import { F as FreestyleExecuteScriptParamsConfiguration } from '../types.gen-CJa21P0C.js';
|
|
9
|
-
import 'node:http';
|
|
10
|
-
|
|
11
|
-
// Type definitions for pino-std-serializers 2.4
|
|
12
|
-
// Definitions by: Connor Fitzgerald <https://github.com/connorjayfitzgerald>
|
|
13
|
-
// Igor Savin <https://github.com/kibertoad>
|
|
14
|
-
// TypeScript Version: 2.7
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
interface SerializedError {
|
|
19
|
-
/**
|
|
20
|
-
* The name of the object's constructor.
|
|
21
|
-
*/
|
|
22
|
-
type: string;
|
|
23
|
-
/**
|
|
24
|
-
* The supplied error message.
|
|
25
|
-
*/
|
|
26
|
-
message: string;
|
|
27
|
-
/**
|
|
28
|
-
* The stack when the error was generated.
|
|
29
|
-
*/
|
|
30
|
-
stack: string;
|
|
31
|
-
/**
|
|
32
|
-
* Non-enumerable. The original Error object. This will not be included in the logged output.
|
|
33
|
-
* This is available for subsequent serializers to use.
|
|
34
|
-
*/
|
|
35
|
-
raw: Error;
|
|
36
|
-
/**
|
|
37
|
-
* `cause` is never included in the log output, if you need the `cause`, use {@link raw.cause}
|
|
38
|
-
*/
|
|
39
|
-
cause?: never;
|
|
40
|
-
/**
|
|
41
|
-
* Any other extra properties that have been attached to the object will also be present on the serialized object.
|
|
42
|
-
*/
|
|
43
|
-
[key: string]: any;
|
|
44
|
-
[key: number]: any;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Serializes an Error object. Does not serialize "err.cause" fields (will append the err.cause.message to err.message
|
|
49
|
-
* and err.cause.stack to err.stack)
|
|
50
|
-
*/
|
|
51
|
-
declare function err(err: Error): SerializedError;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Serializes an Error object, including full serialization for any err.cause fields recursively.
|
|
55
|
-
*/
|
|
56
|
-
declare function errWithCause(err: Error): SerializedError;
|
|
57
|
-
|
|
58
|
-
interface SerializedRequest {
|
|
59
|
-
/**
|
|
60
|
-
* Defaults to `undefined`, unless there is an `id` property already attached to the `request` object or
|
|
61
|
-
* to the `request.info` object. Attach a synchronous function to the `request.id` that returns an
|
|
62
|
-
* identifier to have the value filled.
|
|
63
|
-
*/
|
|
64
|
-
id: string | undefined;
|
|
65
|
-
/**
|
|
66
|
-
* HTTP method.
|
|
67
|
-
*/
|
|
68
|
-
method: string;
|
|
69
|
-
/**
|
|
70
|
-
* Request pathname (as per req.url in core HTTP).
|
|
71
|
-
*/
|
|
72
|
-
url: string;
|
|
73
|
-
/**
|
|
74
|
-
* Reference to the `headers` object from the request (as per req.headers in core HTTP).
|
|
75
|
-
*/
|
|
76
|
-
headers: Record<string, string>;
|
|
77
|
-
remoteAddress: string;
|
|
78
|
-
remotePort: number;
|
|
79
|
-
params: Record<string, string>;
|
|
80
|
-
query: Record<string, string>;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Non-enumerable, i.e. will not be in the output, original request object. This is available for subsequent
|
|
84
|
-
* serializers to use. In cases where the `request` input already has a `raw` property this will
|
|
85
|
-
* replace the original `request.raw` property.
|
|
86
|
-
*/
|
|
87
|
-
raw: IncomingMessage;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Serializes a Request object.
|
|
92
|
-
*/
|
|
93
|
-
declare function req(req: IncomingMessage): SerializedRequest;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Used internally by Pino for general request logging.
|
|
97
|
-
*/
|
|
98
|
-
declare function mapHttpRequest(req: IncomingMessage): {
|
|
99
|
-
req: SerializedRequest
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
interface SerializedResponse {
|
|
103
|
-
/**
|
|
104
|
-
* HTTP status code.
|
|
105
|
-
*/
|
|
106
|
-
statusCode: number;
|
|
107
|
-
/**
|
|
108
|
-
* The headers to be sent in the response.
|
|
109
|
-
*/
|
|
110
|
-
headers: Record<string, string>;
|
|
111
|
-
/**
|
|
112
|
-
* Non-enumerable, i.e. will not be in the output, original response object. This is available for subsequent serializers to use.
|
|
113
|
-
*/
|
|
114
|
-
raw: ServerResponse;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Serializes a Response object.
|
|
119
|
-
*/
|
|
120
|
-
declare function res(res: ServerResponse): SerializedResponse;
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Used internally by Pino for general response logging.
|
|
124
|
-
*/
|
|
125
|
-
declare function mapHttpResponse(res: ServerResponse): {
|
|
126
|
-
res: SerializedResponse
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
type CustomErrorSerializer = (err: SerializedError) => Record<string, any>;
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* A utility method for wrapping the default error serializer.
|
|
133
|
-
* This allows custom serializers to work with the already serialized object.
|
|
134
|
-
* The customSerializer accepts one parameter — the newly serialized error object — and returns the new (or updated) error object.
|
|
135
|
-
*/
|
|
136
|
-
declare function wrapErrorSerializer(customSerializer: CustomErrorSerializer): (err: Error) => Record<string, any>;
|
|
137
|
-
|
|
138
|
-
type CustomRequestSerializer = (req: SerializedRequest) => Record<string, any>;
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* A utility method for wrapping the default request serializer.
|
|
142
|
-
* This allows custom serializers to work with the already serialized object.
|
|
143
|
-
* The customSerializer accepts one parameter — the newly serialized request object — and returns the new (or updated) request object.
|
|
144
|
-
*/
|
|
145
|
-
declare function wrapRequestSerializer(customSerializer: CustomRequestSerializer): (req: IncomingMessage) => Record<string, any>;
|
|
146
|
-
|
|
147
|
-
type CustomResponseSerializer = (res: SerializedResponse) => Record<string, any>;
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* A utility method for wrapping the default response serializer.
|
|
151
|
-
* This allows custom serializers to work with the already serialized object.
|
|
152
|
-
* The customSerializer accepts one parameter — the newly serialized response object — and returns the new (or updated) response object.
|
|
153
|
-
*/
|
|
154
|
-
declare function wrapResponseSerializer(customSerializer: CustomResponseSerializer): (res: ServerResponse) => Record<string, any>;
|
|
155
|
-
|
|
156
|
-
type pinoStdSerializers_CustomErrorSerializer = CustomErrorSerializer;
|
|
157
|
-
type pinoStdSerializers_CustomRequestSerializer = CustomRequestSerializer;
|
|
158
|
-
type pinoStdSerializers_CustomResponseSerializer = CustomResponseSerializer;
|
|
159
|
-
type pinoStdSerializers_SerializedError = SerializedError;
|
|
160
|
-
type pinoStdSerializers_SerializedRequest = SerializedRequest;
|
|
161
|
-
type pinoStdSerializers_SerializedResponse = SerializedResponse;
|
|
162
|
-
declare const pinoStdSerializers_err: typeof err;
|
|
163
|
-
declare const pinoStdSerializers_errWithCause: typeof errWithCause;
|
|
164
|
-
declare const pinoStdSerializers_mapHttpRequest: typeof mapHttpRequest;
|
|
165
|
-
declare const pinoStdSerializers_mapHttpResponse: typeof mapHttpResponse;
|
|
166
|
-
declare const pinoStdSerializers_req: typeof req;
|
|
167
|
-
declare const pinoStdSerializers_res: typeof res;
|
|
168
|
-
declare const pinoStdSerializers_wrapErrorSerializer: typeof wrapErrorSerializer;
|
|
169
|
-
declare const pinoStdSerializers_wrapRequestSerializer: typeof wrapRequestSerializer;
|
|
170
|
-
declare const pinoStdSerializers_wrapResponseSerializer: typeof wrapResponseSerializer;
|
|
171
|
-
declare namespace pinoStdSerializers {
|
|
172
|
-
export { type pinoStdSerializers_CustomErrorSerializer as CustomErrorSerializer, type pinoStdSerializers_CustomRequestSerializer as CustomRequestSerializer, type pinoStdSerializers_CustomResponseSerializer as CustomResponseSerializer, type pinoStdSerializers_SerializedError as SerializedError, type pinoStdSerializers_SerializedRequest as SerializedRequest, type pinoStdSerializers_SerializedResponse as SerializedResponse, pinoStdSerializers_err as err, pinoStdSerializers_errWithCause as errWithCause, pinoStdSerializers_mapHttpRequest as mapHttpRequest, pinoStdSerializers_mapHttpResponse as mapHttpResponse, pinoStdSerializers_req as req, pinoStdSerializers_res as res, pinoStdSerializers_wrapErrorSerializer as wrapErrorSerializer, pinoStdSerializers_wrapRequestSerializer as wrapRequestSerializer, pinoStdSerializers_wrapResponseSerializer as wrapResponseSerializer };
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// Type definitions for sonic-boom 0.7
|
|
176
|
-
// Definitions by: Alex Ferrando <https://github.com/alferpal>
|
|
177
|
-
// Igor Savin <https://github.com/kibertoad>
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
type SonicBoomOpts = {
|
|
181
|
-
fd?: number | string | symbol
|
|
182
|
-
dest?: string | number
|
|
183
|
-
maxLength?: number
|
|
184
|
-
minLength?: number
|
|
185
|
-
maxWrite?: number
|
|
186
|
-
periodicFlush?: number
|
|
187
|
-
sync?: boolean
|
|
188
|
-
fsync?: boolean
|
|
189
|
-
append?: boolean
|
|
190
|
-
mode?: string | number
|
|
191
|
-
mkdir?: boolean
|
|
192
|
-
contentMode?: 'buffer' | 'utf8'
|
|
193
|
-
retryEAGAIN?: (err: Error, writeBufferLen: number, remainingBufferLen: number) => boolean
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
declare class SonicBoom extends EventEmitter {
|
|
197
|
-
/**
|
|
198
|
-
* @param [fileDescriptor] File path or numerical file descriptor
|
|
199
|
-
* relative protocol is enabled. Default: process.stdout
|
|
200
|
-
* @returns a new sonic-boom instance
|
|
201
|
-
*/
|
|
202
|
-
constructor(opts: SonicBoomOpts)
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Writes the string to the file. It will return false to signal the producer to slow down.
|
|
206
|
-
*/
|
|
207
|
-
write(string: string): boolean;
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Writes the current buffer to the file if a write was not in progress.
|
|
211
|
-
* Do nothing if minLength is zero or if it is already writing.
|
|
212
|
-
*/
|
|
213
|
-
flush(cb?: (err?: Error) => unknown): void;
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Reopen the file in place, useful for log rotation.
|
|
217
|
-
*/
|
|
218
|
-
reopen(fileDescriptor?: string | number): void;
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Flushes the buffered data synchronously. This is a costly operation.
|
|
222
|
-
*/
|
|
223
|
-
flushSync(): void;
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Closes the stream, the data will be flushed down asynchronously
|
|
227
|
-
*/
|
|
228
|
-
end(): void;
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Closes the stream immediately, the data is not flushed.
|
|
232
|
-
*/
|
|
233
|
-
destroy(): void;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// Project: https://github.com/pinojs/pino.git, http://getpino.io
|
|
237
|
-
// Definitions by: Peter Snider <https://github.com/psnider>
|
|
238
|
-
// BendingBender <https://github.com/BendingBender>
|
|
239
|
-
// Christian Rackerseder <https://github.com/screendriver>
|
|
240
|
-
// GP <https://github.com/paambaati>
|
|
241
|
-
// Alex Ferrando <https://github.com/alferpal>
|
|
242
|
-
// Oleksandr Sidko <https://github.com/mortiy>
|
|
243
|
-
// Harris Lummis <https://github.com/lummish>
|
|
244
|
-
// Raoul Jaeckel <https://github.com/raoulus>
|
|
245
|
-
// Cory Donkin <https://github.com/Cooryd>
|
|
246
|
-
// Adam Vigneaux <https://github.com/AdamVig>
|
|
247
|
-
// Austin Beer <https://github.com/austin-beer>
|
|
248
|
-
// Michel Nemnom <https://github.com/Pegase745>
|
|
249
|
-
// Igor Savin <https://github.com/kibertoad>
|
|
250
|
-
// James Bromwell <https://github.com/thw0rted>
|
|
251
|
-
// TypeScript Version: 4.4
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
//// Non-exported types and interfaces
|
|
258
|
-
|
|
259
|
-
// ToDo https://github.com/pinojs/thread-stream/issues/24
|
|
260
|
-
type ThreadStream = any
|
|
261
|
-
|
|
262
|
-
type TimeFn = () => string;
|
|
263
|
-
type MixinFn<CustomLevels extends string = never> = (mergeObject: object, level: number, logger:pino.Logger<CustomLevels>) => object;
|
|
264
|
-
type MixinMergeStrategyFn = (mergeObject: object, mixinObject: object) => object;
|
|
265
|
-
|
|
266
|
-
type CustomLevelLogger<CustomLevels extends string, UseOnlyCustomLevels extends boolean = boolean> = {
|
|
267
|
-
/**
|
|
268
|
-
* Define additional logging levels.
|
|
269
|
-
*/
|
|
270
|
-
customLevels: { [level in CustomLevels]: number };
|
|
271
|
-
/**
|
|
272
|
-
* Use only defined `customLevels` and omit Pino's levels.
|
|
273
|
-
*/
|
|
274
|
-
useOnlyCustomLevels: UseOnlyCustomLevels;
|
|
275
|
-
} & {
|
|
276
|
-
// This will override default log methods
|
|
277
|
-
[K in Exclude<pino.Level, CustomLevels>]: UseOnlyCustomLevels extends true ? never : pino.LogFn;
|
|
278
|
-
} & {
|
|
279
|
-
[level in CustomLevels]: pino.LogFn;
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* A synchronous callback that will run on each creation of a new child.
|
|
284
|
-
* @param child: The newly created child logger instance.
|
|
285
|
-
*/
|
|
286
|
-
type OnChildCallback<CustomLevels extends string = never> = (child: pino.Logger<CustomLevels>) => void
|
|
287
|
-
|
|
288
|
-
interface redactOptions {
|
|
289
|
-
paths: string[];
|
|
290
|
-
censor?: string | ((value: any, path: string[]) => any);
|
|
291
|
-
remove?: boolean;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
interface LoggerExtras<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean> extends EventEmitter {
|
|
295
|
-
/**
|
|
296
|
-
* Exposes the Pino package version. Also available on the exported pino function.
|
|
297
|
-
*/
|
|
298
|
-
readonly version: string;
|
|
299
|
-
|
|
300
|
-
levels: pino.LevelMapping;
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Outputs the level as a string instead of integer.
|
|
304
|
-
*/
|
|
305
|
-
useLevelLabels: boolean;
|
|
306
|
-
/**
|
|
307
|
-
* Returns the integer value for the logger instance's logging level.
|
|
308
|
-
*/
|
|
309
|
-
levelVal: number;
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Creates a child logger, setting all key-value pairs in `bindings` as properties in the log lines. All serializers will be applied to the given pair.
|
|
313
|
-
* Child loggers use the same output stream as the parent and inherit the current log level of the parent at the time they are spawned.
|
|
314
|
-
* From v2.x.x the log level of a child is mutable (whereas in v1.x.x it was immutable), and can be set independently of the parent.
|
|
315
|
-
* If a `level` property is present in the object passed to `child` it will override the child logger level.
|
|
316
|
-
*
|
|
317
|
-
* @param bindings: an object of key-value pairs to include in log lines as properties.
|
|
318
|
-
* @param options: an options object that will override child logger inherited options.
|
|
319
|
-
* @returns a child logger instance.
|
|
320
|
-
*/
|
|
321
|
-
child<ChildCustomLevels extends string = never>(bindings: pino.Bindings, options?: ChildLoggerOptions<ChildCustomLevels>): pino.Logger<CustomLevels | ChildCustomLevels>;
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* This can be used to modify the callback function on creation of a new child.
|
|
325
|
-
*/
|
|
326
|
-
onChild: OnChildCallback<CustomLevels>;
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* Registers a listener function that is triggered when the level is changed.
|
|
330
|
-
* Note: When browserified, this functionality will only be available if the `events` module has been required elsewhere
|
|
331
|
-
* (e.g. if you're using streams in the browser). This allows for a trade-off between bundle size and functionality.
|
|
332
|
-
*
|
|
333
|
-
* @param event: only ever fires the `'level-change'` event
|
|
334
|
-
* @param listener: The listener is passed four arguments: `levelLabel`, `levelValue`, `previousLevelLabel`, `previousLevelValue`.
|
|
335
|
-
*/
|
|
336
|
-
on(event: "level-change", listener: pino.LevelChangeEventListener<CustomLevels, UseOnlyCustomLevels>): this;
|
|
337
|
-
addListener(event: "level-change", listener: pino.LevelChangeEventListener<CustomLevels, UseOnlyCustomLevels>): this;
|
|
338
|
-
once(event: "level-change", listener: pino.LevelChangeEventListener<CustomLevels, UseOnlyCustomLevels>): this;
|
|
339
|
-
prependListener(event: "level-change", listener: pino.LevelChangeEventListener<CustomLevels, UseOnlyCustomLevels>): this;
|
|
340
|
-
prependOnceListener(event: "level-change", listener: pino.LevelChangeEventListener<CustomLevels, UseOnlyCustomLevels>): this;
|
|
341
|
-
removeListener(event: "level-change", listener: pino.LevelChangeEventListener<CustomLevels, UseOnlyCustomLevels>): this;
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* A utility method for determining if a given log level will write to the destination.
|
|
345
|
-
*/
|
|
346
|
-
isLevelEnabled(level: pino.LevelWithSilentOrString): boolean;
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Returns an object containing all the current bindings, cloned from the ones passed in via logger.child().
|
|
350
|
-
*/
|
|
351
|
-
bindings(): pino.Bindings;
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Adds to the bindings of this logger instance.
|
|
355
|
-
* Note: Does not overwrite bindings. Can potentially result in duplicate keys in log lines.
|
|
356
|
-
*
|
|
357
|
-
* @param bindings: an object of key-value pairs to include in log lines as properties.
|
|
358
|
-
*/
|
|
359
|
-
setBindings(bindings: pino.Bindings): void;
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* Flushes the content of the buffer when using pino.destination({ sync: false }).
|
|
363
|
-
* call the callback when finished
|
|
364
|
-
*/
|
|
365
|
-
flush(cb?: (err?: Error) => void): void;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
declare namespace pino {
|
|
370
|
-
//// Exported types and interfaces
|
|
371
|
-
|
|
372
|
-
interface BaseLogger {
|
|
373
|
-
/**
|
|
374
|
-
* Set this property to the desired logging level. In order of priority, available levels are:
|
|
375
|
-
*
|
|
376
|
-
* - 'fatal'
|
|
377
|
-
* - 'error'
|
|
378
|
-
* - 'warn'
|
|
379
|
-
* - 'info'
|
|
380
|
-
* - 'debug'
|
|
381
|
-
* - 'trace'
|
|
382
|
-
*
|
|
383
|
-
* The logging level is a __minimum__ level. For instance if `logger.level` is `'info'` then all `'fatal'`, `'error'`, `'warn'`,
|
|
384
|
-
* and `'info'` logs will be enabled.
|
|
385
|
-
*
|
|
386
|
-
* You can pass `'silent'` to disable logging.
|
|
387
|
-
*/
|
|
388
|
-
level: pino.LevelWithSilentOrString;
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* Log at `'fatal'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
|
|
392
|
-
* If more args follows `msg`, these will be used to format `msg` using `util.format`.
|
|
393
|
-
*
|
|
394
|
-
* @typeParam T: the interface of the object being serialized. Default is object.
|
|
395
|
-
* @param obj: object to be serialized
|
|
396
|
-
* @param msg: the log message to write
|
|
397
|
-
* @param ...args: format string values when `msg` is a format string
|
|
398
|
-
*/
|
|
399
|
-
fatal: pino.LogFn;
|
|
400
|
-
/**
|
|
401
|
-
* Log at `'error'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
|
|
402
|
-
* If more args follows `msg`, these will be used to format `msg` using `util.format`.
|
|
403
|
-
*
|
|
404
|
-
* @typeParam T: the interface of the object being serialized. Default is object.
|
|
405
|
-
* @param obj: object to be serialized
|
|
406
|
-
* @param msg: the log message to write
|
|
407
|
-
* @param ...args: format string values when `msg` is a format string
|
|
408
|
-
*/
|
|
409
|
-
error: pino.LogFn;
|
|
410
|
-
/**
|
|
411
|
-
* Log at `'warn'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
|
|
412
|
-
* If more args follows `msg`, these will be used to format `msg` using `util.format`.
|
|
413
|
-
*
|
|
414
|
-
* @typeParam T: the interface of the object being serialized. Default is object.
|
|
415
|
-
* @param obj: object to be serialized
|
|
416
|
-
* @param msg: the log message to write
|
|
417
|
-
* @param ...args: format string values when `msg` is a format string
|
|
418
|
-
*/
|
|
419
|
-
warn: pino.LogFn;
|
|
420
|
-
/**
|
|
421
|
-
* Log at `'info'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
|
|
422
|
-
* If more args follows `msg`, these will be used to format `msg` using `util.format`.
|
|
423
|
-
*
|
|
424
|
-
* @typeParam T: the interface of the object being serialized. Default is object.
|
|
425
|
-
* @param obj: object to be serialized
|
|
426
|
-
* @param msg: the log message to write
|
|
427
|
-
* @param ...args: format string values when `msg` is a format string
|
|
428
|
-
*/
|
|
429
|
-
info: pino.LogFn;
|
|
430
|
-
/**
|
|
431
|
-
* Log at `'debug'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
|
|
432
|
-
* If more args follows `msg`, these will be used to format `msg` using `util.format`.
|
|
433
|
-
*
|
|
434
|
-
* @typeParam T: the interface of the object being serialized. Default is object.
|
|
435
|
-
* @param obj: object to be serialized
|
|
436
|
-
* @param msg: the log message to write
|
|
437
|
-
* @param ...args: format string values when `msg` is a format string
|
|
438
|
-
*/
|
|
439
|
-
debug: pino.LogFn;
|
|
440
|
-
/**
|
|
441
|
-
* Log at `'trace'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
|
|
442
|
-
* If more args follows `msg`, these will be used to format `msg` using `util.format`.
|
|
443
|
-
*
|
|
444
|
-
* @typeParam T: the interface of the object being serialized. Default is object.
|
|
445
|
-
* @param obj: object to be serialized
|
|
446
|
-
* @param msg: the log message to write
|
|
447
|
-
* @param ...args: format string values when `msg` is a format string
|
|
448
|
-
*/
|
|
449
|
-
trace: pino.LogFn;
|
|
450
|
-
/**
|
|
451
|
-
* Noop function.
|
|
452
|
-
*/
|
|
453
|
-
silent: pino.LogFn;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
type Bindings = Record<string, any>;
|
|
457
|
-
|
|
458
|
-
type Level = "fatal" | "error" | "warn" | "info" | "debug" | "trace";
|
|
459
|
-
type LevelOrString = Level | (string & {});
|
|
460
|
-
type LevelWithSilent = pino.Level | "silent";
|
|
461
|
-
type LevelWithSilentOrString = LevelWithSilent | (string & {});
|
|
462
|
-
|
|
463
|
-
type SerializerFn = (value: any) => any;
|
|
464
|
-
type WriteFn = (o: object) => void;
|
|
465
|
-
|
|
466
|
-
type LevelChangeEventListener<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean> = (
|
|
467
|
-
lvl: LevelWithSilentOrString,
|
|
468
|
-
val: number,
|
|
469
|
-
prevLvl: LevelWithSilentOrString,
|
|
470
|
-
prevVal: number,
|
|
471
|
-
logger: Logger<CustomLevels, UseOnlyCustomLevels>
|
|
472
|
-
) => void;
|
|
473
|
-
|
|
474
|
-
type LogDescriptor = Record<string, any>;
|
|
475
|
-
|
|
476
|
-
type Logger<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean> = BaseLogger & LoggerExtras<CustomLevels> & CustomLevelLogger<CustomLevels, UseOnlyCustomLevels>;
|
|
477
|
-
|
|
478
|
-
type SerializedError = SerializedError;
|
|
479
|
-
type SerializedResponse = SerializedResponse;
|
|
480
|
-
type SerializedRequest = SerializedRequest;
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
interface TransportTargetOptions<TransportOptions = Record<string, any>> {
|
|
484
|
-
target: string
|
|
485
|
-
options?: TransportOptions
|
|
486
|
-
level?: LevelWithSilentOrString
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
interface TransportBaseOptions<TransportOptions = Record<string, any>> {
|
|
490
|
-
options?: TransportOptions
|
|
491
|
-
worker?: WorkerOptions & { autoEnd?: boolean}
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
interface TransportSingleOptions<TransportOptions = Record<string, any>> extends TransportBaseOptions<TransportOptions>{
|
|
495
|
-
target: string
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
interface TransportPipelineOptions<TransportOptions = Record<string, any>> extends TransportBaseOptions<TransportOptions>{
|
|
499
|
-
pipeline: TransportSingleOptions<TransportOptions>[]
|
|
500
|
-
level?: LevelWithSilentOrString
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
interface TransportMultiOptions<TransportOptions = Record<string, any>> extends TransportBaseOptions<TransportOptions>{
|
|
504
|
-
targets: readonly (TransportTargetOptions<TransportOptions>|TransportPipelineOptions<TransportOptions>)[],
|
|
505
|
-
levels?: Record<string, number>
|
|
506
|
-
dedupe?: boolean
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
interface MultiStreamOptions {
|
|
510
|
-
levels?: Record<string, number>
|
|
511
|
-
dedupe?: boolean
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
interface DestinationStream {
|
|
515
|
-
write(msg: string): void;
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
interface DestinationStreamHasMetadata {
|
|
519
|
-
[symbols.needsMetadataGsym]: true;
|
|
520
|
-
lastLevel: number;
|
|
521
|
-
lastTime: string;
|
|
522
|
-
lastMsg: string;
|
|
523
|
-
lastObj: object;
|
|
524
|
-
lastLogger: pino.Logger;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
type DestinationStreamWithMetadata = DestinationStream & ({ [symbols.needsMetadataGsym]?: false } | DestinationStreamHasMetadata);
|
|
528
|
-
|
|
529
|
-
interface StreamEntry<TLevel = Level> {
|
|
530
|
-
stream: DestinationStream
|
|
531
|
-
level?: TLevel
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
interface MultiStreamRes<TOriginLevel = Level> {
|
|
535
|
-
write: (data: any) => void,
|
|
536
|
-
add: <TLevel = Level>(dest: StreamEntry<TLevel> | DestinationStream) => MultiStreamRes<TOriginLevel & TLevel>,
|
|
537
|
-
flushSync: () => void,
|
|
538
|
-
minLevel: number,
|
|
539
|
-
streams: StreamEntry<TOriginLevel>[],
|
|
540
|
-
clone<TLevel = Level>(level: TLevel): MultiStreamRes<TLevel>,
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
interface LevelMapping {
|
|
544
|
-
/**
|
|
545
|
-
* Returns the mappings of level names to their respective internal number representation.
|
|
546
|
-
*/
|
|
547
|
-
values: { [level: string]: number };
|
|
548
|
-
/**
|
|
549
|
-
* Returns the mappings of level internal level numbers to their string representations.
|
|
550
|
-
*/
|
|
551
|
-
labels: { [level: number]: string };
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
interface LogFn {
|
|
555
|
-
// TODO: why is this different from `obj: object` or `obj: any`?
|
|
556
|
-
/* tslint:disable:no-unnecessary-generics */
|
|
557
|
-
<T extends object>(obj: T, msg?: string, ...args: any[]): void;
|
|
558
|
-
(obj: unknown, msg?: string, ...args: any[]): void;
|
|
559
|
-
(msg: string, ...args: any[]): void;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
interface LoggerOptions<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean> {
|
|
563
|
-
transport?: TransportSingleOptions | TransportMultiOptions | TransportPipelineOptions
|
|
564
|
-
/**
|
|
565
|
-
* Avoid error causes by circular references in the object tree. Default: `true`.
|
|
566
|
-
*/
|
|
567
|
-
safe?: boolean;
|
|
568
|
-
/**
|
|
569
|
-
* The name of the logger. Default: `undefined`.
|
|
570
|
-
*/
|
|
571
|
-
name?: string;
|
|
572
|
-
/**
|
|
573
|
-
* an object containing functions for custom serialization of objects.
|
|
574
|
-
* These functions should return an JSONifiable object and they should never throw. When logging an object,
|
|
575
|
-
* each top-level property matching the exact key of a serializer will be serialized using the defined serializer.
|
|
576
|
-
*/
|
|
577
|
-
serializers?: { [key: string]: SerializerFn };
|
|
578
|
-
/**
|
|
579
|
-
* Enables or disables the inclusion of a timestamp in the log message. If a function is supplied, it must
|
|
580
|
-
* synchronously return a JSON string representation of the time. If set to `false`, no timestamp will be included in the output.
|
|
581
|
-
* See stdTimeFunctions for a set of available functions for passing in as a value for this option.
|
|
582
|
-
* Caution: any sort of formatted time will significantly slow down Pino's performance.
|
|
583
|
-
*/
|
|
584
|
-
timestamp?: TimeFn | boolean;
|
|
585
|
-
/**
|
|
586
|
-
* One of the supported levels or `silent` to disable logging. Any other value defines a custom level and
|
|
587
|
-
* requires supplying a level value via `levelVal`. Default: 'info'.
|
|
588
|
-
*/
|
|
589
|
-
level?: LevelWithSilentOrString;
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* Use this option to define additional logging levels.
|
|
593
|
-
* The keys of the object correspond the namespace of the log level, and the values should be the numerical value of the level.
|
|
594
|
-
*/
|
|
595
|
-
customLevels?: { [level in CustomLevels]: number };
|
|
596
|
-
|
|
597
|
-
/**
|
|
598
|
-
* Use this option to only use defined `customLevels` and omit Pino's levels.
|
|
599
|
-
* Logger's default `level` must be changed to a value in `customLevels` in order to use `useOnlyCustomLevels`
|
|
600
|
-
* Warning: this option may not be supported by downstream transports.
|
|
601
|
-
*/
|
|
602
|
-
useOnlyCustomLevels?: UseOnlyCustomLevels;
|
|
603
|
-
|
|
604
|
-
/**
|
|
605
|
-
* Use this option to define custom comparison of log levels.
|
|
606
|
-
* Useful to compare custom log levels or non-standard level values.
|
|
607
|
-
* Default: "ASC"
|
|
608
|
-
*/
|
|
609
|
-
levelComparison?: "ASC" | "DESC" | ((current: number, expected: number) => boolean);
|
|
610
|
-
|
|
611
|
-
/**
|
|
612
|
-
* If provided, the `mixin` function is called each time one of the active logging methods
|
|
613
|
-
* is called. The function must synchronously return an object. The properties of the
|
|
614
|
-
* returned object will be added to the logged JSON.
|
|
615
|
-
*/
|
|
616
|
-
mixin?: MixinFn<CustomLevels>;
|
|
617
|
-
|
|
618
|
-
/**
|
|
619
|
-
* If provided, the `mixinMergeStrategy` function is called each time one of the active
|
|
620
|
-
* logging methods is called. The first parameter is the value `mergeObject` or an empty object,
|
|
621
|
-
* the second parameter is the value resulting from `mixin()` or an empty object.
|
|
622
|
-
* The function must synchronously return an object.
|
|
623
|
-
*/
|
|
624
|
-
mixinMergeStrategy?: MixinMergeStrategyFn
|
|
625
|
-
|
|
626
|
-
/**
|
|
627
|
-
* As an array, the redact option specifies paths that should have their values redacted from any log output.
|
|
628
|
-
*
|
|
629
|
-
* Each path must be a string using a syntax which corresponds to JavaScript dot and bracket notation.
|
|
630
|
-
*
|
|
631
|
-
* If an object is supplied, three options can be specified:
|
|
632
|
-
*
|
|
633
|
-
* paths (String[]): Required. An array of paths
|
|
634
|
-
* censor (String): Optional. A value to overwrite key which are to be redacted. Default: '[Redacted]'
|
|
635
|
-
* remove (Boolean): Optional. Instead of censoring the value, remove both the key and the value. Default: false
|
|
636
|
-
*/
|
|
637
|
-
redact?: string[] | redactOptions;
|
|
638
|
-
|
|
639
|
-
/**
|
|
640
|
-
* When defining a custom log level via level, set to an integer value to define the new level. Default: `undefined`.
|
|
641
|
-
*/
|
|
642
|
-
levelVal?: number;
|
|
643
|
-
/**
|
|
644
|
-
* The string key for the 'message' in the JSON object. Default: "msg".
|
|
645
|
-
*/
|
|
646
|
-
messageKey?: string;
|
|
647
|
-
/**
|
|
648
|
-
* The string key for the 'error' in the JSON object. Default: "err".
|
|
649
|
-
*/
|
|
650
|
-
errorKey?: string;
|
|
651
|
-
/**
|
|
652
|
-
* The string key to place any logged object under.
|
|
653
|
-
*/
|
|
654
|
-
nestedKey?: string;
|
|
655
|
-
/**
|
|
656
|
-
* Enables logging. Default: `true`.
|
|
657
|
-
*/
|
|
658
|
-
enabled?: boolean;
|
|
659
|
-
/**
|
|
660
|
-
* Browser only, see http://getpino.io/#/docs/browser.
|
|
661
|
-
*/
|
|
662
|
-
browser?: {
|
|
663
|
-
/**
|
|
664
|
-
* The `asObject` option will create a pino-like log object instead of passing all arguments to a console
|
|
665
|
-
* method. When `write` is set, `asObject` will always be true.
|
|
666
|
-
*
|
|
667
|
-
* @example
|
|
668
|
-
* pino.info('hi') // creates and logs {msg: 'hi', level: 30, time: <ts>}
|
|
669
|
-
*/
|
|
670
|
-
asObject?: boolean;
|
|
671
|
-
formatters?: {
|
|
672
|
-
/**
|
|
673
|
-
* Changes the shape of the log level.
|
|
674
|
-
* The default shape is { level: number }.
|
|
675
|
-
*/
|
|
676
|
-
level?: (label: string, number: number) => object;
|
|
677
|
-
/**
|
|
678
|
-
* Changes the shape of the log object.
|
|
679
|
-
*/
|
|
680
|
-
log?: (object: Record<string, unknown>) => Record<string, unknown>;
|
|
681
|
-
}
|
|
682
|
-
/**
|
|
683
|
-
* Instead of passing log messages to `console.log` they can be passed to a supplied function. If `write` is
|
|
684
|
-
* set to a single function, all logging objects are passed to this function. If `write` is an object, it
|
|
685
|
-
* can have methods that correspond to the levels. When a message is logged at a given level, the
|
|
686
|
-
* corresponding method is called. If a method isn't present, the logging falls back to using the `console`.
|
|
687
|
-
*
|
|
688
|
-
* @example
|
|
689
|
-
* const pino = require('pino')({
|
|
690
|
-
* browser: {
|
|
691
|
-
* write: (o) => {
|
|
692
|
-
* // do something with o
|
|
693
|
-
* }
|
|
694
|
-
* }
|
|
695
|
-
* })
|
|
696
|
-
*
|
|
697
|
-
* @example
|
|
698
|
-
* const pino = require('pino')({
|
|
699
|
-
* browser: {
|
|
700
|
-
* write: {
|
|
701
|
-
* info: function (o) {
|
|
702
|
-
* //process info log object
|
|
703
|
-
* },
|
|
704
|
-
* error: function (o) {
|
|
705
|
-
* //process error log object
|
|
706
|
-
* }
|
|
707
|
-
* }
|
|
708
|
-
* }
|
|
709
|
-
* })
|
|
710
|
-
*/
|
|
711
|
-
write?:
|
|
712
|
-
| WriteFn
|
|
713
|
-
| ({
|
|
714
|
-
fatal?: WriteFn;
|
|
715
|
-
error?: WriteFn;
|
|
716
|
-
warn?: WriteFn;
|
|
717
|
-
info?: WriteFn;
|
|
718
|
-
debug?: WriteFn;
|
|
719
|
-
trace?: WriteFn;
|
|
720
|
-
} & { [logLevel: string]: WriteFn });
|
|
721
|
-
|
|
722
|
-
/**
|
|
723
|
-
* The serializers provided to `pino` are ignored by default in the browser, including the standard
|
|
724
|
-
* serializers provided with Pino. Since the default destination for log messages is the console, values
|
|
725
|
-
* such as `Error` objects are enhanced for inspection, which they otherwise wouldn't be if the Error
|
|
726
|
-
* serializer was enabled. We can turn all serializers on or we can selectively enable them via an array.
|
|
727
|
-
*
|
|
728
|
-
* When `serialize` is `true` the standard error serializer is also enabled (see
|
|
729
|
-
* {@link https://github.com/pinojs/pino/blob/master/docs/api.md#pino-stdserializers}). This is a global
|
|
730
|
-
* serializer which will apply to any `Error` objects passed to the logger methods.
|
|
731
|
-
*
|
|
732
|
-
* If `serialize` is an array the standard error serializer is also automatically enabled, it can be
|
|
733
|
-
* explicitly disabled by including a string in the serialize array: `!stdSerializers.err` (see example).
|
|
734
|
-
*
|
|
735
|
-
* The `serialize` array also applies to any child logger serializers (see
|
|
736
|
-
* {@link https://github.com/pinojs/pino/blob/master/docs/api.md#bindingsserializers-object} for how to
|
|
737
|
-
* set child-bound serializers).
|
|
738
|
-
*
|
|
739
|
-
* Unlike server pino the serializers apply to every object passed to the logger method, if the `asObject`
|
|
740
|
-
* option is `true`, this results in the serializers applying to the first object (as in server pino).
|
|
741
|
-
*
|
|
742
|
-
* For more info on serializers see
|
|
743
|
-
* {@link https://github.com/pinojs/pino/blob/master/docs/api.md#serializers-object}.
|
|
744
|
-
*
|
|
745
|
-
* @example
|
|
746
|
-
* const pino = require('pino')({
|
|
747
|
-
* browser: {
|
|
748
|
-
* serialize: true
|
|
749
|
-
* }
|
|
750
|
-
* })
|
|
751
|
-
*
|
|
752
|
-
* @example
|
|
753
|
-
* const pino = require('pino')({
|
|
754
|
-
* serializers: {
|
|
755
|
-
* custom: myCustomSerializer,
|
|
756
|
-
* another: anotherSerializer
|
|
757
|
-
* },
|
|
758
|
-
* browser: {
|
|
759
|
-
* serialize: ['custom']
|
|
760
|
-
* }
|
|
761
|
-
* })
|
|
762
|
-
* // following will apply myCustomSerializer to the custom property,
|
|
763
|
-
* // but will not apply anotherSerializer to another key
|
|
764
|
-
* pino.info({custom: 'a', another: 'b'})
|
|
765
|
-
*
|
|
766
|
-
* @example
|
|
767
|
-
* const pino = require('pino')({
|
|
768
|
-
* serializers: {
|
|
769
|
-
* custom: myCustomSerializer,
|
|
770
|
-
* another: anotherSerializer
|
|
771
|
-
* },
|
|
772
|
-
* browser: {
|
|
773
|
-
* serialize: ['!stdSerializers.err', 'custom'] //will not serialize Errors, will serialize `custom` keys
|
|
774
|
-
* }
|
|
775
|
-
* })
|
|
776
|
-
*/
|
|
777
|
-
serialize?: boolean | string[];
|
|
778
|
-
|
|
779
|
-
/**
|
|
780
|
-
* Options for transmission of logs.
|
|
781
|
-
*
|
|
782
|
-
* @example
|
|
783
|
-
* const pino = require('pino')({
|
|
784
|
-
* browser: {
|
|
785
|
-
* transmit: {
|
|
786
|
-
* level: 'warn',
|
|
787
|
-
* send: function (level, logEvent) {
|
|
788
|
-
* if (level === 'warn') {
|
|
789
|
-
* // maybe send the logEvent to a separate endpoint
|
|
790
|
-
* // or maybe analyse the messages further before sending
|
|
791
|
-
* }
|
|
792
|
-
* // we could also use the `logEvent.level.value` property to determine
|
|
793
|
-
* // numerical value
|
|
794
|
-
* if (logEvent.level.value >= 50) { // covers error and fatal
|
|
795
|
-
*
|
|
796
|
-
* // send the logEvent somewhere
|
|
797
|
-
* }
|
|
798
|
-
* }
|
|
799
|
-
* }
|
|
800
|
-
* }
|
|
801
|
-
* })
|
|
802
|
-
*/
|
|
803
|
-
transmit?: {
|
|
804
|
-
/**
|
|
805
|
-
* Specifies the minimum level (inclusive) of when the `send` function should be called, if not supplied
|
|
806
|
-
* the `send` function will be called based on the main logging `level` (set via `options.level`,
|
|
807
|
-
* defaulting to `info`).
|
|
808
|
-
*/
|
|
809
|
-
level?: LevelOrString;
|
|
810
|
-
/**
|
|
811
|
-
* Remotely record log messages.
|
|
812
|
-
*
|
|
813
|
-
* @description Called after writing the log message.
|
|
814
|
-
*/
|
|
815
|
-
send: (level: Level, logEvent: LogEvent) => void;
|
|
816
|
-
};
|
|
817
|
-
/**
|
|
818
|
-
* The disabled option will disable logging in browser if set to true, by default it is set to false.
|
|
819
|
-
*
|
|
820
|
-
* @example
|
|
821
|
-
* const pino = require('pino')({browser: {disabled: true}})
|
|
822
|
-
*/
|
|
823
|
-
disabled?: boolean;
|
|
824
|
-
};
|
|
825
|
-
/**
|
|
826
|
-
* key-value object added as child logger to each log line. If set to null the base child logger is not added
|
|
827
|
-
*/
|
|
828
|
-
base?: { [key: string]: any } | null;
|
|
829
|
-
|
|
830
|
-
/**
|
|
831
|
-
* An object containing functions for formatting the shape of the log lines.
|
|
832
|
-
* These functions should return a JSONifiable object and should never throw.
|
|
833
|
-
* These functions allow for full customization of the resulting log lines.
|
|
834
|
-
* For example, they can be used to change the level key name or to enrich the default metadata.
|
|
835
|
-
*/
|
|
836
|
-
formatters?: {
|
|
837
|
-
/**
|
|
838
|
-
* Changes the shape of the log level.
|
|
839
|
-
* The default shape is { level: number }.
|
|
840
|
-
* The function takes two arguments, the label of the level (e.g. 'info') and the numeric value (e.g. 30).
|
|
841
|
-
*/
|
|
842
|
-
level?: (label: string, number: number) => object;
|
|
843
|
-
/**
|
|
844
|
-
* Changes the shape of the bindings.
|
|
845
|
-
* The default shape is { pid, hostname }.
|
|
846
|
-
* The function takes a single argument, the bindings object.
|
|
847
|
-
* It will be called every time a child logger is created.
|
|
848
|
-
*/
|
|
849
|
-
bindings?: (bindings: Bindings) => object;
|
|
850
|
-
/**
|
|
851
|
-
* Changes the shape of the log object.
|
|
852
|
-
* This function will be called every time one of the log methods (such as .info) is called.
|
|
853
|
-
* All arguments passed to the log method, except the message, will be pass to this function.
|
|
854
|
-
* By default it does not change the shape of the log object.
|
|
855
|
-
*/
|
|
856
|
-
log?: (object: Record<string, unknown>) => Record<string, unknown>;
|
|
857
|
-
};
|
|
858
|
-
|
|
859
|
-
/**
|
|
860
|
-
* A string that would be prefixed to every message (and child message)
|
|
861
|
-
*/
|
|
862
|
-
msgPrefix?: string
|
|
863
|
-
|
|
864
|
-
/**
|
|
865
|
-
* An object mapping to hook functions. Hook functions allow for customizing internal logger operations.
|
|
866
|
-
* Hook functions must be synchronous functions.
|
|
867
|
-
*/
|
|
868
|
-
hooks?: {
|
|
869
|
-
/**
|
|
870
|
-
* Allows for manipulating the parameters passed to logger methods. The signature for this hook is
|
|
871
|
-
* logMethod (args, method, level) {}, where args is an array of the arguments that were passed to the
|
|
872
|
-
* log method and method is the log method itself, and level is the log level. This hook must invoke the method function by
|
|
873
|
-
* using apply, like so: method.apply(this, newArgumentsArray).
|
|
874
|
-
*/
|
|
875
|
-
logMethod?: (this: Logger, args: Parameters<LogFn>, method: LogFn, level: number) => void;
|
|
876
|
-
|
|
877
|
-
/**
|
|
878
|
-
* Allows for manipulating the stringified JSON log output just before writing to various transports.
|
|
879
|
-
* This function must return a string and must be valid JSON.
|
|
880
|
-
*/
|
|
881
|
-
streamWrite?: (s: string) => string;
|
|
882
|
-
};
|
|
883
|
-
|
|
884
|
-
/**
|
|
885
|
-
* Stringification limit at a specific nesting depth when logging circular object. Default: `5`.
|
|
886
|
-
*/
|
|
887
|
-
depthLimit?: number
|
|
888
|
-
|
|
889
|
-
/**
|
|
890
|
-
* Stringification limit of properties/elements when logging a specific object/array with circular references. Default: `100`.
|
|
891
|
-
*/
|
|
892
|
-
edgeLimit?: number
|
|
893
|
-
|
|
894
|
-
/**
|
|
895
|
-
* Optional child creation callback.
|
|
896
|
-
*/
|
|
897
|
-
onChild?: OnChildCallback<CustomLevels>;
|
|
898
|
-
|
|
899
|
-
/**
|
|
900
|
-
* logs newline delimited JSON with `\r\n` instead of `\n`. Default: `false`.
|
|
901
|
-
*/
|
|
902
|
-
crlf?: boolean;
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
interface ChildLoggerOptions<CustomLevels extends string = never> {
|
|
906
|
-
level?: LevelOrString;
|
|
907
|
-
serializers?: { [key: string]: SerializerFn };
|
|
908
|
-
customLevels?: { [level in CustomLevels]: number };
|
|
909
|
-
formatters?: {
|
|
910
|
-
level?: (label: string, number: number) => object;
|
|
911
|
-
bindings?: (bindings: Bindings) => object;
|
|
912
|
-
log?: (object: object) => object;
|
|
913
|
-
};
|
|
914
|
-
redact?: string[] | redactOptions;
|
|
915
|
-
msgPrefix?: string
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
/**
|
|
919
|
-
* A data structure representing a log message, it represents the arguments passed to a logger statement, the level
|
|
920
|
-
* at which they were logged and the hierarchy of child bindings.
|
|
921
|
-
*
|
|
922
|
-
* @description By default serializers are not applied to log output in the browser, but they will always be applied
|
|
923
|
-
* to `messages` and `bindings` in the `logEvent` object. This allows us to ensure a consistent format for all
|
|
924
|
-
* values between server and client.
|
|
925
|
-
*/
|
|
926
|
-
interface LogEvent {
|
|
927
|
-
/**
|
|
928
|
-
* Unix epoch timestamp in milliseconds, the time is taken from the moment the logger method is called.
|
|
929
|
-
*/
|
|
930
|
-
ts: number;
|
|
931
|
-
/**
|
|
932
|
-
* All arguments passed to logger method, (for instance `logger.info('a', 'b', 'c')` would result in `messages`
|
|
933
|
-
* array `['a', 'b', 'c']`).
|
|
934
|
-
*/
|
|
935
|
-
messages: any[];
|
|
936
|
-
/**
|
|
937
|
-
* Represents each child logger (if any), and the relevant bindings.
|
|
938
|
-
*
|
|
939
|
-
* @description For instance, given `logger.child({a: 1}).child({b: 2}).info({c: 3})`, the bindings array would
|
|
940
|
-
* hold `[{a: 1}, {b: 2}]` and the `messages` array would be `[{c: 3}]`. The `bindings` are ordered according to
|
|
941
|
-
* their position in the child logger hierarchy, with the lowest index being the top of the hierarchy.
|
|
942
|
-
*/
|
|
943
|
-
bindings: Bindings[];
|
|
944
|
-
/**
|
|
945
|
-
* Holds the `label` (for instance `info`), and the corresponding numerical `value` (for instance `30`).
|
|
946
|
-
* This could be important in cases where client side level values and labels differ from server side.
|
|
947
|
-
*/
|
|
948
|
-
level: {
|
|
949
|
-
label: string;
|
|
950
|
-
value: number;
|
|
951
|
-
};
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
//// Top level variable (const) exports
|
|
957
|
-
|
|
958
|
-
/**
|
|
959
|
-
* Provides functions for serializing objects common to many projects.
|
|
960
|
-
*/
|
|
961
|
-
export const stdSerializers: typeof pinoStdSerializers;
|
|
962
|
-
|
|
963
|
-
/**
|
|
964
|
-
* Holds the current log format version (as output in the v property of each log record).
|
|
965
|
-
*/
|
|
966
|
-
export const levels: LevelMapping;
|
|
967
|
-
export const symbols: {
|
|
968
|
-
readonly setLevelSym: unique symbol;
|
|
969
|
-
readonly getLevelSym: unique symbol;
|
|
970
|
-
readonly levelValSym: unique symbol;
|
|
971
|
-
readonly useLevelLabelsSym: unique symbol;
|
|
972
|
-
readonly mixinSym: unique symbol;
|
|
973
|
-
readonly lsCacheSym: unique symbol;
|
|
974
|
-
readonly chindingsSym: unique symbol;
|
|
975
|
-
readonly parsedChindingsSym: unique symbol;
|
|
976
|
-
readonly asJsonSym: unique symbol;
|
|
977
|
-
readonly writeSym: unique symbol;
|
|
978
|
-
readonly serializersSym: unique symbol;
|
|
979
|
-
readonly redactFmtSym: unique symbol;
|
|
980
|
-
readonly timeSym: unique symbol;
|
|
981
|
-
readonly timeSliceIndexSym: unique symbol;
|
|
982
|
-
readonly streamSym: unique symbol;
|
|
983
|
-
readonly stringifySym: unique symbol;
|
|
984
|
-
readonly stringifySafeSym: unique symbol;
|
|
985
|
-
readonly stringifiersSym: unique symbol;
|
|
986
|
-
readonly endSym: unique symbol;
|
|
987
|
-
readonly formatOptsSym: unique symbol;
|
|
988
|
-
readonly messageKeySym: unique symbol;
|
|
989
|
-
readonly errorKeySym: unique symbol;
|
|
990
|
-
readonly nestedKeySym: unique symbol;
|
|
991
|
-
readonly wildcardFirstSym: unique symbol;
|
|
992
|
-
readonly needsMetadataGsym: unique symbol;
|
|
993
|
-
readonly useOnlyCustomLevelsSym: unique symbol;
|
|
994
|
-
readonly formattersSym: unique symbol;
|
|
995
|
-
readonly hooksSym: unique symbol;
|
|
996
|
-
};
|
|
997
|
-
|
|
998
|
-
/**
|
|
999
|
-
* Exposes the Pino package version. Also available on the logger instance.
|
|
1000
|
-
*/
|
|
1001
|
-
export const version: string;
|
|
1002
|
-
|
|
1003
|
-
/**
|
|
1004
|
-
* Provides functions for generating the timestamp property in the log output. You can set the `timestamp` option during
|
|
1005
|
-
* initialization to one of these functions to adjust the output format. Alternatively, you can specify your own time function.
|
|
1006
|
-
* A time function must synchronously return a string that would be a valid component of a JSON string. For example,
|
|
1007
|
-
* the default function returns a string like `,"time":1493426328206`.
|
|
1008
|
-
*/
|
|
1009
|
-
export const stdTimeFunctions: {
|
|
1010
|
-
/**
|
|
1011
|
-
* The default time function for Pino. Returns a string like `,"time":1493426328206`.
|
|
1012
|
-
*/
|
|
1013
|
-
epochTime: TimeFn;
|
|
1014
|
-
/*
|
|
1015
|
-
* Returns the seconds since Unix epoch
|
|
1016
|
-
*/
|
|
1017
|
-
unixTime: TimeFn;
|
|
1018
|
-
/**
|
|
1019
|
-
* Returns an empty string. This function is used when the `timestamp` option is set to `false`.
|
|
1020
|
-
*/
|
|
1021
|
-
nullTime: TimeFn;
|
|
1022
|
-
/*
|
|
1023
|
-
* Returns ISO 8601-formatted time in UTC
|
|
1024
|
-
*/
|
|
1025
|
-
isoTime: TimeFn;
|
|
1026
|
-
};
|
|
1027
|
-
|
|
1028
|
-
//// Exported functions
|
|
1029
|
-
|
|
1030
|
-
/**
|
|
1031
|
-
* Create a Pino Destination instance: a stream-like object with significantly more throughput (over 30%) than a standard Node.js stream.
|
|
1032
|
-
* @param [dest]: The `destination` parameter, can be a file descriptor, a file path, or an object with `dest` property pointing to a fd or path.
|
|
1033
|
-
* An ordinary Node.js `stream` file descriptor can be passed as the destination (such as the result of `fs.createWriteStream`)
|
|
1034
|
-
* but for peak log writing performance, it is strongly recommended to use `pino.destination` to create the destination stream.
|
|
1035
|
-
* @returns A Sonic-Boom stream to be used as destination for the pino function
|
|
1036
|
-
*/
|
|
1037
|
-
export function destination(
|
|
1038
|
-
dest?: number | object | string | DestinationStream | NodeJS.WritableStream | SonicBoomOpts,
|
|
1039
|
-
): SonicBoom;
|
|
1040
|
-
|
|
1041
|
-
export function transport<TransportOptions = Record<string, any>>(
|
|
1042
|
-
options: TransportSingleOptions<TransportOptions> | TransportMultiOptions<TransportOptions> | TransportPipelineOptions<TransportOptions>
|
|
1043
|
-
): ThreadStream
|
|
1044
|
-
|
|
1045
|
-
export function multistream<TLevel = Level>(
|
|
1046
|
-
streamsArray: (DestinationStream | StreamEntry<TLevel>)[] | DestinationStream | StreamEntry<TLevel>,
|
|
1047
|
-
opts?: MultiStreamOptions
|
|
1048
|
-
): MultiStreamRes<TLevel>
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
//// Callable default export
|
|
1052
|
-
|
|
1053
|
-
/**
|
|
1054
|
-
* @param [optionsOrStream]: an options object or a writable stream where the logs will be written. It can also receive some log-line metadata, if the
|
|
1055
|
-
* relative protocol is enabled. Default: process.stdout
|
|
1056
|
-
* @returns a new logger instance.
|
|
1057
|
-
*/
|
|
1058
|
-
declare function pino<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean>(optionsOrStream?: LoggerOptions<CustomLevels, UseOnlyCustomLevels> | DestinationStream): Logger$1<CustomLevels, UseOnlyCustomLevels>;
|
|
1059
|
-
|
|
1060
|
-
/**
|
|
1061
|
-
* @param [options]: an options object
|
|
1062
|
-
* @param [stream]: a writable stream where the logs will be written. It can also receive some log-line metadata, if the
|
|
1063
|
-
* relative protocol is enabled. Default: process.stdout
|
|
1064
|
-
* @returns a new logger instance.
|
|
1065
|
-
*/
|
|
1066
|
-
declare function pino<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean>(options: LoggerOptions<CustomLevels, UseOnlyCustomLevels>, stream?: DestinationStream | undefined): Logger$1<CustomLevels, UseOnlyCustomLevels>;
|
|
1067
|
-
type Logger$1<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean> = pino.Logger<CustomLevels, UseOnlyCustomLevels>;
|
|
1068
|
-
interface ChildLoggerOptions<CustomLevels extends string = never> extends pino.ChildLoggerOptions<CustomLevels> {}
|
|
1069
|
-
interface DestinationStream extends pino.DestinationStream {}
|
|
1070
|
-
interface LoggerOptions<CustomLevels extends string = never, UseOnlyCustomLevels extends boolean = boolean> extends pino.LoggerOptions<CustomLevels, UseOnlyCustomLevels> {}
|
|
1071
|
-
|
|
1072
|
-
type RunStatus = 'created' | 'running' | 'completed' | 'failed';
|
|
1073
|
-
type Run = {
|
|
1074
|
-
runId?: string;
|
|
1075
|
-
runStatus?: RunStatus;
|
|
1076
|
-
};
|
|
1077
|
-
|
|
1078
|
-
declare const RegisteredLogger: {
|
|
1079
|
-
readonly AGENT: "AGENT";
|
|
1080
|
-
readonly WORKFLOW: "WORKFLOW";
|
|
1081
|
-
readonly LLM: "LLM";
|
|
1082
|
-
readonly TTS: "TTS";
|
|
1083
|
-
readonly VOICE: "VOICE";
|
|
1084
|
-
readonly VECTOR: "VECTOR";
|
|
1085
|
-
readonly BUNDLER: "BUNDLER";
|
|
1086
|
-
readonly DEPLOYER: "DEPLOYER";
|
|
1087
|
-
readonly MEMORY: "MEMORY";
|
|
1088
|
-
readonly STORAGE: "STORAGE";
|
|
1089
|
-
readonly EMBEDDINGS: "EMBEDDINGS";
|
|
1090
|
-
};
|
|
1091
|
-
type RegisteredLogger = (typeof RegisteredLogger)[keyof typeof RegisteredLogger];
|
|
1092
|
-
declare const LogLevel: {
|
|
1093
|
-
readonly DEBUG: "debug";
|
|
1094
|
-
readonly INFO: "info";
|
|
1095
|
-
readonly WARN: "warn";
|
|
1096
|
-
readonly ERROR: "error";
|
|
1097
|
-
readonly NONE: "silent";
|
|
1098
|
-
};
|
|
1099
|
-
type LogLevel = (typeof LogLevel)[keyof typeof LogLevel];
|
|
1100
|
-
interface BaseLogMessage extends Run {
|
|
1101
|
-
msg: string;
|
|
1102
|
-
level: number;
|
|
1103
|
-
time: Date;
|
|
1104
|
-
pid: number;
|
|
1105
|
-
hostname: string;
|
|
1106
|
-
name: string;
|
|
1107
|
-
}
|
|
1108
|
-
declare class LoggerTransport extends Transform {
|
|
1109
|
-
constructor(opts?: any);
|
|
1110
|
-
getLogsByRunId(_args: {
|
|
1111
|
-
runId: string;
|
|
1112
|
-
}): Promise<BaseLogMessage[]>;
|
|
1113
|
-
getLogs(): Promise<BaseLogMessage[]>;
|
|
1114
|
-
}
|
|
1115
|
-
type TransportMap = Record<string, LoggerTransport>;
|
|
1116
|
-
declare class Logger {
|
|
1117
|
-
protected logger: pino.Logger;
|
|
1118
|
-
transports: TransportMap;
|
|
1119
|
-
constructor(options?: {
|
|
1120
|
-
name?: string;
|
|
1121
|
-
level?: LogLevel;
|
|
1122
|
-
transports?: TransportMap;
|
|
1123
|
-
overrideDefaultTransports?: boolean;
|
|
1124
|
-
});
|
|
1125
|
-
debug(message: string, args?: Record<string, any>): void;
|
|
1126
|
-
info(message: string, args?: Record<string, any>): void;
|
|
1127
|
-
warn(message: string, args?: Record<string, any>): void;
|
|
1128
|
-
error(message: string, args?: Record<string, any>): void;
|
|
1129
|
-
createStream(): Transform;
|
|
1130
|
-
getLogs(transportId: string): Promise<BaseLogMessage[]>;
|
|
1131
|
-
getLogsByRunId({ runId, transportId }: {
|
|
1132
|
-
transportId: string;
|
|
1133
|
-
runId: string;
|
|
1134
|
-
}): Promise<BaseLogMessage[] | undefined>;
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
/**
|
|
1138
|
-
* An instrumentation library consists of the name and optional version
|
|
1139
|
-
* used to obtain a tracer or meter from a provider. This metadata is made
|
|
1140
|
-
* available on ReadableSpan and MetricRecord for use by the export pipeline.
|
|
1141
|
-
* @deprecated Use {@link InstrumentationScope} instead.
|
|
1142
|
-
*/
|
|
1143
|
-
interface InstrumentationLibrary {
|
|
1144
|
-
readonly name: string;
|
|
1145
|
-
readonly version?: string;
|
|
1146
|
-
readonly schemaUrl?: string;
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
|
-
interface ExportResult {
|
|
1150
|
-
code: ExportResultCode;
|
|
1151
|
-
error?: Error;
|
|
1152
|
-
}
|
|
1153
|
-
declare enum ExportResultCode {
|
|
1154
|
-
SUCCESS = 0,
|
|
1155
|
-
FAILED = 1
|
|
1156
|
-
}
|
|
1157
|
-
|
|
1158
|
-
/**
|
|
1159
|
-
* An interface that represents a resource. A Resource describes the entity for which signals (metrics or trace) are
|
|
1160
|
-
* collected.
|
|
1161
|
-
*
|
|
1162
|
-
*/
|
|
1163
|
-
interface IResource {
|
|
1164
|
-
/**
|
|
1165
|
-
* Check if async attributes have resolved. This is useful to avoid awaiting
|
|
1166
|
-
* waitForAsyncAttributes (which will introduce asynchronous behavior) when not necessary.
|
|
1167
|
-
*
|
|
1168
|
-
* @returns true if the resource "attributes" property is not yet settled to its final value
|
|
1169
|
-
*/
|
|
1170
|
-
asyncAttributesPending?: boolean;
|
|
1171
|
-
/**
|
|
1172
|
-
* @returns the Resource's attributes.
|
|
1173
|
-
*/
|
|
1174
|
-
readonly attributes: ResourceAttributes;
|
|
1175
|
-
/**
|
|
1176
|
-
* Returns a promise that will never be rejected. Resolves when all async attributes have finished being added to
|
|
1177
|
-
* this Resource's attributes. This is useful in exporters to block until resource detection
|
|
1178
|
-
* has finished.
|
|
1179
|
-
*/
|
|
1180
|
-
waitForAsyncAttributes?(): Promise<void>;
|
|
1181
|
-
/**
|
|
1182
|
-
* Returns a new, merged {@link Resource} by merging the current Resource
|
|
1183
|
-
* with the other Resource. In case of a collision, other Resource takes
|
|
1184
|
-
* precedence.
|
|
1185
|
-
*
|
|
1186
|
-
* @param other the Resource that will be merged with this.
|
|
1187
|
-
* @returns the newly merged Resource.
|
|
1188
|
-
*/
|
|
1189
|
-
merge(other: IResource | null): IResource;
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
/**
|
|
1193
|
-
* Interface for Resource attributes.
|
|
1194
|
-
* General `Attributes` interface is added in api v1.1.0.
|
|
1195
|
-
* To backward support older api (1.0.x), the deprecated `SpanAttributes` is used here.
|
|
1196
|
-
*/
|
|
1197
|
-
declare type ResourceAttributes = SpanAttributes;
|
|
1198
|
-
|
|
1199
|
-
/**
|
|
1200
|
-
* Represents a timed event.
|
|
1201
|
-
* A timed event is an event with a timestamp.
|
|
1202
|
-
*/
|
|
1203
|
-
interface TimedEvent {
|
|
1204
|
-
time: HrTime;
|
|
1205
|
-
/** The name of the event. */
|
|
1206
|
-
name: string;
|
|
1207
|
-
/** The attributes of the event. */
|
|
1208
|
-
attributes?: SpanAttributes;
|
|
1209
|
-
/** Count of attributes of the event that were dropped due to collection limits */
|
|
1210
|
-
droppedAttributesCount?: number;
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
|
-
interface ReadableSpan {
|
|
1214
|
-
readonly name: string;
|
|
1215
|
-
readonly kind: SpanKind;
|
|
1216
|
-
readonly spanContext: () => SpanContext;
|
|
1217
|
-
readonly parentSpanId?: string;
|
|
1218
|
-
readonly startTime: HrTime;
|
|
1219
|
-
readonly endTime: HrTime;
|
|
1220
|
-
readonly status: SpanStatus;
|
|
1221
|
-
readonly attributes: SpanAttributes;
|
|
1222
|
-
readonly links: Link[];
|
|
1223
|
-
readonly events: TimedEvent[];
|
|
1224
|
-
readonly duration: HrTime;
|
|
1225
|
-
readonly ended: boolean;
|
|
1226
|
-
readonly resource: IResource;
|
|
1227
|
-
readonly instrumentationLibrary: InstrumentationLibrary;
|
|
1228
|
-
readonly droppedAttributesCount: number;
|
|
1229
|
-
readonly droppedEventsCount: number;
|
|
1230
|
-
readonly droppedLinksCount: number;
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
/**
|
|
1234
|
-
* An interface that allows different tracing services to export recorded data
|
|
1235
|
-
* for sampled spans in their own format.
|
|
1236
|
-
*
|
|
1237
|
-
* To export data this MUST be register to the Tracer SDK using a optional
|
|
1238
|
-
* config.
|
|
1239
|
-
*/
|
|
1240
|
-
interface SpanExporter {
|
|
1241
|
-
/**
|
|
1242
|
-
* Called to export sampled {@link ReadableSpan}s.
|
|
1243
|
-
* @param spans the list of sampled Spans to be exported.
|
|
1244
|
-
*/
|
|
1245
|
-
export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void;
|
|
1246
|
-
/** Stops the exporter. */
|
|
1247
|
-
shutdown(): Promise<void>;
|
|
1248
|
-
/** Immediately export all spans */
|
|
1249
|
-
forceFlush?(): Promise<void>;
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
/** Sampling strategy configuration for OpenTelemetry */
|
|
1253
|
-
type SamplingStrategy = {
|
|
1254
|
-
/** Sample traces based on a probability between 0 and 1 */
|
|
1255
|
-
type: 'ratio';
|
|
1256
|
-
/** Probability between 0 and 1 (e.g., 0.1 for 10% sampling) */
|
|
1257
|
-
probability: number;
|
|
1258
|
-
} | {
|
|
1259
|
-
/** Sample all traces */
|
|
1260
|
-
type: 'always_on';
|
|
1261
|
-
} | {
|
|
1262
|
-
/** Don't sample any traces */
|
|
1263
|
-
type: 'always_off';
|
|
1264
|
-
} | {
|
|
1265
|
-
/** Use parent sampling decision if available, otherwise use root sampler */
|
|
1266
|
-
type: 'parent_based';
|
|
1267
|
-
/** Configuration for the root sampler when no parent context exists */
|
|
1268
|
-
root: {
|
|
1269
|
-
/** Probability between 0 and 1 for the root sampler */
|
|
1270
|
-
probability: number;
|
|
1271
|
-
};
|
|
1272
|
-
};
|
|
1273
|
-
/** Configuration options for OpenTelemetry */
|
|
1274
|
-
type OtelConfig = {
|
|
1275
|
-
/** Name of the service for telemetry identification */
|
|
1276
|
-
serviceName?: string;
|
|
1277
|
-
/** Whether telemetry is enabled. Defaults to true */
|
|
1278
|
-
enabled?: boolean;
|
|
1279
|
-
/** Name of the tracer to use. Defaults to 'mastra-tracer' */
|
|
1280
|
-
tracerName?: string;
|
|
1281
|
-
/** Sampling configuration to control trace data volume */
|
|
1282
|
-
sampling?: SamplingStrategy;
|
|
1283
|
-
/** Export configuration for sending telemetry data */
|
|
1284
|
-
export?: {
|
|
1285
|
-
/** Export to an OTLP (OpenTelemetry Protocol) endpoint */
|
|
1286
|
-
type: 'otlp';
|
|
1287
|
-
/** Whether to use gRPC or HTTP for OTLP */
|
|
1288
|
-
protocol?: 'grpc' | 'http';
|
|
1289
|
-
/** OTLP endpoint URL */
|
|
1290
|
-
endpoint?: string;
|
|
1291
|
-
/** Optional headers for OTLP requests */
|
|
1292
|
-
headers?: Record<string, string>;
|
|
1293
|
-
} | {
|
|
1294
|
-
/** Export to console for development/debugging */
|
|
1295
|
-
type: 'console';
|
|
1296
|
-
} | {
|
|
1297
|
-
type: 'custom';
|
|
1298
|
-
tracerName?: string;
|
|
1299
|
-
exporter: SpanExporter;
|
|
1300
|
-
};
|
|
1301
|
-
};
|
|
1302
|
-
|
|
1303
|
-
declare global {
|
|
1304
|
-
var __TELEMETRY__: Telemetry | undefined;
|
|
1305
|
-
}
|
|
1306
|
-
declare class Telemetry {
|
|
1307
|
-
tracer: Tracer;
|
|
1308
|
-
name: string;
|
|
1309
|
-
private constructor();
|
|
1310
|
-
/**
|
|
1311
|
-
* @deprecated This method does not do anything
|
|
1312
|
-
*/
|
|
1313
|
-
shutdown(): Promise<void>;
|
|
1314
|
-
/**
|
|
1315
|
-
* Initialize telemetry with the given configuration
|
|
1316
|
-
* @param config - Optional telemetry configuration object
|
|
1317
|
-
* @returns Telemetry instance that can be used for tracing
|
|
1318
|
-
*/
|
|
1319
|
-
static init(config?: OtelConfig): Telemetry;
|
|
1320
|
-
/**
|
|
1321
|
-
* Get the global telemetry instance
|
|
1322
|
-
* @throws {Error} If telemetry has not been initialized
|
|
1323
|
-
* @returns {Telemetry} The global telemetry instance
|
|
1324
|
-
*/
|
|
1325
|
-
static get(): Telemetry;
|
|
1326
|
-
/**
|
|
1327
|
-
* Wraps a class instance with telemetry tracing
|
|
1328
|
-
* @param instance The class instance to wrap
|
|
1329
|
-
* @param options Optional configuration for tracing
|
|
1330
|
-
* @returns Wrapped instance with all methods traced
|
|
1331
|
-
*/
|
|
1332
|
-
traceClass<T extends object>(instance: T, options?: {
|
|
1333
|
-
/** Base name for spans (e.g. 'integration', 'agent') */
|
|
1334
|
-
spanNamePrefix?: string;
|
|
1335
|
-
/** Additional attributes to add to all spans */
|
|
1336
|
-
attributes?: Record<string, string>;
|
|
1337
|
-
/** Methods to exclude from tracing */
|
|
1338
|
-
excludeMethods?: string[];
|
|
1339
|
-
/** Skip tracing if telemetry is not active */
|
|
1340
|
-
skipIfNoTelemetry?: boolean;
|
|
1341
|
-
}): T;
|
|
1342
|
-
/**
|
|
1343
|
-
* method to trace individual methods with proper context
|
|
1344
|
-
* @param method The method to trace
|
|
1345
|
-
* @param context Additional context for the trace
|
|
1346
|
-
* @returns Wrapped method with tracing
|
|
1347
|
-
*/
|
|
1348
|
-
traceMethod<TMethod extends Function>(method: TMethod, context: {
|
|
1349
|
-
spanName: string;
|
|
1350
|
-
attributes?: Record<string, string>;
|
|
1351
|
-
skipIfNoTelemetry?: boolean;
|
|
1352
|
-
parentSpan?: Span;
|
|
1353
|
-
}): TMethod;
|
|
1354
|
-
getBaggageTracer(): Tracer;
|
|
1355
|
-
}
|
|
1356
|
-
|
|
1357
|
-
declare class MastraBase {
|
|
1358
|
-
component: RegisteredLogger;
|
|
1359
|
-
protected logger: Logger;
|
|
1360
|
-
name?: string;
|
|
1361
|
-
telemetry?: Telemetry;
|
|
1362
|
-
constructor({ component, name }: {
|
|
1363
|
-
component?: RegisteredLogger;
|
|
1364
|
-
name?: string;
|
|
1365
|
-
});
|
|
1366
|
-
/**
|
|
1367
|
-
* Set the logger for the agent
|
|
1368
|
-
* @param logger
|
|
1369
|
-
*/
|
|
1370
|
-
__setLogger(logger: Logger): void;
|
|
1371
|
-
/**
|
|
1372
|
-
* Set the telemetry for the
|
|
1373
|
-
* @param telemetry
|
|
1374
|
-
*/
|
|
1375
|
-
__setTelemetry(telemetry: Telemetry): void;
|
|
1376
|
-
/**
|
|
1377
|
-
* Get the telemetry on the vector
|
|
1378
|
-
* @returns telemetry
|
|
1379
|
-
*/
|
|
1380
|
-
__getTelemetry(): Telemetry | undefined;
|
|
1381
|
-
get experimental_telemetry(): {
|
|
1382
|
-
tracer: Tracer;
|
|
1383
|
-
isEnabled: boolean;
|
|
1384
|
-
} | undefined;
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
type BasicValueQuery<TValue> = {
|
|
1388
|
-
$eq?: TValue;
|
|
1389
|
-
$ne?: TValue;
|
|
1390
|
-
$lt?: TValue;
|
|
1391
|
-
$gt?: TValue;
|
|
1392
|
-
$lte?: TValue;
|
|
1393
|
-
$gte?: TValue;
|
|
1394
|
-
$in?: TValue[];
|
|
1395
|
-
$nin?: TValue[];
|
|
1396
|
-
$all?: TValue[];
|
|
1397
|
-
$mod?: [number, number];
|
|
1398
|
-
$exists?: boolean;
|
|
1399
|
-
$regex?: string | RegExp;
|
|
1400
|
-
$size?: number;
|
|
1401
|
-
$where?: ((this: TValue, obj: TValue) => boolean) | string;
|
|
1402
|
-
$options?: "i" | "g" | "m" | "u";
|
|
1403
|
-
$type?: Function;
|
|
1404
|
-
$not?: NestedQuery<TValue>;
|
|
1405
|
-
$or?: NestedQuery<TValue>[];
|
|
1406
|
-
$nor?: NestedQuery<TValue>[];
|
|
1407
|
-
$and?: NestedQuery<TValue>[];
|
|
1408
|
-
};
|
|
1409
|
-
type ArrayValueQuery<TValue> = {
|
|
1410
|
-
$elemMatch?: Query<TValue>;
|
|
1411
|
-
} & BasicValueQuery<TValue>;
|
|
1412
|
-
type Unpacked<T> = T extends (infer U)[] ? U : T;
|
|
1413
|
-
type ValueQuery<TValue> = TValue extends Array<any> ? ArrayValueQuery<Unpacked<TValue>> : BasicValueQuery<TValue>;
|
|
1414
|
-
type NotObject = string | number | Date | boolean | Array<any>;
|
|
1415
|
-
type ShapeQuery<TItemSchema> = TItemSchema extends NotObject ? {} : {
|
|
1416
|
-
[k in keyof TItemSchema]?: TItemSchema[k] | ValueQuery<TItemSchema[k]>;
|
|
1417
|
-
};
|
|
1418
|
-
type NestedQuery<TItemSchema> = ValueQuery<TItemSchema> & ShapeQuery<TItemSchema>;
|
|
1419
|
-
type Query<TItemSchema> = TItemSchema | RegExp | NestedQuery<TItemSchema>;
|
|
1420
|
-
|
|
1421
|
-
interface MetricResult {
|
|
1422
|
-
score: number;
|
|
1423
|
-
info?: Record<string, any>;
|
|
1424
|
-
}
|
|
1425
|
-
declare abstract class Metric {
|
|
1426
|
-
abstract measure(input: string, output: string): Promise<MetricResult>;
|
|
1427
|
-
}
|
|
1428
|
-
|
|
1429
|
-
interface TestInfo {
|
|
1430
|
-
testName?: string;
|
|
1431
|
-
testPath?: string;
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
|
-
interface IBundler {
|
|
1435
|
-
loadEnvVars(): Promise<Map<string, string>>;
|
|
1436
|
-
getEnvFiles(): Promise<string[]>;
|
|
1437
|
-
bundle(entryFile: string, outputDirectory: string): Promise<void>;
|
|
1438
|
-
prepare(outputDirectory: string): Promise<void>;
|
|
1439
|
-
writePackageJson(outputDirectory: string, dependencies: Map<string, string>): Promise<void>;
|
|
1440
|
-
}
|
|
1441
|
-
declare abstract class MastraBundler extends MastraBase implements IBundler {
|
|
1442
|
-
constructor({ name, component }: {
|
|
1443
|
-
name: string;
|
|
1444
|
-
component?: 'BUNDLER' | 'DEPLOYER';
|
|
1445
|
-
});
|
|
1446
|
-
loadEnvVars(): Promise<Map<string, string>>;
|
|
1447
|
-
abstract prepare(outputDirectory: string): Promise<void>;
|
|
1448
|
-
abstract writePackageJson(outputDirectory: string, dependencies: Map<string, string>): Promise<void>;
|
|
1449
|
-
abstract writeInstrumentationFile(outputDirectory: string): Promise<void>;
|
|
1450
|
-
abstract getEnvFiles(): Promise<string[]>;
|
|
1451
|
-
abstract bundle(entryFile: string, outputDirectory: string): Promise<void>;
|
|
1452
|
-
}
|
|
1453
|
-
|
|
1454
|
-
interface IDeployer extends IBundler {
|
|
1455
|
-
deploy(outputDirectory: string): Promise<void>;
|
|
1456
|
-
}
|
|
1457
|
-
declare abstract class MastraDeployer extends MastraBundler implements IDeployer {
|
|
1458
|
-
constructor({ name }: {
|
|
1459
|
-
name: string;
|
|
1460
|
-
});
|
|
1461
|
-
abstract deploy(outputDirectory: string): Promise<void>;
|
|
1462
|
-
}
|
|
1463
|
-
|
|
1464
|
-
type BasicOperator = '$eq' | '$ne';
|
|
1465
|
-
type NumericOperator = '$gt' | '$gte' | '$lt' | '$lte';
|
|
1466
|
-
type LogicalOperator = '$and' | '$not' | '$nor' | '$or';
|
|
1467
|
-
type ArrayOperator = '$all' | '$in' | '$nin' | '$elemMatch';
|
|
1468
|
-
type ElementOperator = '$exists';
|
|
1469
|
-
type RegexOperator = '$regex' | '$options';
|
|
1470
|
-
type QueryOperator = BasicOperator | NumericOperator | LogicalOperator | ArrayOperator | ElementOperator | RegexOperator;
|
|
1471
|
-
type OperatorCondition = {
|
|
1472
|
-
[K in QueryOperator]?: any;
|
|
1473
|
-
};
|
|
1474
|
-
type FieldCondition = OperatorCondition | any;
|
|
1475
|
-
type VectorFilter = {
|
|
1476
|
-
[field: string]: FieldCondition | VectorFilter;
|
|
1477
|
-
} | null | undefined;
|
|
1478
|
-
|
|
1479
|
-
interface QueryResult {
|
|
1480
|
-
id: string;
|
|
1481
|
-
score: number;
|
|
1482
|
-
metadata?: Record<string, any>;
|
|
1483
|
-
vector?: number[];
|
|
1484
|
-
/**
|
|
1485
|
-
* The document content, if available.
|
|
1486
|
-
* Note: Currently only supported by Chroma vector store.
|
|
1487
|
-
* For other vector stores, documents should be stored in metadata.
|
|
1488
|
-
*/
|
|
1489
|
-
document?: string;
|
|
1490
|
-
}
|
|
1491
|
-
interface IndexStats {
|
|
1492
|
-
dimension: number;
|
|
1493
|
-
count: number;
|
|
1494
|
-
metric?: 'cosine' | 'euclidean' | 'dotproduct';
|
|
1495
|
-
}
|
|
1496
|
-
interface UpsertVectorParams {
|
|
1497
|
-
indexName: string;
|
|
1498
|
-
vectors: number[][];
|
|
1499
|
-
metadata?: Record<string, any>[];
|
|
1500
|
-
ids?: string[];
|
|
1501
|
-
}
|
|
1502
|
-
type UpsertVectorArgs = [string, number[][], Record<string, any>[], string[]?];
|
|
1503
|
-
interface CreateIndexParams {
|
|
1504
|
-
indexName: string;
|
|
1505
|
-
dimension: number;
|
|
1506
|
-
metric?: 'cosine' | 'euclidean' | 'dotproduct';
|
|
1507
|
-
}
|
|
1508
|
-
type CreateIndexArgs = [string, number, 'cosine' | 'euclidean' | 'dotproduct'];
|
|
1509
|
-
interface QueryVectorParams {
|
|
1510
|
-
indexName: string;
|
|
1511
|
-
queryVector: number[];
|
|
1512
|
-
topK?: number;
|
|
1513
|
-
filter?: VectorFilter;
|
|
1514
|
-
includeVector?: boolean;
|
|
1515
|
-
}
|
|
1516
|
-
type QueryVectorArgs = [string, number[], number, VectorFilter?, boolean?];
|
|
1517
|
-
type ParamsToArgs<T> = [T] | (T extends QueryVectorParams ? QueryVectorArgs : never) | (T extends UpsertVectorParams ? UpsertVectorArgs : never) | (T extends CreateIndexParams ? CreateIndexArgs : never);
|
|
1518
|
-
|
|
1519
|
-
declare abstract class MastraVector extends MastraBase {
|
|
1520
|
-
constructor();
|
|
1521
|
-
private readonly baseKeys;
|
|
1522
|
-
protected normalizeArgs<T, E extends any[] = never>(method: string, [first, ...rest]: ParamsToArgs<T> | E, extendedKeys?: string[]): T;
|
|
1523
|
-
abstract query<E extends QueryVectorArgs = QueryVectorArgs>(...args: ParamsToArgs<QueryVectorParams> | E): Promise<QueryResult[]>;
|
|
1524
|
-
abstract upsert<E extends UpsertVectorArgs = UpsertVectorArgs>(...args: ParamsToArgs<UpsertVectorParams> | E): Promise<string[]>;
|
|
1525
|
-
abstract createIndex<E extends CreateIndexArgs = CreateIndexArgs>(...args: ParamsToArgs<CreateIndexParams> | E): Promise<void>;
|
|
1526
|
-
abstract listIndexes(): Promise<string[]>;
|
|
1527
|
-
abstract describeIndex(indexName: string): Promise<IndexStats>;
|
|
1528
|
-
abstract deleteIndex(indexName: string): Promise<void>;
|
|
1529
|
-
updateIndexById(_indexName: string, _id: string, _update: {
|
|
1530
|
-
vector?: number[];
|
|
1531
|
-
metadata?: Record<string, any>;
|
|
1532
|
-
}): Promise<void>;
|
|
1533
|
-
deleteIndexById(_indexName: string, _id: string): Promise<void>;
|
|
1534
|
-
}
|
|
1535
|
-
|
|
1536
|
-
interface BuiltInModelConfig$1 {
|
|
1537
|
-
provider: string;
|
|
1538
|
-
name: string;
|
|
1539
|
-
apiKey?: string;
|
|
1540
|
-
}
|
|
1541
|
-
interface TTSConfig {
|
|
1542
|
-
model: BuiltInModelConfig$1;
|
|
1543
|
-
}
|
|
1544
|
-
declare abstract class MastraTTS extends MastraBase {
|
|
1545
|
-
model: BuiltInModelConfig$1;
|
|
1546
|
-
constructor({ model }: TTSConfig);
|
|
1547
|
-
traced<T extends Function>(method: T, methodName: string): T;
|
|
1548
|
-
abstract generate({ text }: {
|
|
1549
|
-
text: string;
|
|
1550
|
-
}): Promise<any>;
|
|
1551
|
-
abstract stream({ text }: {
|
|
1552
|
-
text: string;
|
|
1553
|
-
}): Promise<any>;
|
|
1554
|
-
}
|
|
1555
|
-
|
|
1556
|
-
interface BuiltInModelConfig {
|
|
1557
|
-
name: string;
|
|
1558
|
-
apiKey?: string;
|
|
1559
|
-
}
|
|
1560
|
-
interface VoiceConfig {
|
|
1561
|
-
listeningModel?: BuiltInModelConfig;
|
|
1562
|
-
speechModel?: BuiltInModelConfig;
|
|
1563
|
-
speaker?: string;
|
|
1564
|
-
}
|
|
1565
|
-
declare abstract class MastraVoice extends MastraBase {
|
|
1566
|
-
protected listeningModel?: BuiltInModelConfig;
|
|
1567
|
-
protected speechModel?: BuiltInModelConfig;
|
|
1568
|
-
protected speaker?: string;
|
|
1569
|
-
constructor({ listeningModel, speechModel, speaker }?: VoiceConfig);
|
|
1570
|
-
traced<T extends Function>(method: T, methodName: string): T;
|
|
1571
|
-
/**
|
|
1572
|
-
* Convert text to speech
|
|
1573
|
-
* @param input Text or text stream to convert to speech
|
|
1574
|
-
* @param options Speech options including speaker and provider-specific options
|
|
1575
|
-
* @returns Audio stream
|
|
1576
|
-
*/
|
|
1577
|
-
abstract speak(input: string | NodeJS.ReadableStream, options?: {
|
|
1578
|
-
speaker?: string;
|
|
1579
|
-
[key: string]: any;
|
|
1580
|
-
}): Promise<NodeJS.ReadableStream>;
|
|
1581
|
-
/**
|
|
1582
|
-
* Convert speech to text
|
|
1583
|
-
* @param audioStream Audio stream to transcribe
|
|
1584
|
-
* @param options Provider-specific transcription options
|
|
1585
|
-
* @returns Text or text stream
|
|
1586
|
-
*/
|
|
1587
|
-
abstract listen(audioStream: NodeJS.ReadableStream, options?: {
|
|
1588
|
-
[key: string]: any;
|
|
1589
|
-
}): Promise<string | NodeJS.ReadableStream>;
|
|
1590
|
-
/**
|
|
1591
|
-
* Get available speakers/voices
|
|
1592
|
-
* @returns Array of available voice IDs and their metadata
|
|
1593
|
-
*/
|
|
1594
|
-
abstract getSpeakers(): Promise<Array<{
|
|
1595
|
-
voiceId: string;
|
|
1596
|
-
[key: string]: any;
|
|
1597
|
-
}>>;
|
|
1598
|
-
}
|
|
1599
|
-
|
|
1600
|
-
declare class CompositeVoice extends MastraVoice {
|
|
1601
|
-
protected speakProvider?: MastraVoice;
|
|
1602
|
-
protected listenProvider?: MastraVoice;
|
|
1603
|
-
constructor({ speakProvider, listenProvider }: {
|
|
1604
|
-
speakProvider?: MastraVoice;
|
|
1605
|
-
listenProvider?: MastraVoice;
|
|
1606
|
-
});
|
|
1607
|
-
speak(input: string | NodeJS.ReadableStream, options?: any): Promise<NodeJS.ReadableStream>;
|
|
1608
|
-
listen(audioStream: NodeJS.ReadableStream, options?: any): Promise<string | NodeJS.ReadableStream>;
|
|
1609
|
-
getSpeakers(): Promise<{
|
|
1610
|
-
[key: string]: any;
|
|
1611
|
-
voiceId: string;
|
|
1612
|
-
}[]>;
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
type VercelTool = Tool$1;
|
|
1616
|
-
type CoreTool = {
|
|
1617
|
-
description?: string;
|
|
1618
|
-
parameters: ZodSchema;
|
|
1619
|
-
execute?: (params: any, options: ToolExecutionOptions) => Promise<any>;
|
|
1620
|
-
};
|
|
1621
|
-
interface ToolExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undefined> extends IExecutionContext<TSchemaIn> {
|
|
1622
|
-
mastra?: MastraUnion;
|
|
1623
|
-
}
|
|
1624
|
-
interface ToolAction<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>, TOptions extends unknown = unknown> extends IAction<string, TSchemaIn, TSchemaOut, TContext, TOptions> {
|
|
1625
|
-
description: string;
|
|
1626
|
-
execute?: (context: TContext, options?: TOptions) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
|
|
1627
|
-
mastra?: Mastra;
|
|
1628
|
-
}
|
|
1629
|
-
|
|
1630
|
-
/**
|
|
1631
|
-
* Abstract Memory class that defines the interface for storing and retrieving
|
|
1632
|
-
* conversation threads and messages.
|
|
1633
|
-
*/
|
|
1634
|
-
declare abstract class MastraMemory extends MastraBase {
|
|
1635
|
-
MAX_CONTEXT_TOKENS?: number;
|
|
1636
|
-
storage: MastraStorage;
|
|
1637
|
-
vector: MastraVector;
|
|
1638
|
-
embedder: EmbeddingModel<string>;
|
|
1639
|
-
protected threadConfig: MemoryConfig;
|
|
1640
|
-
constructor(config: {
|
|
1641
|
-
name: string;
|
|
1642
|
-
} & SharedMemoryConfig);
|
|
1643
|
-
setStorage(storage: MastraStorage): void;
|
|
1644
|
-
setVector(vector: MastraVector): void;
|
|
1645
|
-
setEmbedder(embedder: EmbeddingModel<string>): void;
|
|
1646
|
-
/**
|
|
1647
|
-
* Get a system message to inject into the conversation.
|
|
1648
|
-
* This will be called before each conversation turn.
|
|
1649
|
-
* Implementations can override this to inject custom system messages.
|
|
1650
|
-
*/
|
|
1651
|
-
getSystemMessage(_input: {
|
|
1652
|
-
threadId: string;
|
|
1653
|
-
memoryConfig?: MemoryConfig;
|
|
1654
|
-
}): Promise<string | null>;
|
|
1655
|
-
/**
|
|
1656
|
-
* Get tools that should be available to the agent.
|
|
1657
|
-
* This will be called when converting tools for the agent.
|
|
1658
|
-
* Implementations can override this to provide additional tools.
|
|
1659
|
-
*/
|
|
1660
|
-
getTools(_config?: MemoryConfig): Record<string, CoreTool>;
|
|
1661
|
-
protected createEmbeddingIndex(): Promise<{
|
|
1662
|
-
indexName: string;
|
|
1663
|
-
}>;
|
|
1664
|
-
getMergedThreadConfig(config?: MemoryConfig): MemoryConfig;
|
|
1665
|
-
abstract rememberMessages({ threadId, resourceId, vectorMessageSearch, config, }: {
|
|
1666
|
-
threadId: string;
|
|
1667
|
-
resourceId?: string;
|
|
1668
|
-
vectorMessageSearch?: string;
|
|
1669
|
-
config?: MemoryConfig;
|
|
1670
|
-
}): Promise<{
|
|
1671
|
-
threadId: string;
|
|
1672
|
-
messages: CoreMessage$1[];
|
|
1673
|
-
uiMessages: Message[];
|
|
1674
|
-
}>;
|
|
1675
|
-
estimateTokens(text: string): number;
|
|
1676
|
-
protected parseMessages(messages: MessageType[]): CoreMessage$1[];
|
|
1677
|
-
protected convertToUIMessages(messages: MessageType[]): Message[];
|
|
1678
|
-
/**
|
|
1679
|
-
* Retrieves a specific thread by its ID
|
|
1680
|
-
* @param threadId - The unique identifier of the thread
|
|
1681
|
-
* @returns Promise resolving to the thread or null if not found
|
|
1682
|
-
*/
|
|
1683
|
-
abstract getThreadById({ threadId }: {
|
|
1684
|
-
threadId: string;
|
|
1685
|
-
}): Promise<StorageThreadType | null>;
|
|
1686
|
-
abstract getThreadsByResourceId({ resourceId }: {
|
|
1687
|
-
resourceId: string;
|
|
1688
|
-
}): Promise<StorageThreadType[]>;
|
|
1689
|
-
/**
|
|
1690
|
-
* Saves or updates a thread
|
|
1691
|
-
* @param thread - The thread data to save
|
|
1692
|
-
* @returns Promise resolving to the saved thread
|
|
1693
|
-
*/
|
|
1694
|
-
abstract saveThread({ thread, memoryConfig, }: {
|
|
1695
|
-
thread: StorageThreadType;
|
|
1696
|
-
memoryConfig?: MemoryConfig;
|
|
1697
|
-
}): Promise<StorageThreadType>;
|
|
1698
|
-
/**
|
|
1699
|
-
* Saves messages to a thread
|
|
1700
|
-
* @param messages - Array of messages to save
|
|
1701
|
-
* @returns Promise resolving to the saved messages
|
|
1702
|
-
*/
|
|
1703
|
-
abstract saveMessages({ messages, memoryConfig, }: {
|
|
1704
|
-
messages: MessageType[];
|
|
1705
|
-
memoryConfig: MemoryConfig | undefined;
|
|
1706
|
-
}): Promise<MessageType[]>;
|
|
1707
|
-
/**
|
|
1708
|
-
* Retrieves all messages for a specific thread
|
|
1709
|
-
* @param threadId - The unique identifier of the thread
|
|
1710
|
-
* @returns Promise resolving to array of messages and uiMessages
|
|
1711
|
-
*/
|
|
1712
|
-
abstract query({ threadId, resourceId, selectBy, }: StorageGetMessagesArg): Promise<{
|
|
1713
|
-
messages: CoreMessage$1[];
|
|
1714
|
-
uiMessages: Message[];
|
|
1715
|
-
}>;
|
|
1716
|
-
/**
|
|
1717
|
-
* Helper method to create a new thread
|
|
1718
|
-
* @param title - Optional title for the thread
|
|
1719
|
-
* @param metadata - Optional metadata for the thread
|
|
1720
|
-
* @returns Promise resolving to the created thread
|
|
1721
|
-
*/
|
|
1722
|
-
createThread({ threadId, resourceId, title, metadata, memoryConfig, }: {
|
|
1723
|
-
resourceId: string;
|
|
1724
|
-
threadId?: string;
|
|
1725
|
-
title?: string;
|
|
1726
|
-
metadata?: Record<string, unknown>;
|
|
1727
|
-
memoryConfig?: MemoryConfig;
|
|
1728
|
-
}): Promise<StorageThreadType>;
|
|
1729
|
-
/**
|
|
1730
|
-
* Helper method to delete a thread
|
|
1731
|
-
* @param threadId - the id of the thread to delete
|
|
1732
|
-
*/
|
|
1733
|
-
abstract deleteThread(threadId: string): Promise<void>;
|
|
1734
|
-
/**
|
|
1735
|
-
* Helper method to add a single message to a thread
|
|
1736
|
-
* @param threadId - The thread to add the message to
|
|
1737
|
-
* @param content - The message content
|
|
1738
|
-
* @param role - The role of the message sender
|
|
1739
|
-
* @param type - The type of the message
|
|
1740
|
-
* @param toolNames - Optional array of tool names that were called
|
|
1741
|
-
* @param toolCallArgs - Optional array of tool call arguments
|
|
1742
|
-
* @param toolCallIds - Optional array of tool call ids
|
|
1743
|
-
* @returns Promise resolving to the saved message
|
|
1744
|
-
*/
|
|
1745
|
-
addMessage({ threadId, config, content, role, type, toolNames, toolCallArgs, toolCallIds, }: {
|
|
1746
|
-
threadId: string;
|
|
1747
|
-
config?: MemoryConfig;
|
|
1748
|
-
content: UserContent | AssistantContent;
|
|
1749
|
-
role: 'user' | 'assistant';
|
|
1750
|
-
type: 'text' | 'tool-call' | 'tool-result';
|
|
1751
|
-
toolNames?: string[];
|
|
1752
|
-
toolCallArgs?: Record<string, unknown>[];
|
|
1753
|
-
toolCallIds?: string[];
|
|
1754
|
-
}): Promise<MessageType>;
|
|
1755
|
-
/**
|
|
1756
|
-
* Generates a unique identifier
|
|
1757
|
-
* @returns A unique string ID
|
|
1758
|
-
*/
|
|
1759
|
-
generateId(): string;
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1762
|
-
declare class Step<TStepId extends string = any, TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends StepExecutionContext<TSchemaIn> = StepExecutionContext<TSchemaIn>> implements StepAction<TStepId, TSchemaIn, TSchemaOut, TContext> {
|
|
1763
|
-
id: TStepId;
|
|
1764
|
-
description?: string;
|
|
1765
|
-
inputSchema?: TSchemaIn;
|
|
1766
|
-
outputSchema?: TSchemaOut;
|
|
1767
|
-
payload?: TSchemaIn extends z.ZodSchema ? Partial<z.infer<TSchemaIn>> : unknown;
|
|
1768
|
-
execute: (context: TContext) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
|
|
1769
|
-
retryConfig?: RetryConfig;
|
|
1770
|
-
mastra?: Mastra;
|
|
1771
|
-
constructor({ id, description, execute, payload, outputSchema, inputSchema, retryConfig, }: StepAction<TStepId, TSchemaIn, TSchemaOut, TContext>);
|
|
1772
|
-
}
|
|
1773
|
-
|
|
1774
|
-
interface WorkflowOptions<TTriggerSchema extends z.ZodObject<any> = any> {
|
|
1775
|
-
name: string;
|
|
1776
|
-
triggerSchema?: TTriggerSchema;
|
|
1777
|
-
events?: Record<string, {
|
|
1778
|
-
schema: z.ZodObject<any>;
|
|
1779
|
-
}>;
|
|
1780
|
-
retryConfig?: RetryConfig;
|
|
1781
|
-
mastra?: Mastra;
|
|
1782
|
-
}
|
|
1783
|
-
interface StepExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undefined, TContext extends WorkflowContext = WorkflowContext> extends IExecutionContext<TSchemaIn> {
|
|
1784
|
-
context: TSchemaIn extends z.ZodSchema ? z.infer<TSchemaIn> & TContext : TContext;
|
|
1785
|
-
suspend: (payload?: unknown) => Promise<void>;
|
|
1786
|
-
runId: string;
|
|
1787
|
-
mastra?: MastraUnion;
|
|
1788
|
-
}
|
|
1789
|
-
interface StepAction<TId extends string, TSchemaIn extends z.ZodSchema | undefined, TSchemaOut extends z.ZodSchema | undefined, TContext extends StepExecutionContext<TSchemaIn>> extends IAction<TId, TSchemaIn, TSchemaOut, TContext> {
|
|
1790
|
-
mastra?: Mastra;
|
|
1791
|
-
payload?: TSchemaIn extends z.ZodSchema ? Partial<z.infer<TSchemaIn>> : unknown;
|
|
1792
|
-
execute: (context: TContext) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
|
|
1793
|
-
retryConfig?: RetryConfig;
|
|
1794
|
-
}
|
|
1795
|
-
interface SimpleConditionalType {
|
|
1796
|
-
[key: `${string}.${string}`]: string | Query<any>;
|
|
1797
|
-
}
|
|
1798
|
-
type StepVariableType<TId extends string, TSchemaIn extends z.ZodSchema | undefined, TSchemaOut extends z.ZodSchema | undefined, TContext extends StepExecutionContext<TSchemaIn>> = StepAction<TId, TSchemaIn, TSchemaOut, TContext> | 'trigger' | {
|
|
1799
|
-
id: string;
|
|
1800
|
-
};
|
|
1801
|
-
type StepNode = {
|
|
1802
|
-
step: StepAction<any, any, any, any>;
|
|
1803
|
-
config: StepDef<any, any, any, any>[any];
|
|
1804
|
-
};
|
|
1805
|
-
type StepGraph = {
|
|
1806
|
-
initial: StepNode[];
|
|
1807
|
-
[key: string]: StepNode[];
|
|
1808
|
-
};
|
|
1809
|
-
type RetryConfig = {
|
|
1810
|
-
attempts?: number;
|
|
1811
|
-
delay?: number;
|
|
1812
|
-
};
|
|
1813
|
-
type VariableReference<TStep extends StepVariableType<any, any, any, any>, TTriggerSchema extends z.ZodObject<any>> = TStep extends StepAction<any, any, any, any> ? {
|
|
1814
|
-
step: TStep;
|
|
1815
|
-
path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TStep, 'outputSchema'>>> | '' | '.';
|
|
1816
|
-
} : TStep extends 'trigger' ? {
|
|
1817
|
-
step: 'trigger';
|
|
1818
|
-
path: PathsToStringProps<ExtractSchemaType<TTriggerSchema>> | '.' | '';
|
|
1819
|
-
} : {
|
|
1820
|
-
step: {
|
|
1821
|
-
id: string;
|
|
1822
|
-
};
|
|
1823
|
-
path: string;
|
|
1824
|
-
};
|
|
1825
|
-
interface BaseCondition<TStep extends StepVariableType<any, any, any, any>, TTriggerSchema extends z.ZodObject<any>> {
|
|
1826
|
-
ref: TStep extends StepAction<any, any, any, any> ? {
|
|
1827
|
-
step: TStep;
|
|
1828
|
-
path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TStep, 'outputSchema'>>> | '' | '.' | 'status';
|
|
1829
|
-
} : TStep extends 'trigger' ? {
|
|
1830
|
-
step: 'trigger';
|
|
1831
|
-
path: PathsToStringProps<ExtractSchemaType<TTriggerSchema>> | '.' | '';
|
|
1832
|
-
} : {
|
|
1833
|
-
step: {
|
|
1834
|
-
id: string;
|
|
1835
|
-
};
|
|
1836
|
-
path: string;
|
|
1837
|
-
};
|
|
1838
|
-
query: Query<any>;
|
|
1839
|
-
}
|
|
1840
|
-
type ActionContext<TSchemaIn extends z.ZodType<any>> = StepExecutionContext<z.infer<TSchemaIn>, WorkflowContext>;
|
|
1841
|
-
declare enum WhenConditionReturnValue {
|
|
1842
|
-
CONTINUE = "continue",
|
|
1843
|
-
CONTINUE_FAILED = "continue_failed",
|
|
1844
|
-
ABORT = "abort",
|
|
1845
|
-
LIMBO = "limbo"
|
|
1846
|
-
}
|
|
1847
|
-
type StepDef<TStepId extends TSteps[number]['id'], TSteps extends StepAction<any, any, any, any>[], TSchemaIn extends z.ZodType<any>, TSchemaOut extends z.ZodType<any>> = Record<TStepId, {
|
|
1848
|
-
when?: Condition<any, any> | ((args: {
|
|
1849
|
-
context: WorkflowContext;
|
|
1850
|
-
mastra?: Mastra;
|
|
1851
|
-
}) => Promise<boolean | WhenConditionReturnValue>);
|
|
1852
|
-
serializedWhen?: Condition<any, any> | string;
|
|
1853
|
-
data: TSchemaIn;
|
|
1854
|
-
handler: (args: ActionContext<TSchemaIn>) => Promise<z.infer<TSchemaOut>>;
|
|
1855
|
-
}>;
|
|
1856
|
-
type Condition<TStep extends StepVariableType<any, any, any, any>, TTriggerSchema extends z.ZodObject<any>> = BaseCondition<TStep, TTriggerSchema> | SimpleConditionalType | {
|
|
1857
|
-
and: Condition<TStep, TTriggerSchema>[];
|
|
1858
|
-
} | {
|
|
1859
|
-
or: Condition<TStep, TTriggerSchema>[];
|
|
1860
|
-
} | {
|
|
1861
|
-
not: Condition<TStep, TTriggerSchema>;
|
|
1862
|
-
};
|
|
1863
|
-
interface StepConfig<TStep extends StepAction<any, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>, TTriggerSchema extends z.ZodObject<any>, TSteps extends Step<string, any, any, any>[] = Step<string, any, any, any>[]> {
|
|
1864
|
-
when?: Condition<CondStep, TTriggerSchema> | ((args: {
|
|
1865
|
-
context: WorkflowContext<TTriggerSchema, TSteps>;
|
|
1866
|
-
mastra?: Mastra;
|
|
1867
|
-
}) => Promise<boolean | WhenConditionReturnValue>);
|
|
1868
|
-
variables?: StepInputType<TStep, 'inputSchema'> extends never ? Record<string, VariableReference<VarStep, TTriggerSchema>> : {
|
|
1869
|
-
[K in keyof StepInputType<TStep, 'inputSchema'>]?: VariableReference<VarStep, TTriggerSchema>;
|
|
1870
|
-
};
|
|
1871
|
-
}
|
|
1872
|
-
type StepSuccess<T> = {
|
|
1873
|
-
status: 'success';
|
|
1874
|
-
output: T;
|
|
1875
|
-
};
|
|
1876
|
-
type StepSuspended = {
|
|
1877
|
-
status: 'suspended';
|
|
1878
|
-
suspendPayload?: any;
|
|
1879
|
-
};
|
|
1880
|
-
type StepWaiting = {
|
|
1881
|
-
status: 'waiting';
|
|
1882
|
-
};
|
|
1883
|
-
type StepFailure = {
|
|
1884
|
-
status: 'failed';
|
|
1885
|
-
error: string;
|
|
1886
|
-
};
|
|
1887
|
-
type StepSkipped = {
|
|
1888
|
-
status: 'skipped';
|
|
1889
|
-
};
|
|
1890
|
-
type StepResult<T> = StepSuccess<T> | StepFailure | StepSuspended | StepWaiting | StepSkipped;
|
|
1891
|
-
type StepsRecord<T extends readonly Step<any, any, z.ZodType<any> | undefined>[]> = {
|
|
1892
|
-
[K in T[number]['id']]: Extract<T[number], {
|
|
1893
|
-
id: K;
|
|
1894
|
-
}>;
|
|
1895
|
-
};
|
|
1896
|
-
interface WorkflowRunResult<T extends z.ZodType<any>, TSteps extends Step<string, any, z.ZodType<any> | undefined>[]> {
|
|
1897
|
-
triggerData?: z.infer<T>;
|
|
1898
|
-
results: {
|
|
1899
|
-
[K in keyof StepsRecord<TSteps>]: StepsRecord<TSteps>[K]['outputSchema'] extends undefined ? StepResult<unknown> : StepResult<z.infer<NonNullable<StepsRecord<TSteps>[K]['outputSchema']>>>;
|
|
1900
|
-
};
|
|
1901
|
-
runId: string;
|
|
1902
|
-
activePaths: Map<keyof StepsRecord<TSteps>, {
|
|
1903
|
-
status: string;
|
|
1904
|
-
suspendPayload?: any;
|
|
1905
|
-
}>;
|
|
1906
|
-
}
|
|
1907
|
-
interface WorkflowContext<TTrigger extends z.ZodObject<any> = any, TSteps extends Step<string, any, any, any>[] = Step<string, any, any, any>[]> {
|
|
1908
|
-
mastra?: MastraUnion;
|
|
1909
|
-
steps: {
|
|
1910
|
-
[K in keyof StepsRecord<TSteps>]: StepsRecord<TSteps>[K]['outputSchema'] extends undefined ? StepResult<unknown> : StepResult<z.infer<NonNullable<StepsRecord<TSteps>[K]['outputSchema']>>>;
|
|
1911
|
-
};
|
|
1912
|
-
triggerData: z.infer<TTrigger>;
|
|
1913
|
-
resumeData?: any;
|
|
1914
|
-
attempts: Record<string, number>;
|
|
1915
|
-
getStepResult(stepId: 'trigger'): z.infer<TTrigger>;
|
|
1916
|
-
getStepResult<T extends keyof StepsRecord<TSteps> | unknown>(stepId: T extends keyof StepsRecord<TSteps> ? T : string): T extends keyof StepsRecord<TSteps> ? StepsRecord<TSteps>[T]['outputSchema'] extends undefined ? unknown : z.infer<NonNullable<StepsRecord<TSteps>[T]['outputSchema']>> : T;
|
|
1917
|
-
getStepResult<T extends Step<any, any, any, any>>(stepId: T): T['outputSchema'] extends undefined ? unknown : z.infer<NonNullable<T['outputSchema']>>;
|
|
1918
|
-
}
|
|
1919
|
-
type ExtractSchemaFromStep<TStep extends StepAction<any, any, any, any>, TKey extends 'inputSchema' | 'outputSchema'> = TStep[TKey];
|
|
1920
|
-
type StepInputType<TStep extends StepAction<any, any, any, any>, TKey extends 'inputSchema' | 'outputSchema'> = ExtractSchemaFromStep<TStep, TKey> extends infer Schema ? Schema extends z.ZodType<any> ? z.infer<Schema> : never : never;
|
|
1921
|
-
type ExtractSchemaType<T extends z.ZodSchema> = T extends z.ZodSchema<infer V> ? V : never;
|
|
1922
|
-
type PathsToStringProps<T> = T extends object ? {
|
|
1923
|
-
[K in keyof T]: T[K] extends object ? K extends string ? K | `${K}.${PathsToStringProps<T[K]>}` : never : K extends string ? K : never;
|
|
1924
|
-
}[keyof T] : never;
|
|
1925
|
-
interface WorkflowRunState {
|
|
1926
|
-
value: Record<string, string>;
|
|
1927
|
-
context: {
|
|
1928
|
-
steps: Record<string, {
|
|
1929
|
-
status: 'success' | 'failed' | 'suspended' | 'waiting' | 'skipped';
|
|
1930
|
-
payload?: any;
|
|
1931
|
-
error?: string;
|
|
1932
|
-
}>;
|
|
1933
|
-
triggerData: Record<string, any>;
|
|
1934
|
-
attempts: Record<string, number>;
|
|
1935
|
-
};
|
|
1936
|
-
activePaths: Array<{
|
|
1937
|
-
stepPath: string[];
|
|
1938
|
-
stepId: string;
|
|
1939
|
-
status: string;
|
|
1940
|
-
}>;
|
|
1941
|
-
runId: string;
|
|
1942
|
-
timestamp: number;
|
|
1943
|
-
childStates?: Record<string, WorkflowRunState>;
|
|
1944
|
-
suspendedSteps?: Record<string, string>;
|
|
1945
|
-
}
|
|
1946
|
-
|
|
1947
|
-
interface WorkflowResultReturn<T extends z.ZodType<any>, TSteps extends Step<any, any, any>[]> {
|
|
1948
|
-
runId: string;
|
|
1949
|
-
start: (props?: {
|
|
1950
|
-
triggerData?: z.infer<T>;
|
|
1951
|
-
} | undefined) => Promise<WorkflowRunResult<T, TSteps>>;
|
|
1952
|
-
}
|
|
1953
|
-
|
|
1954
|
-
declare class Workflow<TSteps extends Step<string, any, any>[] = Step<string, any, any>[], TTriggerSchema extends z.ZodObject<any> = any> extends MastraBase {
|
|
1955
|
-
#private;
|
|
1956
|
-
name: string;
|
|
1957
|
-
triggerSchema?: TTriggerSchema;
|
|
1958
|
-
events?: Record<string, {
|
|
1959
|
-
schema: z.ZodObject<any>;
|
|
1960
|
-
}>;
|
|
1961
|
-
/**
|
|
1962
|
-
* Creates a new Workflow instance
|
|
1963
|
-
* @param name - Identifier for the workflow (not necessarily unique)
|
|
1964
|
-
* @param logger - Optional logger instance
|
|
1965
|
-
*/
|
|
1966
|
-
constructor({ name, triggerSchema, retryConfig, mastra, events }: WorkflowOptions<TTriggerSchema>);
|
|
1967
|
-
step<TStep extends StepAction<any, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>>(step: TStep, config?: StepConfig<TStep, CondStep, VarStep, TTriggerSchema>): this;
|
|
1968
|
-
then<TStep extends StepAction<any, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>>(step: TStep, config?: StepConfig<TStep, CondStep, VarStep, TTriggerSchema>): this;
|
|
1969
|
-
private loop;
|
|
1970
|
-
while<FallbackStep extends StepAction<any, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>>(condition: StepConfig<FallbackStep, CondStep, VarStep, TTriggerSchema>['when'], fallbackStep: FallbackStep): this;
|
|
1971
|
-
until<FallbackStep extends StepAction<any, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>>(condition: StepConfig<FallbackStep, CondStep, VarStep, TTriggerSchema, TSteps>['when'], fallbackStep: FallbackStep): this;
|
|
1972
|
-
if<TStep extends StepAction<any, any, any, any>>(condition: StepConfig<TStep, any, any, TTriggerSchema>['when']): this;
|
|
1973
|
-
else(): this;
|
|
1974
|
-
after<TStep extends StepAction<any, any, any, any>>(steps: TStep | TStep[]): Omit<typeof this, "then" | "after">;
|
|
1975
|
-
afterEvent(eventName: string): this;
|
|
1976
|
-
/**
|
|
1977
|
-
* Executes the workflow with the given trigger data
|
|
1978
|
-
* @param triggerData - Initial data to start the workflow with
|
|
1979
|
-
* @returns Promise resolving to workflow results or rejecting with error
|
|
1980
|
-
* @throws Error if trigger schema validation fails
|
|
1981
|
-
*/
|
|
1982
|
-
createRun(): WorkflowResultReturn<TTriggerSchema, TSteps>;
|
|
1983
|
-
/**
|
|
1984
|
-
* Rebuilds the machine with the current steps configuration and validates the workflow
|
|
1985
|
-
*
|
|
1986
|
-
* This is the last step of a workflow builder method chain
|
|
1987
|
-
* @throws Error if validation fails
|
|
1988
|
-
*
|
|
1989
|
-
* @returns this instance for method chaining
|
|
1990
|
-
*/
|
|
1991
|
-
commit(): this;
|
|
1992
|
-
getExecutionSpan(runId: string): Span | undefined;
|
|
1993
|
-
getState(runId: string): Promise<WorkflowRunState | null>;
|
|
1994
|
-
watch(onTransition: (state: WorkflowRunState) => void): () => void;
|
|
1995
|
-
resume({ runId, stepId, context: resumeContext, }: {
|
|
1996
|
-
runId: string;
|
|
1997
|
-
stepId: string;
|
|
1998
|
-
context?: Record<string, any>;
|
|
1999
|
-
}): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps>, "runId"> | undefined>;
|
|
2000
|
-
_resume({ runId, stepId, context: resumeContext, }: {
|
|
2001
|
-
runId: string;
|
|
2002
|
-
stepId: string;
|
|
2003
|
-
context?: Record<string, any>;
|
|
2004
|
-
}): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps>, "runId"> | undefined>;
|
|
2005
|
-
resumeWithEvent(runId: string, eventName: string, data: any): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps>, "runId"> | undefined>;
|
|
2006
|
-
__registerMastra(mastra: Mastra): void;
|
|
2007
|
-
__registerPrimitives(p: MastraPrimitives): void;
|
|
2008
|
-
get stepGraph(): StepGraph;
|
|
2009
|
-
get stepSubscriberGraph(): Record<string, StepGraph>;
|
|
2010
|
-
get steps(): Record<string, StepAction<any, any, any, any>>;
|
|
2011
|
-
}
|
|
2012
|
-
|
|
2013
|
-
interface Config<TAgents extends Record<string, Agent<any>> = Record<string, Agent<any>>, TWorkflows extends Record<string, Workflow> = Record<string, Workflow>, TVectors extends Record<string, MastraVector> = Record<string, MastraVector>, TTTS extends Record<string, MastraTTS> = Record<string, MastraTTS>, TLogger extends Logger = Logger> {
|
|
2014
|
-
agents?: TAgents;
|
|
2015
|
-
storage?: MastraStorage;
|
|
2016
|
-
vectors?: TVectors;
|
|
2017
|
-
logger?: TLogger | false;
|
|
2018
|
-
workflows?: TWorkflows;
|
|
2019
|
-
tts?: TTTS;
|
|
2020
|
-
telemetry?: OtelConfig;
|
|
2021
|
-
deployer?: MastraDeployer;
|
|
2022
|
-
/**
|
|
2023
|
-
* Server middleware functions to be applied to API routes
|
|
2024
|
-
* Each middleware can specify a path pattern (defaults to '/api/*')
|
|
2025
|
-
*/
|
|
2026
|
-
serverMiddleware?: Array<{
|
|
2027
|
-
handler: (c: any, next: () => Promise<void>) => Promise<Response | void>;
|
|
2028
|
-
path?: string;
|
|
2029
|
-
}>;
|
|
2030
|
-
memory?: MastraMemory;
|
|
2031
|
-
}
|
|
2032
|
-
declare class Mastra<TAgents extends Record<string, Agent<any>> = Record<string, Agent<any>>, TWorkflows extends Record<string, Workflow> = Record<string, Workflow>, TVectors extends Record<string, MastraVector> = Record<string, MastraVector>, TTTS extends Record<string, MastraTTS> = Record<string, MastraTTS>, TLogger extends Logger = Logger> {
|
|
2033
|
-
#private;
|
|
2034
|
-
/**
|
|
2035
|
-
* @deprecated use getTelemetry() instead
|
|
2036
|
-
*/
|
|
2037
|
-
get telemetry(): Telemetry | undefined;
|
|
2038
|
-
/**
|
|
2039
|
-
* @deprecated use getStorage() instead
|
|
2040
|
-
*/
|
|
2041
|
-
get storage(): MastraStorage | undefined;
|
|
2042
|
-
/**
|
|
2043
|
-
* @deprecated use getMemory() instead
|
|
2044
|
-
*/
|
|
2045
|
-
get memory(): MastraMemory | undefined;
|
|
2046
|
-
constructor(config?: Config<TAgents, TWorkflows, TVectors, TTTS, TLogger>);
|
|
2047
|
-
getAgent<TAgentName extends keyof TAgents>(name: TAgentName): TAgents[TAgentName];
|
|
2048
|
-
getAgents(): TAgents;
|
|
2049
|
-
getVector<TVectorName extends keyof TVectors>(name: TVectorName): TVectors[TVectorName];
|
|
2050
|
-
getVectors(): TVectors | undefined;
|
|
2051
|
-
getDeployer(): MastraDeployer | undefined;
|
|
2052
|
-
getWorkflow<TWorkflowId extends keyof TWorkflows>(id: TWorkflowId, { serialized }?: {
|
|
2053
|
-
serialized?: boolean;
|
|
2054
|
-
}): TWorkflows[TWorkflowId];
|
|
2055
|
-
getWorkflows(props?: {
|
|
2056
|
-
serialized?: boolean;
|
|
2057
|
-
}): Record<string, Workflow>;
|
|
2058
|
-
setStorage(storage: MastraStorage): void;
|
|
2059
|
-
setLogger({ logger }: {
|
|
2060
|
-
logger: TLogger;
|
|
2061
|
-
}): void;
|
|
2062
|
-
setTelemetry(telemetry: OtelConfig): void;
|
|
2063
|
-
getTTS(): TTTS | undefined;
|
|
2064
|
-
getLogger(): TLogger;
|
|
2065
|
-
getTelemetry(): Telemetry | undefined;
|
|
2066
|
-
getMemory(): MastraMemory | undefined;
|
|
2067
|
-
getStorage(): MastraStorage | undefined;
|
|
2068
|
-
getServerMiddleware(): {
|
|
2069
|
-
handler: (c: any, next: () => Promise<void>) => Promise<Response | void>;
|
|
2070
|
-
path: string;
|
|
2071
|
-
}[];
|
|
2072
|
-
getLogsByRunId({ runId, transportId }: {
|
|
2073
|
-
runId: string;
|
|
2074
|
-
transportId: string;
|
|
2075
|
-
}): Promise<BaseLogMessage[] | undefined>;
|
|
2076
|
-
getLogs(transportId: string): Promise<BaseLogMessage[]>;
|
|
2077
|
-
}
|
|
2078
|
-
|
|
2079
|
-
type MastraPrimitives = {
|
|
2080
|
-
logger?: Logger;
|
|
2081
|
-
telemetry?: Telemetry;
|
|
2082
|
-
storage?: MastraStorage;
|
|
2083
|
-
agents?: Record<string, Agent>;
|
|
2084
|
-
tts?: Record<string, MastraTTS>;
|
|
2085
|
-
vectors?: Record<string, MastraVector>;
|
|
2086
|
-
memory?: MastraMemory;
|
|
2087
|
-
};
|
|
2088
|
-
type MastraUnion = {
|
|
2089
|
-
[K in keyof Mastra]: Mastra[K];
|
|
2090
|
-
} & MastraPrimitives;
|
|
2091
|
-
interface IExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undefined> {
|
|
2092
|
-
context: TSchemaIn extends z.ZodSchema ? z.infer<TSchemaIn> : {};
|
|
2093
|
-
runId?: string;
|
|
2094
|
-
threadId?: string;
|
|
2095
|
-
resourceId?: string;
|
|
2096
|
-
}
|
|
2097
|
-
interface IAction<TId extends string, TSchemaIn extends z.ZodSchema | undefined, TSchemaOut extends z.ZodSchema | undefined, TContext extends IExecutionContext<TSchemaIn>, TOptions extends unknown = unknown> {
|
|
2098
|
-
id: TId;
|
|
2099
|
-
description?: string;
|
|
2100
|
-
inputSchema?: TSchemaIn;
|
|
2101
|
-
outputSchema?: TSchemaOut;
|
|
2102
|
-
execute?: (context: TContext, options?: TOptions) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
|
|
2103
|
-
}
|
|
2104
|
-
|
|
2105
|
-
type ToolsInput = Record<string, ToolAction<any, any, any> | VercelTool>;
|
|
2106
|
-
type ToolsetsInput = Record<string, ToolsInput>;
|
|
2107
|
-
type MastraLanguageModel = LanguageModelV1;
|
|
2108
|
-
interface AgentConfig<TTools extends ToolsInput = ToolsInput, TMetrics extends Record<string, Metric> = Record<string, Metric>> {
|
|
2109
|
-
name: string;
|
|
2110
|
-
instructions: string;
|
|
2111
|
-
model: MastraLanguageModel;
|
|
2112
|
-
tools?: TTools;
|
|
2113
|
-
mastra?: Mastra;
|
|
2114
|
-
/** @deprecated This property is deprecated. Use evals instead to add evaluation metrics. */
|
|
2115
|
-
metrics?: TMetrics;
|
|
2116
|
-
evals?: TMetrics;
|
|
2117
|
-
memory?: MastraMemory;
|
|
2118
|
-
voice?: CompositeVoice;
|
|
2119
|
-
}
|
|
2120
|
-
type AgentGenerateOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
2121
|
-
toolsets?: ToolsetsInput;
|
|
2122
|
-
context?: CoreMessage[];
|
|
2123
|
-
memoryOptions?: MemoryConfig;
|
|
2124
|
-
runId?: string;
|
|
2125
|
-
onStepFinish?: (step: string) => void;
|
|
2126
|
-
maxSteps?: number;
|
|
2127
|
-
output?: OutputType | Z;
|
|
2128
|
-
experimental_output?: Z;
|
|
2129
|
-
toolChoice?: 'auto' | 'none' | 'required' | {
|
|
2130
|
-
type: 'tool';
|
|
2131
|
-
toolName: string;
|
|
2132
|
-
};
|
|
2133
|
-
telemetry?: TelemetrySettings;
|
|
2134
|
-
} & ({
|
|
2135
|
-
resourceId?: undefined;
|
|
2136
|
-
threadId?: undefined;
|
|
2137
|
-
} | {
|
|
2138
|
-
resourceId: string;
|
|
2139
|
-
threadId: string;
|
|
2140
|
-
}) & (Z extends undefined ? DefaultLLMTextOptions : DefaultLLMTextObjectOptions);
|
|
2141
|
-
type AgentStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
2142
|
-
toolsets?: ToolsetsInput;
|
|
2143
|
-
context?: CoreMessage[];
|
|
2144
|
-
memoryOptions?: MemoryConfig;
|
|
2145
|
-
runId?: string;
|
|
2146
|
-
onFinish?: (result: string) => unknown;
|
|
2147
|
-
onStepFinish?: (step: string) => unknown;
|
|
2148
|
-
maxSteps?: number;
|
|
2149
|
-
output?: OutputType | Z;
|
|
2150
|
-
temperature?: number;
|
|
2151
|
-
toolChoice?: 'auto' | 'none' | 'required' | {
|
|
2152
|
-
type: 'tool';
|
|
2153
|
-
toolName: string;
|
|
2154
|
-
};
|
|
2155
|
-
experimental_output?: Z;
|
|
2156
|
-
telemetry?: TelemetrySettings;
|
|
2157
|
-
} & ({
|
|
2158
|
-
resourceId?: undefined;
|
|
2159
|
-
threadId?: undefined;
|
|
2160
|
-
} | {
|
|
2161
|
-
resourceId: string;
|
|
2162
|
-
threadId: string;
|
|
2163
|
-
}) & (Z extends undefined ? DefaultLLMStreamOptions : DefaultLLMStreamObjectOptions);
|
|
2164
|
-
type CoreMessage = CoreMessage$1;
|
|
2165
|
-
type BaseStructuredOutputType = 'string' | 'number' | 'boolean' | 'date';
|
|
2166
|
-
type StructuredOutputArrayItem = {
|
|
2167
|
-
type: BaseStructuredOutputType;
|
|
2168
|
-
} | {
|
|
2169
|
-
type: 'object';
|
|
2170
|
-
items: StructuredOutput;
|
|
2171
|
-
};
|
|
2172
|
-
type StructuredOutput = {
|
|
2173
|
-
[key: string]: {
|
|
2174
|
-
type: BaseStructuredOutputType;
|
|
2175
|
-
} | {
|
|
2176
|
-
type: 'object';
|
|
2177
|
-
items: StructuredOutput;
|
|
2178
|
-
} | {
|
|
2179
|
-
type: 'array';
|
|
2180
|
-
items: StructuredOutputArrayItem;
|
|
2181
|
-
};
|
|
2182
|
-
};
|
|
2183
|
-
type GenerateReturn<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = Z extends undefined ? GenerateTextResult<any, Z extends ZodSchema ? z.infer<Z> : unknown> : GenerateObjectResult<Z extends ZodSchema ? z.infer<Z> : unknown>;
|
|
2184
|
-
type StreamReturn<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = Z extends undefined ? StreamTextResult<any, Z extends ZodSchema ? z.infer<Z> : unknown> : StreamObjectResult<any, Z extends ZodSchema ? z.infer<Z> : unknown, any>;
|
|
2185
|
-
type OutputType = StructuredOutput | ZodSchema | JSONSchema7 | undefined;
|
|
2186
|
-
type GenerateTextOptions = Parameters<typeof generateText>[0];
|
|
2187
|
-
type StreamTextOptions = Parameters<typeof streamText>[0];
|
|
2188
|
-
type GenerateObjectOptions = Parameters<typeof generateObject>[0];
|
|
2189
|
-
type StreamObjectOptions = Parameters<typeof streamObject>[0];
|
|
2190
|
-
type MastraCustomLLMOptionsKeys = 'messages' | 'tools' | 'model' | 'onStepFinish' | 'experimental_output' | 'experimental_telemetry' | 'messages' | 'onFinish' | 'output';
|
|
2191
|
-
type DefaultLLMTextOptions = Omit<GenerateTextOptions, MastraCustomLLMOptionsKeys>;
|
|
2192
|
-
type DefaultLLMTextObjectOptions = Omit<GenerateObjectOptions, MastraCustomLLMOptionsKeys>;
|
|
2193
|
-
type DefaultLLMStreamOptions = Omit<StreamTextOptions, MastraCustomLLMOptionsKeys>;
|
|
2194
|
-
type DefaultLLMStreamObjectOptions = Omit<StreamObjectOptions, MastraCustomLLMOptionsKeys>;
|
|
2195
|
-
type MastraCustomLLMOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
2196
|
-
tools?: ToolsInput;
|
|
2197
|
-
convertedTools?: Record<string, CoreTool>;
|
|
2198
|
-
onStepFinish?: (step: string) => void;
|
|
2199
|
-
experimental_output?: Z;
|
|
2200
|
-
telemetry?: TelemetrySettings;
|
|
2201
|
-
threadId?: string;
|
|
2202
|
-
resourceId?: string;
|
|
2203
|
-
} & Run;
|
|
2204
|
-
type LLMTextOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
2205
|
-
messages: CoreMessage[];
|
|
2206
|
-
} & MastraCustomLLMOptions<Z> & DefaultLLMTextOptions;
|
|
2207
|
-
type LLMTextObjectOptions<T extends ZodSchema | JSONSchema7 | undefined = undefined> = LLMTextOptions<T> & DefaultLLMTextObjectOptions & {
|
|
2208
|
-
structuredOutput: JSONSchema7 | z.ZodType<T> | StructuredOutput;
|
|
2209
|
-
};
|
|
2210
|
-
type LLMStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
2211
|
-
output?: OutputType | Z;
|
|
2212
|
-
onFinish?: (result: string) => Promise<void> | void;
|
|
2213
|
-
} & MastraCustomLLMOptions<Z> & DefaultLLMStreamOptions;
|
|
2214
|
-
type LLMInnerStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
2215
|
-
messages: CoreMessage[];
|
|
2216
|
-
onFinish?: (result: string) => Promise<void> | void;
|
|
2217
|
-
} & MastraCustomLLMOptions<Z> & DefaultLLMStreamOptions;
|
|
2218
|
-
type LLMStreamObjectOptions<T extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
2219
|
-
structuredOutput: JSONSchema7 | z.ZodType<T> | StructuredOutput;
|
|
2220
|
-
} & LLMInnerStreamOptions<T> & DefaultLLMStreamObjectOptions;
|
|
2221
|
-
|
|
2222
|
-
declare class MastraLLMBase extends MastraBase {
|
|
2223
|
-
#private;
|
|
2224
|
-
constructor({ name, model }: {
|
|
2225
|
-
name: string;
|
|
2226
|
-
model: LanguageModel;
|
|
2227
|
-
});
|
|
2228
|
-
getProvider(): string;
|
|
2229
|
-
getModelId(): string;
|
|
2230
|
-
getModel(): LanguageModelV1;
|
|
2231
|
-
convertToMessages(messages: string | string[] | CoreMessage$1[]): CoreMessage$1[];
|
|
2232
|
-
__registerPrimitives(p: MastraPrimitives): void;
|
|
2233
|
-
__text<Z extends ZodSchema | JSONSchema7 | undefined>(input: LLMTextOptions<Z>): Promise<GenerateTextResult<any, any>>;
|
|
2234
|
-
__textObject<T extends ZodSchema | JSONSchema7 | undefined>(input: LLMTextObjectOptions<T>): Promise<GenerateObjectResult<T>>;
|
|
2235
|
-
generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options?: LLMStreamOptions<Z>): Promise<GenerateReturn<Z>>;
|
|
2236
|
-
__stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(input: LLMInnerStreamOptions<Z>): Promise<StreamTextResult<any, any>>;
|
|
2237
|
-
__streamObject<T extends ZodSchema | JSONSchema7 | undefined>(input: LLMStreamObjectOptions<T>): Promise<StreamObjectResult<DeepPartial<T>, T, never>>;
|
|
2238
|
-
stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options?: LLMStreamOptions<Z>): Promise<StreamReturn<Z>>;
|
|
2239
|
-
}
|
|
2240
|
-
|
|
2241
|
-
declare class Agent<TTools extends ToolsInput = ToolsInput, TMetrics extends Record<string, Metric> = Record<string, Metric>> extends MastraBase {
|
|
2242
|
-
#private;
|
|
2243
|
-
name: string;
|
|
2244
|
-
readonly llm: MastraLLMBase;
|
|
2245
|
-
instructions: string;
|
|
2246
|
-
readonly model?: MastraLanguageModel;
|
|
2247
|
-
tools: TTools;
|
|
2248
|
-
/** @deprecated This property is deprecated. Use evals instead. */
|
|
2249
|
-
metrics: TMetrics;
|
|
2250
|
-
evals: TMetrics;
|
|
2251
|
-
voice?: CompositeVoice;
|
|
2252
|
-
constructor(config: AgentConfig<TTools, TMetrics>);
|
|
2253
|
-
hasOwnMemory(): boolean;
|
|
2254
|
-
getMemory(): MastraMemory | undefined;
|
|
2255
|
-
__updateInstructions(newInstructions: string): void;
|
|
2256
|
-
__registerPrimitives(p: MastraPrimitives): void;
|
|
2257
|
-
__registerMastra(mastra: Mastra): void;
|
|
2258
|
-
/**
|
|
2259
|
-
* Set the concrete tools for the agent
|
|
2260
|
-
* @param tools
|
|
2261
|
-
*/
|
|
2262
|
-
__setTools(tools: TTools): void;
|
|
2263
|
-
generateTitleFromUserMessage({ message }: {
|
|
2264
|
-
message: CoreUserMessage;
|
|
2265
|
-
}): Promise<string>;
|
|
2266
|
-
getMostRecentUserMessage(messages: Array<CoreMessage$1>): CoreUserMessage | undefined;
|
|
2267
|
-
genTitle(userMessage: CoreUserMessage | undefined): Promise<string>;
|
|
2268
|
-
saveMemory({ threadId, memoryConfig, resourceId, userMessages, runId, }: {
|
|
2269
|
-
resourceId: string;
|
|
2270
|
-
threadId?: string;
|
|
2271
|
-
memoryConfig?: MemoryConfig;
|
|
2272
|
-
userMessages: CoreMessage$1[];
|
|
2273
|
-
time?: Date;
|
|
2274
|
-
keyword?: string;
|
|
2275
|
-
runId?: string;
|
|
2276
|
-
}): Promise<{
|
|
2277
|
-
threadId: string;
|
|
2278
|
-
messages: NonNullable<CoreMessage$1 | null>[];
|
|
2279
|
-
}>;
|
|
2280
|
-
saveResponse({ result, threadId, resourceId, runId, memoryConfig, }: {
|
|
2281
|
-
runId: string;
|
|
2282
|
-
resourceId: string;
|
|
2283
|
-
result: Record<string, any>;
|
|
2284
|
-
threadId: string;
|
|
2285
|
-
memoryConfig: MemoryConfig | undefined;
|
|
2286
|
-
}): Promise<void>;
|
|
2287
|
-
sanitizeResponseMessages(messages: Array<CoreMessage$1>): Array<CoreMessage$1>;
|
|
2288
|
-
convertTools({ toolsets, threadId, resourceId, runId, }: {
|
|
2289
|
-
toolsets?: ToolsetsInput;
|
|
2290
|
-
threadId?: string;
|
|
2291
|
-
resourceId?: string;
|
|
2292
|
-
runId?: string;
|
|
2293
|
-
}): Record<string, CoreTool>;
|
|
2294
|
-
preExecute({ resourceId, runId, threadId, memoryConfig, messages, }: {
|
|
2295
|
-
runId?: string;
|
|
2296
|
-
threadId?: string;
|
|
2297
|
-
memoryConfig?: MemoryConfig;
|
|
2298
|
-
messages: CoreMessage$1[];
|
|
2299
|
-
resourceId: string;
|
|
2300
|
-
}): Promise<{
|
|
2301
|
-
coreMessages: CoreMessage$1[];
|
|
2302
|
-
threadIdToUse: string;
|
|
2303
|
-
}>;
|
|
2304
|
-
__primitive({ messages, context, threadId, memoryConfig, resourceId, runId, toolsets, }: {
|
|
2305
|
-
toolsets?: ToolsetsInput;
|
|
2306
|
-
resourceId?: string;
|
|
2307
|
-
threadId?: string;
|
|
2308
|
-
memoryConfig?: MemoryConfig;
|
|
2309
|
-
context?: CoreMessage$1[];
|
|
2310
|
-
runId?: string;
|
|
2311
|
-
messages: CoreMessage$1[];
|
|
2312
|
-
}): {
|
|
2313
|
-
before: () => Promise<{
|
|
2314
|
-
messageObjects: CoreMessage$1[];
|
|
2315
|
-
convertedTools: Record<string, CoreTool> | undefined;
|
|
2316
|
-
threadId: string;
|
|
2317
|
-
}>;
|
|
2318
|
-
after: ({ result, threadId, memoryConfig, outputText, runId, }: {
|
|
2319
|
-
runId: string;
|
|
2320
|
-
result: Record<string, any>;
|
|
2321
|
-
threadId: string;
|
|
2322
|
-
memoryConfig: MemoryConfig | undefined;
|
|
2323
|
-
outputText: string;
|
|
2324
|
-
}) => Promise<void>;
|
|
2325
|
-
};
|
|
2326
|
-
generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], args?: AgentGenerateOptions<Z> & {
|
|
2327
|
-
output?: never;
|
|
2328
|
-
experimental_output?: never;
|
|
2329
|
-
}): Promise<GenerateTextResult<any, Z extends ZodSchema ? z.infer<Z> : unknown>>;
|
|
2330
|
-
generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], args?: AgentGenerateOptions<Z> & ({
|
|
2331
|
-
output: Z;
|
|
2332
|
-
experimental_output?: never;
|
|
2333
|
-
} | {
|
|
2334
|
-
experimental_output: Z;
|
|
2335
|
-
output?: never;
|
|
2336
|
-
})): Promise<GenerateObjectResult<Z extends ZodSchema ? z.infer<Z> : unknown>>;
|
|
2337
|
-
stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], args?: AgentStreamOptions<Z> & {
|
|
2338
|
-
output?: never;
|
|
2339
|
-
experimental_output?: never;
|
|
2340
|
-
}): Promise<StreamTextResult<any, Z extends ZodSchema ? z.infer<Z> : unknown>>;
|
|
2341
|
-
stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], args?: AgentStreamOptions<Z> & ({
|
|
2342
|
-
output: Z;
|
|
2343
|
-
experimental_output?: never;
|
|
2344
|
-
} | {
|
|
2345
|
-
experimental_output: Z;
|
|
2346
|
-
output?: never;
|
|
2347
|
-
})): Promise<StreamObjectResult<any, Z extends ZodSchema ? z.infer<Z> : unknown, any>>;
|
|
2348
|
-
/**
|
|
2349
|
-
* Convert text to speech using the configured voice provider
|
|
2350
|
-
* @param input Text or text stream to convert to speech
|
|
2351
|
-
* @param options Speech options including speaker and provider-specific options
|
|
2352
|
-
* @returns Audio stream
|
|
2353
|
-
*/
|
|
2354
|
-
speak(input: string | NodeJS.ReadableStream, options?: {
|
|
2355
|
-
speaker?: string;
|
|
2356
|
-
[key: string]: any;
|
|
2357
|
-
}): Promise<NodeJS.ReadableStream>;
|
|
2358
|
-
/**
|
|
2359
|
-
* Convert speech to text using the configured voice provider
|
|
2360
|
-
* @param audioStream Audio stream to transcribe
|
|
2361
|
-
* @param options Provider-specific transcription options
|
|
2362
|
-
* @returns Text or text stream
|
|
2363
|
-
*/
|
|
2364
|
-
listen(audioStream: NodeJS.ReadableStream, options?: {
|
|
2365
|
-
[key: string]: any;
|
|
2366
|
-
}): Promise<string | NodeJS.ReadableStream>;
|
|
2367
|
-
/**
|
|
2368
|
-
* Get a list of available speakers from the configured voice provider
|
|
2369
|
-
* @throws {Error} If no voice provider is configured
|
|
2370
|
-
* @returns {Promise<Array<{voiceId: string}>>} List of available speakers
|
|
2371
|
-
*/
|
|
2372
|
-
getSpeakers(): Promise<{
|
|
2373
|
-
[key: string]: any;
|
|
2374
|
-
voiceId: string;
|
|
2375
|
-
}[]>;
|
|
2376
|
-
}
|
|
2377
|
-
|
|
2378
|
-
interface StorageColumn {
|
|
2379
|
-
type: 'text' | 'timestamp' | 'uuid' | 'jsonb' | 'integer' | 'bigint';
|
|
2380
|
-
primaryKey?: boolean;
|
|
2381
|
-
nullable?: boolean;
|
|
2382
|
-
references?: {
|
|
2383
|
-
table: string;
|
|
2384
|
-
column: string;
|
|
2385
|
-
};
|
|
2386
|
-
}
|
|
2387
|
-
type StorageGetMessagesArg = {
|
|
2388
|
-
threadId: string;
|
|
2389
|
-
resourceId?: string;
|
|
2390
|
-
selectBy?: {
|
|
2391
|
-
vectorSearchString?: string;
|
|
2392
|
-
last?: number | false;
|
|
2393
|
-
include?: {
|
|
2394
|
-
id: string;
|
|
2395
|
-
withPreviousMessages?: number;
|
|
2396
|
-
withNextMessages?: number;
|
|
2397
|
-
}[];
|
|
2398
|
-
};
|
|
2399
|
-
threadConfig?: MemoryConfig;
|
|
2400
|
-
};
|
|
2401
|
-
type EvalRow = {
|
|
2402
|
-
input: string;
|
|
2403
|
-
output: string;
|
|
2404
|
-
result: MetricResult;
|
|
2405
|
-
agentName: string;
|
|
2406
|
-
createdAt: string;
|
|
2407
|
-
metricName: string;
|
|
2408
|
-
instructions: string;
|
|
2409
|
-
runId: string;
|
|
2410
|
-
globalRunId: string;
|
|
2411
|
-
testInfo?: TestInfo;
|
|
2412
|
-
};
|
|
2413
|
-
|
|
2414
|
-
declare const TABLE_WORKFLOW_SNAPSHOT = "mastra_workflow_snapshot";
|
|
2415
|
-
declare const TABLE_EVALS = "mastra_evals";
|
|
2416
|
-
declare const TABLE_MESSAGES = "mastra_messages";
|
|
2417
|
-
declare const TABLE_THREADS = "mastra_threads";
|
|
2418
|
-
declare const TABLE_TRACES = "mastra_traces";
|
|
2419
|
-
type TABLE_NAMES = typeof TABLE_WORKFLOW_SNAPSHOT | typeof TABLE_EVALS | typeof TABLE_MESSAGES | typeof TABLE_THREADS | typeof TABLE_TRACES;
|
|
2420
|
-
|
|
2421
|
-
type MessageType = {
|
|
2422
|
-
id: string;
|
|
2423
|
-
content: UserContent | AssistantContent | ToolContent;
|
|
2424
|
-
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
2425
|
-
createdAt: Date;
|
|
2426
|
-
threadId: string;
|
|
2427
|
-
toolCallIds?: string[];
|
|
2428
|
-
toolCallArgs?: Record<string, unknown>[];
|
|
2429
|
-
toolNames?: string[];
|
|
2430
|
-
type: 'text' | 'tool-call' | 'tool-result';
|
|
2431
|
-
};
|
|
2432
|
-
type StorageThreadType = {
|
|
2433
|
-
id: string;
|
|
2434
|
-
title?: string;
|
|
2435
|
-
resourceId: string;
|
|
2436
|
-
createdAt: Date;
|
|
2437
|
-
updatedAt: Date;
|
|
2438
|
-
metadata?: Record<string, unknown>;
|
|
2439
|
-
};
|
|
2440
|
-
type MemoryConfig = {
|
|
2441
|
-
lastMessages?: number | false;
|
|
2442
|
-
semanticRecall?: boolean | {
|
|
2443
|
-
topK: number;
|
|
2444
|
-
messageRange: number | {
|
|
2445
|
-
before: number;
|
|
2446
|
-
after: number;
|
|
2447
|
-
};
|
|
2448
|
-
};
|
|
2449
|
-
workingMemory?: {
|
|
2450
|
-
enabled: boolean;
|
|
2451
|
-
template?: string;
|
|
2452
|
-
use?: 'text-stream' | 'tool-call';
|
|
2453
|
-
};
|
|
2454
|
-
threads?: {
|
|
2455
|
-
generateTitle?: boolean;
|
|
2456
|
-
};
|
|
2457
|
-
};
|
|
2458
|
-
type SharedMemoryConfig = {
|
|
2459
|
-
storage?: MastraStorage;
|
|
2460
|
-
options?: MemoryConfig;
|
|
2461
|
-
vector?: MastraVector;
|
|
2462
|
-
embedder?: EmbeddingModel<string>;
|
|
2463
|
-
};
|
|
2464
|
-
|
|
2465
|
-
declare abstract class MastraStorage extends MastraBase {
|
|
2466
|
-
/** @deprecated import from { TABLE_WORKFLOW_SNAPSHOT } '@mastra/core/storage' instead */
|
|
2467
|
-
static readonly TABLE_WORKFLOW_SNAPSHOT = "mastra_workflow_snapshot";
|
|
2468
|
-
/** @deprecated import from { TABLE_EVALS } '@mastra/core/storage' instead */
|
|
2469
|
-
static readonly TABLE_EVALS = "mastra_evals";
|
|
2470
|
-
/** @deprecated import from { TABLE_MESSAGES } '@mastra/core/storage' instead */
|
|
2471
|
-
static readonly TABLE_MESSAGES = "mastra_messages";
|
|
2472
|
-
/** @deprecated import from { TABLE_THREADS } '@mastra/core/storage' instead */
|
|
2473
|
-
static readonly TABLE_THREADS = "mastra_threads";
|
|
2474
|
-
/** @deprecated import { TABLE_TRACES } from '@mastra/core/storage' instead */
|
|
2475
|
-
static readonly TABLE_TRACES = "mastra_traces";
|
|
2476
|
-
protected hasInitialized: null | Promise<boolean>;
|
|
2477
|
-
protected shouldCacheInit: boolean;
|
|
2478
|
-
constructor({ name }: {
|
|
2479
|
-
name: string;
|
|
2480
|
-
});
|
|
2481
|
-
abstract createTable({ tableName }: {
|
|
2482
|
-
tableName: TABLE_NAMES;
|
|
2483
|
-
schema: Record<string, StorageColumn>;
|
|
2484
|
-
}): Promise<void>;
|
|
2485
|
-
abstract clearTable({ tableName }: {
|
|
2486
|
-
tableName: TABLE_NAMES;
|
|
2487
|
-
}): Promise<void>;
|
|
2488
|
-
abstract insert({ tableName, record }: {
|
|
2489
|
-
tableName: TABLE_NAMES;
|
|
2490
|
-
record: Record<string, any>;
|
|
2491
|
-
}): Promise<void>;
|
|
2492
|
-
abstract batchInsert({ tableName, records, }: {
|
|
2493
|
-
tableName: TABLE_NAMES;
|
|
2494
|
-
records: Record<string, any>[];
|
|
2495
|
-
}): Promise<void>;
|
|
2496
|
-
__batchInsert({ tableName, records, }: {
|
|
2497
|
-
tableName: TABLE_NAMES;
|
|
2498
|
-
records: Record<string, any>[];
|
|
2499
|
-
}): Promise<void>;
|
|
2500
|
-
abstract load<R>({ tableName, keys }: {
|
|
2501
|
-
tableName: TABLE_NAMES;
|
|
2502
|
-
keys: Record<string, string>;
|
|
2503
|
-
}): Promise<R | null>;
|
|
2504
|
-
abstract getThreadById({ threadId }: {
|
|
2505
|
-
threadId: string;
|
|
2506
|
-
}): Promise<StorageThreadType | null>;
|
|
2507
|
-
__getThreadById({ threadId }: {
|
|
2508
|
-
threadId: string;
|
|
2509
|
-
}): Promise<StorageThreadType | null>;
|
|
2510
|
-
abstract getThreadsByResourceId({ resourceId }: {
|
|
2511
|
-
resourceId: string;
|
|
2512
|
-
}): Promise<StorageThreadType[]>;
|
|
2513
|
-
__getThreadsByResourceId({ resourceId }: {
|
|
2514
|
-
resourceId: string;
|
|
2515
|
-
}): Promise<StorageThreadType[]>;
|
|
2516
|
-
abstract saveThread({ thread }: {
|
|
2517
|
-
thread: StorageThreadType;
|
|
2518
|
-
}): Promise<StorageThreadType>;
|
|
2519
|
-
__saveThread({ thread }: {
|
|
2520
|
-
thread: StorageThreadType;
|
|
2521
|
-
}): Promise<StorageThreadType>;
|
|
2522
|
-
abstract updateThread({ id, title, metadata, }: {
|
|
2523
|
-
id: string;
|
|
2524
|
-
title: string;
|
|
2525
|
-
metadata: Record<string, unknown>;
|
|
2526
|
-
}): Promise<StorageThreadType>;
|
|
2527
|
-
__updateThread({ id, title, metadata, }: {
|
|
2528
|
-
id: string;
|
|
2529
|
-
title: string;
|
|
2530
|
-
metadata: Record<string, unknown>;
|
|
2531
|
-
}): Promise<StorageThreadType>;
|
|
2532
|
-
abstract deleteThread({ threadId }: {
|
|
2533
|
-
threadId: string;
|
|
2534
|
-
}): Promise<void>;
|
|
2535
|
-
__deleteThread({ threadId }: {
|
|
2536
|
-
threadId: string;
|
|
2537
|
-
}): Promise<void>;
|
|
2538
|
-
abstract getMessages({ threadId, selectBy, threadConfig }: StorageGetMessagesArg): Promise<MessageType[]>;
|
|
2539
|
-
__getMessages({ threadId, selectBy, threadConfig }: StorageGetMessagesArg): Promise<MessageType[]>;
|
|
2540
|
-
abstract saveMessages({ messages }: {
|
|
2541
|
-
messages: MessageType[];
|
|
2542
|
-
}): Promise<MessageType[]>;
|
|
2543
|
-
__saveMessages({ messages }: {
|
|
2544
|
-
messages: MessageType[];
|
|
2545
|
-
}): Promise<MessageType[]>;
|
|
2546
|
-
abstract getTraces({ name, scope, page, perPage, attributes, }: {
|
|
2547
|
-
name?: string;
|
|
2548
|
-
scope?: string;
|
|
2549
|
-
page: number;
|
|
2550
|
-
perPage: number;
|
|
2551
|
-
attributes?: Record<string, string>;
|
|
2552
|
-
}): Promise<any[]>;
|
|
2553
|
-
__getTraces({ scope, page, perPage, attributes, }: {
|
|
2554
|
-
scope?: string;
|
|
2555
|
-
page: number;
|
|
2556
|
-
perPage: number;
|
|
2557
|
-
attributes?: Record<string, string>;
|
|
2558
|
-
}): Promise<any[]>;
|
|
2559
|
-
init(): Promise<void>;
|
|
2560
|
-
persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
|
|
2561
|
-
workflowName: string;
|
|
2562
|
-
runId: string;
|
|
2563
|
-
snapshot: WorkflowRunState;
|
|
2564
|
-
}): Promise<void>;
|
|
2565
|
-
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
2566
|
-
workflowName: string;
|
|
2567
|
-
runId: string;
|
|
2568
|
-
}): Promise<WorkflowRunState | null>;
|
|
2569
|
-
abstract getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
2570
|
-
__getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
2571
|
-
}
|
|
2572
|
-
|
|
2573
|
-
declare class Tool<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>, TOptions extends unknown = unknown> implements ToolAction<TSchemaIn, TSchemaOut, TContext, TOptions> {
|
|
2574
|
-
id: string;
|
|
2575
|
-
description: string;
|
|
2576
|
-
inputSchema?: TSchemaIn;
|
|
2577
|
-
outputSchema?: TSchemaOut;
|
|
2578
|
-
execute?: (context: TContext, options?: TOptions) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
|
|
2579
|
-
mastra?: Mastra;
|
|
2580
|
-
constructor(opts: ToolAction<TSchemaIn, TSchemaOut, TContext>);
|
|
2581
|
-
}
|
|
2582
|
-
|
|
2583
|
-
declare const executeTool: (config: FreestyleExecuteScriptParamsConfiguration & {
|
|
2584
|
-
apiKey: string;
|
|
2585
|
-
}) => Tool<z.ZodObject<{
|
|
2586
|
-
script: z.ZodString;
|
|
2587
|
-
}, "strip", z.ZodTypeAny, {
|
|
2588
|
-
script?: string;
|
|
2589
|
-
}, {
|
|
2590
|
-
script?: string;
|
|
2591
|
-
}>, z.ZodObject<{
|
|
2592
|
-
logs: z.ZodArray<z.ZodObject<{
|
|
2593
|
-
message: z.ZodString;
|
|
2594
|
-
type: z.ZodString;
|
|
2595
|
-
}, "strip", z.ZodTypeAny, {
|
|
2596
|
-
message?: string;
|
|
2597
|
-
type?: string;
|
|
2598
|
-
}, {
|
|
2599
|
-
message?: string;
|
|
2600
|
-
type?: string;
|
|
2601
|
-
}>, "many">;
|
|
2602
|
-
result: z.ZodUnknown;
|
|
2603
|
-
}, "strip", z.ZodTypeAny, {
|
|
2604
|
-
logs?: {
|
|
2605
|
-
message?: string;
|
|
2606
|
-
type?: string;
|
|
2607
|
-
}[];
|
|
2608
|
-
result?: unknown;
|
|
2609
|
-
}, {
|
|
2610
|
-
logs?: {
|
|
2611
|
-
message?: string;
|
|
2612
|
-
type?: string;
|
|
2613
|
-
}[];
|
|
2614
|
-
result?: unknown;
|
|
2615
|
-
}>, ToolExecutionContext<z.ZodObject<{
|
|
2616
|
-
script: z.ZodString;
|
|
2617
|
-
}, "strip", z.ZodTypeAny, {
|
|
2618
|
-
script?: string;
|
|
2619
|
-
}, {
|
|
2620
|
-
script?: string;
|
|
2621
|
-
}>>, unknown>;
|
|
2622
|
-
|
|
2623
|
-
export { executeTool };
|