@mastra/server 0.0.1-alpha.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/LICENSE +44 -0
- package/README.md +159 -0
- package/dist/_tsup-dts-rollup.d.cts +592 -0
- package/dist/_tsup-dts-rollup.d.ts +592 -0
- package/dist/chunk-2FJURXCL.cjs +213 -0
- package/dist/chunk-2JQC6JWP.js +46 -0
- package/dist/chunk-2YONKUWB.js +117 -0
- package/dist/chunk-3AHQ5RGN.js +11 -0
- package/dist/chunk-3RVHWGWO.js +95 -0
- package/dist/chunk-4C3EPMMF.cjs +122 -0
- package/dist/chunk-4JINXASC.js +120 -0
- package/dist/chunk-5JOF627H.cjs +123 -0
- package/dist/chunk-5MCUD7TP.js +142 -0
- package/dist/chunk-5WF7YIIE.cjs +150 -0
- package/dist/chunk-A4DCRMIV.js +125 -0
- package/dist/chunk-A7DF4ETD.cjs +100 -0
- package/dist/chunk-FV45V6WC.cjs +43 -0
- package/dist/chunk-L7XE5QTW.js +16 -0
- package/dist/chunk-M56ECCHK.cjs +128 -0
- package/dist/chunk-QH6XWSXP.cjs +5579 -0
- package/dist/chunk-QN4KF3BH.cjs +18 -0
- package/dist/chunk-RBQASTUP.js +203 -0
- package/dist/chunk-S6GTZWMY.js +275 -0
- package/dist/chunk-SKKC3EDG.cjs +286 -0
- package/dist/chunk-TRDNDNGQ.js +40 -0
- package/dist/chunk-VB7KH62D.cjs +51 -0
- package/dist/chunk-VK6FX47H.js +5576 -0
- package/dist/chunk-YCJ2OJTL.cjs +129 -0
- package/dist/chunk-YNSGUC2O.js +116 -0
- package/dist/chunk-ZLBRQFDD.cjs +13 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/server/handlers/agents.cjs +30 -0
- package/dist/server/handlers/agents.d.cts +6 -0
- package/dist/server/handlers/agents.d.ts +6 -0
- package/dist/server/handlers/agents.js +1 -0
- package/dist/server/handlers/error.cjs +10 -0
- package/dist/server/handlers/error.d.cts +1 -0
- package/dist/server/handlers/error.d.ts +1 -0
- package/dist/server/handlers/error.js +1 -0
- package/dist/server/handlers/logs.cjs +18 -0
- package/dist/server/handlers/logs.d.cts +3 -0
- package/dist/server/handlers/logs.d.ts +3 -0
- package/dist/server/handlers/logs.js +1 -0
- package/dist/server/handlers/memory.cjs +38 -0
- package/dist/server/handlers/memory.d.cts +8 -0
- package/dist/server/handlers/memory.d.ts +8 -0
- package/dist/server/handlers/memory.js +1 -0
- package/dist/server/handlers/network.cjs +22 -0
- package/dist/server/handlers/network.d.cts +4 -0
- package/dist/server/handlers/network.d.ts +4 -0
- package/dist/server/handlers/network.js +1 -0
- package/dist/server/handlers/telemetry.cjs +14 -0
- package/dist/server/handlers/telemetry.d.cts +2 -0
- package/dist/server/handlers/telemetry.d.ts +2 -0
- package/dist/server/handlers/telemetry.js +1 -0
- package/dist/server/handlers/tools.cjs +22 -0
- package/dist/server/handlers/tools.d.cts +4 -0
- package/dist/server/handlers/tools.d.ts +4 -0
- package/dist/server/handlers/tools.js +1 -0
- package/dist/server/handlers/utils.cjs +10 -0
- package/dist/server/handlers/utils.d.cts +1 -0
- package/dist/server/handlers/utils.d.ts +1 -0
- package/dist/server/handlers/utils.js +1 -0
- package/dist/server/handlers/vector.cjs +30 -0
- package/dist/server/handlers/vector.d.cts +6 -0
- package/dist/server/handlers/vector.d.ts +6 -0
- package/dist/server/handlers/vector.js +1 -0
- package/dist/server/handlers/voice.cjs +18 -0
- package/dist/server/handlers/voice.d.cts +3 -0
- package/dist/server/handlers/voice.d.ts +3 -0
- package/dist/server/handlers/voice.js +1 -0
- package/dist/server/handlers/workflows.cjs +42 -0
- package/dist/server/handlers/workflows.d.cts +9 -0
- package/dist/server/handlers/workflows.d.ts +9 -0
- package/dist/server/handlers/workflows.js +1 -0
- package/dist/server/handlers.cjs +50 -0
- package/dist/server/handlers.d.cts +9 -0
- package/dist/server/handlers.d.ts +9 -0
- package/dist/server/handlers.js +9 -0
- package/package.json +71 -0
|
@@ -0,0 +1,592 @@
|
|
|
1
|
+
import type { Agent } from '@mastra/core/agent';
|
|
2
|
+
import type { AgentNetwork } from '@mastra/core/network';
|
|
3
|
+
import { BaseLogMessage } from '@mastra/core';
|
|
4
|
+
import { CoreMessage } from 'ai';
|
|
5
|
+
import { EvalRow } from '@mastra/core';
|
|
6
|
+
import { GenerateObjectResult } from 'ai';
|
|
7
|
+
import { GenerateTextResult } from 'ai';
|
|
8
|
+
import type { Mastra } from '@mastra/core/mastra';
|
|
9
|
+
import type { Mastra as Mastra_2 } from '@mastra/core';
|
|
10
|
+
import type { MastraMemory } from '@mastra/core/memory';
|
|
11
|
+
import { Message } from 'ai';
|
|
12
|
+
import { MessageType } from '@mastra/core';
|
|
13
|
+
import type { QueryResult } from '@mastra/core/vector';
|
|
14
|
+
import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
|
|
15
|
+
import { Step } from '@mastra/core';
|
|
16
|
+
import { StepExecutionContext } from '@mastra/core';
|
|
17
|
+
import { StepGraph } from '@mastra/core';
|
|
18
|
+
import { StorageThreadType } from '@mastra/core';
|
|
19
|
+
import type { ToolAction } from '@mastra/core/tools';
|
|
20
|
+
import type { VercelTool } from '@mastra/core/tools';
|
|
21
|
+
import type { Workflow } from '@mastra/core/workflows';
|
|
22
|
+
import { WorkflowContext as WorkflowContext_2 } from '@mastra/core';
|
|
23
|
+
import { WorkflowRunResult } from '@mastra/core';
|
|
24
|
+
|
|
25
|
+
export declare namespace agents {
|
|
26
|
+
export {
|
|
27
|
+
getAgentsHandler,
|
|
28
|
+
getAgentByIdHandler,
|
|
29
|
+
getEvalsByAgentIdHandler,
|
|
30
|
+
getLiveEvalsByAgentIdHandler,
|
|
31
|
+
generateHandler,
|
|
32
|
+
streamGenerateHandler
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export declare interface ApiError extends Error {
|
|
37
|
+
message: string;
|
|
38
|
+
status?: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare type ClientErrorStatusCode = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451;
|
|
42
|
+
|
|
43
|
+
export declare interface Context {
|
|
44
|
+
mastra: Mastra;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export declare function createIndex({ mastra, vectorName, index, }: Pick<VectorContext, 'mastra' | 'vectorName'> & {
|
|
48
|
+
index: CreateIndexRequest;
|
|
49
|
+
}): Promise<{
|
|
50
|
+
success: boolean;
|
|
51
|
+
}>;
|
|
52
|
+
|
|
53
|
+
declare interface CreateIndexRequest {
|
|
54
|
+
indexName: string;
|
|
55
|
+
dimension: number;
|
|
56
|
+
metric?: 'cosine' | 'euclidean' | 'dotproduct';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export declare function createRunHandler({ mastra, workflowId, runId: prevRunId, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<{
|
|
60
|
+
runId: string;
|
|
61
|
+
}>;
|
|
62
|
+
|
|
63
|
+
export declare function createThreadHandler({ mastra, agentId, body, }: Pick<MemoryContext, 'mastra' | 'agentId'> & {
|
|
64
|
+
body?: Omit<Parameters<MastraMemory['createThread']>[0], 'resourceId'> & {
|
|
65
|
+
resourceId?: string;
|
|
66
|
+
};
|
|
67
|
+
}): Promise<StorageThreadType>;
|
|
68
|
+
|
|
69
|
+
export declare function deleteIndex({ mastra, vectorName, indexName, }: Pick<VectorContext, 'mastra' | 'vectorName'> & {
|
|
70
|
+
indexName?: string;
|
|
71
|
+
}): Promise<{
|
|
72
|
+
success: boolean;
|
|
73
|
+
}>;
|
|
74
|
+
|
|
75
|
+
export declare function deleteThreadHandler({ mastra, agentId, threadId, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'>): Promise<{
|
|
76
|
+
result: string;
|
|
77
|
+
}>;
|
|
78
|
+
|
|
79
|
+
declare type DeprecatedStatusCode = 305 | 306;
|
|
80
|
+
|
|
81
|
+
export declare function describeIndex({ mastra, vectorName, indexName, }: Pick<VectorContext, 'mastra' | 'vectorName'> & {
|
|
82
|
+
indexName?: string;
|
|
83
|
+
}): Promise<{
|
|
84
|
+
dimension: number;
|
|
85
|
+
count: number;
|
|
86
|
+
metric: string | undefined;
|
|
87
|
+
}>;
|
|
88
|
+
|
|
89
|
+
export declare function executeAgentToolHandler({ mastra, agentId, toolId, data, }: Pick<ToolsContext, 'mastra' | 'toolId'> & {
|
|
90
|
+
agentId?: string;
|
|
91
|
+
data: any;
|
|
92
|
+
}): Promise<any>;
|
|
93
|
+
|
|
94
|
+
export declare function executeToolHandler(tools: ToolsContext['tools']): ({ mastra, runId, toolId, data, }: Pick<ToolsContext, "mastra" | "toolId" | "runId"> & {
|
|
95
|
+
data?: unknown;
|
|
96
|
+
}) => Promise<any>;
|
|
97
|
+
|
|
98
|
+
export declare function generateHandler({ mastra, agentId, body, }: Context & {
|
|
99
|
+
agentId: string;
|
|
100
|
+
body: GetBody<'generate'>;
|
|
101
|
+
}): Promise<GenerateTextResult<any, any>>;
|
|
102
|
+
|
|
103
|
+
export declare function generateHandler_alias_1({ mastra, networkId, body, }: NetworkContext & {
|
|
104
|
+
body: {
|
|
105
|
+
messages?: Parameters<AgentNetwork['generate']>[0];
|
|
106
|
+
} & Parameters<AgentNetwork['generate']>[1];
|
|
107
|
+
}): Promise<GenerateObjectResult<any>>;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Generate speech from text
|
|
111
|
+
*/
|
|
112
|
+
export declare function generateSpeechHandler({ mastra, agentId, body, }: VoiceContext & {
|
|
113
|
+
body?: {
|
|
114
|
+
text?: string;
|
|
115
|
+
speakerId?: string;
|
|
116
|
+
};
|
|
117
|
+
}): Promise<{
|
|
118
|
+
audioData: Buffer<ArrayBuffer>;
|
|
119
|
+
}>;
|
|
120
|
+
|
|
121
|
+
export declare function getAgentByIdHandler({ mastra, agentId }: Context & {
|
|
122
|
+
agentId: string;
|
|
123
|
+
}): Promise<{
|
|
124
|
+
name: any;
|
|
125
|
+
instructions: string;
|
|
126
|
+
tools: any;
|
|
127
|
+
provider: string;
|
|
128
|
+
modelId: string;
|
|
129
|
+
}>;
|
|
130
|
+
|
|
131
|
+
export declare function getAgentsHandler({ mastra }: Context): Promise<any>;
|
|
132
|
+
|
|
133
|
+
declare type GetBody<T extends keyof Agent & {
|
|
134
|
+
[K in keyof Agent]: Agent[K] extends (...args: any) => any ? K : never;
|
|
135
|
+
}[keyof Agent]> = {
|
|
136
|
+
messages: Parameters<Agent[T]>[0];
|
|
137
|
+
} & Parameters<Agent[T]>[1];
|
|
138
|
+
|
|
139
|
+
export declare function getEvalsByAgentIdHandler({ mastra, agentId }: Context & {
|
|
140
|
+
agentId: string;
|
|
141
|
+
}): Promise<{
|
|
142
|
+
id: string;
|
|
143
|
+
name: any;
|
|
144
|
+
instructions: string;
|
|
145
|
+
evals: EvalRow[];
|
|
146
|
+
}>;
|
|
147
|
+
|
|
148
|
+
export declare function getLiveEvalsByAgentIdHandler({ mastra, agentId }: Context & {
|
|
149
|
+
agentId: string;
|
|
150
|
+
}): Promise<{
|
|
151
|
+
id: string;
|
|
152
|
+
name: any;
|
|
153
|
+
instructions: string;
|
|
154
|
+
evals: EvalRow[];
|
|
155
|
+
}>;
|
|
156
|
+
|
|
157
|
+
export declare function getLogsByRunIdHandler({ mastra, runId, transportId, }: Pick<LogsContext, 'mastra' | 'runId' | 'transportId'>): Promise<BaseLogMessage[] | undefined>;
|
|
158
|
+
|
|
159
|
+
export declare function getLogsHandler({ mastra, transportId }: Pick<LogsContext, 'mastra' | 'transportId'>): Promise<BaseLogMessage[]>;
|
|
160
|
+
|
|
161
|
+
export declare function getLogTransports({ mastra }: Pick<LogsContext, 'mastra'>): Promise<{
|
|
162
|
+
transports: string[];
|
|
163
|
+
}>;
|
|
164
|
+
|
|
165
|
+
export declare function getMemoryStatusHandler({ mastra, agentId }: Pick<MemoryContext, 'mastra' | 'agentId'>): Promise<{
|
|
166
|
+
result: boolean;
|
|
167
|
+
}>;
|
|
168
|
+
|
|
169
|
+
export declare function getMessagesHandler({ mastra, agentId, threadId, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'>): Promise<{
|
|
170
|
+
messages: CoreMessage[];
|
|
171
|
+
uiMessages: Message[];
|
|
172
|
+
}>;
|
|
173
|
+
|
|
174
|
+
export declare function getNetworkByIdHandler({ mastra, networkId }: Pick<NetworkContext, 'mastra' | 'networkId'>): Promise<{
|
|
175
|
+
id: string;
|
|
176
|
+
name: string;
|
|
177
|
+
instructions: string;
|
|
178
|
+
agents: {
|
|
179
|
+
name: string;
|
|
180
|
+
provider: string;
|
|
181
|
+
modelId: string;
|
|
182
|
+
}[];
|
|
183
|
+
routingModel: {
|
|
184
|
+
provider: string;
|
|
185
|
+
modelId: string;
|
|
186
|
+
};
|
|
187
|
+
}>;
|
|
188
|
+
|
|
189
|
+
export declare function getNetworksHandler({ mastra }: Pick<NetworkContext, 'mastra'>): Promise<{
|
|
190
|
+
id: string;
|
|
191
|
+
name: string;
|
|
192
|
+
instructions: string;
|
|
193
|
+
agents: {
|
|
194
|
+
name: string;
|
|
195
|
+
provider: string;
|
|
196
|
+
modelId: string;
|
|
197
|
+
}[];
|
|
198
|
+
routingModel: {
|
|
199
|
+
provider: string;
|
|
200
|
+
modelId: string;
|
|
201
|
+
};
|
|
202
|
+
}[]>;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Get available speakers for an agent
|
|
206
|
+
*/
|
|
207
|
+
export declare function getSpeakersHandler({ mastra, agentId }: VoiceContext): Promise<{
|
|
208
|
+
voiceId: string;
|
|
209
|
+
}[]>;
|
|
210
|
+
|
|
211
|
+
export declare function getTelemetryHandler({ mastra, body }: TelemetryContext): Promise<{
|
|
212
|
+
traces: any[];
|
|
213
|
+
}>;
|
|
214
|
+
|
|
215
|
+
export declare function getThreadByIdHandler({ mastra, agentId, threadId, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'>): Promise<StorageThreadType>;
|
|
216
|
+
|
|
217
|
+
export declare function getThreadsHandler({ mastra, agentId, resourceId, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'resourceId'>): Promise<StorageThreadType[]>;
|
|
218
|
+
|
|
219
|
+
export declare function getToolByIdHandler({ tools, toolId }: Pick<ToolsContext, 'tools' | 'toolId'>): Promise<any>;
|
|
220
|
+
|
|
221
|
+
export declare function getToolsHandler({ tools }: Pick<ToolsContext, 'tools'>): Promise<Record<string, any>>;
|
|
222
|
+
|
|
223
|
+
export declare function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext): Promise<{
|
|
224
|
+
stepGraph: StepGraph;
|
|
225
|
+
stepSubscriberGraph: Record<string, StepGraph>;
|
|
226
|
+
serializedStepGraph: StepGraph;
|
|
227
|
+
serializedStepSubscriberGraph: Record<string, StepGraph>;
|
|
228
|
+
name: string;
|
|
229
|
+
triggerSchema: string | undefined;
|
|
230
|
+
steps: any;
|
|
231
|
+
}>;
|
|
232
|
+
|
|
233
|
+
export declare function getWorkflowRunHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<Workflow['getRun']>>;
|
|
234
|
+
|
|
235
|
+
export declare function getWorkflowsHandler({ mastra }: WorkflowContext): Promise<any>;
|
|
236
|
+
|
|
237
|
+
export declare function handleError(error: unknown, defaultMessage: string): never;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* `HTTPException` must be used when a fatal error such as authentication failure occurs.
|
|
241
|
+
*
|
|
242
|
+
* @see {@link https://hono.dev/docs/api/exception}
|
|
243
|
+
*
|
|
244
|
+
* @param {StatusCode} status - status code of HTTPException
|
|
245
|
+
* @param {HTTPExceptionOptions} options - options of HTTPException
|
|
246
|
+
* @param {HTTPExceptionOptions["res"]} options.res - response of options of HTTPException
|
|
247
|
+
* @param {HTTPExceptionOptions["message"]} options.message - message of options of HTTPException
|
|
248
|
+
* @param {HTTPExceptionOptions["cause"]} options.cause - cause of options of HTTPException
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```ts
|
|
252
|
+
* import { HTTPException } from 'hono/http-exception'
|
|
253
|
+
*
|
|
254
|
+
* // ...
|
|
255
|
+
*
|
|
256
|
+
* app.post('/auth', async (c, next) => {
|
|
257
|
+
* // authentication
|
|
258
|
+
* if (authorized === false) {
|
|
259
|
+
* throw new HTTPException(401, { message: 'Custom error message' })
|
|
260
|
+
* }
|
|
261
|
+
* await next()
|
|
262
|
+
* })
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
export declare class HTTPException extends Error {
|
|
266
|
+
readonly res?: Response;
|
|
267
|
+
readonly status: StatusCode;
|
|
268
|
+
/**
|
|
269
|
+
* Creates an instance of `HTTPException`.
|
|
270
|
+
* @param status - HTTP status code for the exception. Defaults to 500.
|
|
271
|
+
* @param options - Additional options for the exception.
|
|
272
|
+
*/
|
|
273
|
+
constructor(status?: StatusCode, options?: HTTPExceptionOptions);
|
|
274
|
+
/**
|
|
275
|
+
* Returns the response object associated with the exception.
|
|
276
|
+
* If a response object is not provided, a new response is created with the error message and status code.
|
|
277
|
+
* @returns The response object.
|
|
278
|
+
*/
|
|
279
|
+
getResponse(): Response;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Options for creating an `HTTPException`.
|
|
284
|
+
* @property res - Optional response object to use.
|
|
285
|
+
* @property message - Optional custom error message.
|
|
286
|
+
* @property cause - Optional cause of the error.
|
|
287
|
+
*/
|
|
288
|
+
declare type HTTPExceptionOptions = {
|
|
289
|
+
res?: Response;
|
|
290
|
+
message?: string;
|
|
291
|
+
cause?: unknown;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* @module
|
|
296
|
+
* This module provides the `HTTPException` class.
|
|
297
|
+
*/
|
|
298
|
+
declare type InfoStatusCode = 100 | 101 | 102 | 103;
|
|
299
|
+
|
|
300
|
+
export declare function listIndexes({ mastra, vectorName }: Pick<VectorContext, 'mastra' | 'vectorName'>): Promise<string[]>;
|
|
301
|
+
|
|
302
|
+
export declare namespace logs {
|
|
303
|
+
export {
|
|
304
|
+
getLogsHandler,
|
|
305
|
+
getLogsByRunIdHandler,
|
|
306
|
+
getLogTransports
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
declare type LogsContext = {
|
|
311
|
+
mastra: Mastra;
|
|
312
|
+
transportId?: string;
|
|
313
|
+
runId?: string;
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
export declare namespace memory {
|
|
317
|
+
export {
|
|
318
|
+
getMemoryStatusHandler,
|
|
319
|
+
getThreadsHandler,
|
|
320
|
+
getThreadByIdHandler,
|
|
321
|
+
saveMessagesHandler,
|
|
322
|
+
createThreadHandler,
|
|
323
|
+
updateThreadHandler,
|
|
324
|
+
deleteThreadHandler,
|
|
325
|
+
getMessagesHandler
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
declare interface MemoryContext extends Context {
|
|
330
|
+
agentId?: string;
|
|
331
|
+
resourceId?: string;
|
|
332
|
+
threadId?: string;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export declare namespace network {
|
|
336
|
+
export {
|
|
337
|
+
getNetworksHandler,
|
|
338
|
+
getNetworkByIdHandler,
|
|
339
|
+
generateHandler_alias_1 as generateHandler,
|
|
340
|
+
streamGenerateHandler_alias_1 as streamGenerateHandler
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
declare interface NetworkContext extends Context {
|
|
345
|
+
networkId?: string;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
declare interface QueryRequest {
|
|
349
|
+
indexName: string;
|
|
350
|
+
queryVector: number[];
|
|
351
|
+
topK?: number;
|
|
352
|
+
filter?: Record<string, any>;
|
|
353
|
+
includeVector?: boolean;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export declare function queryVectors({ mastra, vectorName, query, }: Pick<VectorContext, 'mastra' | 'vectorName'> & {
|
|
357
|
+
query: QueryRequest;
|
|
358
|
+
}): Promise<QueryResult[]>;
|
|
359
|
+
|
|
360
|
+
declare type RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308;
|
|
361
|
+
|
|
362
|
+
export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, }: WorkflowContext & {
|
|
363
|
+
body: {
|
|
364
|
+
stepId: string;
|
|
365
|
+
context: any;
|
|
366
|
+
};
|
|
367
|
+
}): Promise<Omit<WorkflowRunResult<any, Step<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, Step<string, any, any, any>[], Record<string, any>>>>[], any>, "runId"> | undefined>;
|
|
368
|
+
|
|
369
|
+
export declare function resumeWorkflowHandler({ mastra, workflowId, runId, body, }: WorkflowContext & {
|
|
370
|
+
body: {
|
|
371
|
+
stepId: string;
|
|
372
|
+
context: any;
|
|
373
|
+
};
|
|
374
|
+
}): Promise<{
|
|
375
|
+
message: string;
|
|
376
|
+
}>;
|
|
377
|
+
|
|
378
|
+
export declare function saveMessagesHandler({ mastra, agentId, body, }: Pick<MemoryContext, 'mastra' | 'agentId'> & {
|
|
379
|
+
body: {
|
|
380
|
+
messages: Parameters<MastraMemory['saveMessages']>[0]['messages'];
|
|
381
|
+
};
|
|
382
|
+
}): Promise<MessageType[]>;
|
|
383
|
+
|
|
384
|
+
declare type ServerErrorStatusCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
|
|
385
|
+
|
|
386
|
+
export declare function startAsyncWorkflowHandler({ mastra, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
|
|
387
|
+
triggerData?: unknown;
|
|
388
|
+
}): Promise<{
|
|
389
|
+
runId: string;
|
|
390
|
+
timestamp: number;
|
|
391
|
+
result?: any;
|
|
392
|
+
results: {
|
|
393
|
+
[x: string]: {
|
|
394
|
+
status: "failed";
|
|
395
|
+
error: string;
|
|
396
|
+
} | {
|
|
397
|
+
status: "waiting";
|
|
398
|
+
} | {
|
|
399
|
+
status: "skipped";
|
|
400
|
+
} | {
|
|
401
|
+
status: "success";
|
|
402
|
+
output: unknown;
|
|
403
|
+
} | {
|
|
404
|
+
status: "suspended";
|
|
405
|
+
suspendPayload?: any;
|
|
406
|
+
output?: unknown;
|
|
407
|
+
} | {
|
|
408
|
+
status: "success";
|
|
409
|
+
output: any;
|
|
410
|
+
} | {
|
|
411
|
+
status: "suspended";
|
|
412
|
+
suspendPayload?: any;
|
|
413
|
+
output?: any;
|
|
414
|
+
};
|
|
415
|
+
};
|
|
416
|
+
triggerData?: any;
|
|
417
|
+
activePaths: Map<string, {
|
|
418
|
+
status: string;
|
|
419
|
+
suspendPayload?: any;
|
|
420
|
+
stepPath: string[];
|
|
421
|
+
}>;
|
|
422
|
+
}>;
|
|
423
|
+
|
|
424
|
+
export declare function startWorkflowRunHandler({ mastra, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
|
|
425
|
+
triggerData?: unknown;
|
|
426
|
+
}): Promise<{
|
|
427
|
+
message: string;
|
|
428
|
+
}>;
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* If you want to use an unofficial status, use `UnofficialStatusCode`.
|
|
432
|
+
*/
|
|
433
|
+
export declare type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode | UnofficialStatusCode;
|
|
434
|
+
|
|
435
|
+
export declare function storeTelemetryHandler({ mastra, body }: Context & {
|
|
436
|
+
body: {
|
|
437
|
+
resourceSpans: any[];
|
|
438
|
+
};
|
|
439
|
+
}): Promise<{
|
|
440
|
+
status: string;
|
|
441
|
+
message: string;
|
|
442
|
+
traceCount: number;
|
|
443
|
+
} | {
|
|
444
|
+
status: string;
|
|
445
|
+
message: string;
|
|
446
|
+
error: any;
|
|
447
|
+
}>;
|
|
448
|
+
|
|
449
|
+
export declare function streamGenerateHandler({ mastra, agentId, body, }: Context & {
|
|
450
|
+
agentId: string;
|
|
451
|
+
body: GetBody<'stream'>;
|
|
452
|
+
}): Promise<Response | undefined>;
|
|
453
|
+
|
|
454
|
+
export declare function streamGenerateHandler_alias_1({ mastra, networkId, body, }: NetworkContext & {
|
|
455
|
+
body: {
|
|
456
|
+
messages?: Parameters<AgentNetwork['stream']>[0];
|
|
457
|
+
} & Parameters<AgentNetwork['stream']>[1];
|
|
458
|
+
}): Promise<Response>;
|
|
459
|
+
|
|
460
|
+
declare type SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226;
|
|
461
|
+
|
|
462
|
+
export declare namespace telemetry {
|
|
463
|
+
export {
|
|
464
|
+
getTelemetryHandler,
|
|
465
|
+
storeTelemetryHandler
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
declare interface TelemetryContext extends Context {
|
|
470
|
+
body?: {
|
|
471
|
+
name?: string;
|
|
472
|
+
scope?: string;
|
|
473
|
+
page?: number;
|
|
474
|
+
perPage?: number;
|
|
475
|
+
attribute?: string | string[];
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
export declare namespace tools {
|
|
480
|
+
export {
|
|
481
|
+
getToolsHandler,
|
|
482
|
+
getToolByIdHandler,
|
|
483
|
+
executeToolHandler,
|
|
484
|
+
executeAgentToolHandler
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
declare interface ToolsContext extends Context {
|
|
489
|
+
tools?: Record<string, ToolAction | VercelTool>;
|
|
490
|
+
toolId?: string;
|
|
491
|
+
runId?: string;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Transcribe speech to text
|
|
496
|
+
*/
|
|
497
|
+
export declare function transcribeSpeechHandler({ mastra, agentId, body, }: VoiceContext & {
|
|
498
|
+
body?: {
|
|
499
|
+
audioData?: Buffer;
|
|
500
|
+
options?: Parameters<NonNullable<Agent['voice']>['listen']>[1];
|
|
501
|
+
};
|
|
502
|
+
}): Promise<{
|
|
503
|
+
text: string | void | NodeJS.ReadableStream;
|
|
504
|
+
}>;
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* @deprecated
|
|
508
|
+
* Use `UnofficialStatusCode` instead.
|
|
509
|
+
*/
|
|
510
|
+
export declare type UnOfficalStatusCode = UnofficialStatusCode;
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* `UnofficialStatusCode` can be used to specify an unofficial status code.
|
|
514
|
+
* @example
|
|
515
|
+
*
|
|
516
|
+
* ```ts
|
|
517
|
+
* app.get('/unknown', (c) => {
|
|
518
|
+
* return c.text("Unknown Error", 520 as UnofficialStatusCode)
|
|
519
|
+
* })
|
|
520
|
+
* ```
|
|
521
|
+
*/
|
|
522
|
+
export declare type UnofficialStatusCode = -1;
|
|
523
|
+
|
|
524
|
+
export declare function updateThreadHandler({ mastra, agentId, threadId, body, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'> & {
|
|
525
|
+
body?: Parameters<MastraMemory['saveThread']>[0]['thread'];
|
|
526
|
+
}): Promise<StorageThreadType>;
|
|
527
|
+
|
|
528
|
+
declare interface UpsertRequest {
|
|
529
|
+
indexName: string;
|
|
530
|
+
vectors: number[][];
|
|
531
|
+
metadata?: Record<string, any>[];
|
|
532
|
+
ids?: string[];
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
export declare function upsertVectors({ mastra, vectorName, index }: VectorContext & {
|
|
536
|
+
index: UpsertRequest;
|
|
537
|
+
}): Promise<{
|
|
538
|
+
ids: string[];
|
|
539
|
+
}>;
|
|
540
|
+
|
|
541
|
+
export declare function validateBody(body: Record<string, unknown>): void;
|
|
542
|
+
|
|
543
|
+
export declare namespace vector {
|
|
544
|
+
export {
|
|
545
|
+
upsertVectors,
|
|
546
|
+
createIndex,
|
|
547
|
+
queryVectors,
|
|
548
|
+
listIndexes,
|
|
549
|
+
describeIndex,
|
|
550
|
+
deleteIndex
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
declare interface VectorContext extends Context {
|
|
555
|
+
vectorName?: string;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
export declare namespace voice {
|
|
559
|
+
export {
|
|
560
|
+
getSpeakersHandler,
|
|
561
|
+
generateSpeechHandler,
|
|
562
|
+
transcribeSpeechHandler
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
declare interface VoiceContext extends Context {
|
|
567
|
+
agentId?: string;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
export declare function watchWorkflowHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReadableStream_2<string>>;
|
|
571
|
+
|
|
572
|
+
declare interface WorkflowContext {
|
|
573
|
+
mastra: Mastra_2;
|
|
574
|
+
workflowId?: string;
|
|
575
|
+
runId?: string;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
export declare namespace workflows {
|
|
579
|
+
export {
|
|
580
|
+
getWorkflowsHandler,
|
|
581
|
+
getWorkflowByIdHandler,
|
|
582
|
+
startAsyncWorkflowHandler,
|
|
583
|
+
getWorkflowRunHandler,
|
|
584
|
+
createRunHandler,
|
|
585
|
+
startWorkflowRunHandler,
|
|
586
|
+
watchWorkflowHandler,
|
|
587
|
+
resumeAsyncWorkflowHandler,
|
|
588
|
+
resumeWorkflowHandler
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
export { }
|