@mastra/deployer 0.10.1-alpha.0 → 0.10.1-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_tsup-dts-rollup.d.cts +4 -0
- package/dist/_tsup-dts-rollup.d.ts +4 -0
- package/dist/build/index.cjs +9 -9
- package/dist/build/index.js +1 -1
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-SC6Y2LQ4.js → chunk-GIF6UX5W.js} +20 -16
- package/dist/{chunk-U7N6PH2I.cjs → chunk-UJIBCTVU.cjs} +21 -17
- package/dist/index.cjs +3 -3
- package/dist/index.js +2 -2
- package/dist/server/index.cjs +93 -6
- package/dist/server/index.js +94 -7
- package/package.json +5 -4
|
@@ -291,6 +291,8 @@ tools: any;
|
|
|
291
291
|
workflows: {};
|
|
292
292
|
provider: string;
|
|
293
293
|
modelId: string;
|
|
294
|
+
defaultGenerateOptions: any;
|
|
295
|
+
defaultStreamOptions: any;
|
|
294
296
|
}, ContentfulStatusCode, "json">>;
|
|
295
297
|
|
|
296
298
|
export declare function getAgentCardByIdHandler(c: Context): Promise<Response & TypedResponse< {
|
|
@@ -727,6 +729,8 @@ export declare function streamGenerateHandler(c: Context): Promise<Response | un
|
|
|
727
729
|
|
|
728
730
|
export declare function streamGenerateHandler_alias_1(c: Context): Promise<Response | undefined>;
|
|
729
731
|
|
|
732
|
+
export declare function streamWorkflowHandler(c: Context): Promise<Response>;
|
|
733
|
+
|
|
730
734
|
declare type TransitiveDependencyResult = {
|
|
731
735
|
resolutions: Record<string, string>;
|
|
732
736
|
usedWorkspacePackages: Set<string>;
|
|
@@ -291,6 +291,8 @@ tools: any;
|
|
|
291
291
|
workflows: {};
|
|
292
292
|
provider: string;
|
|
293
293
|
modelId: string;
|
|
294
|
+
defaultGenerateOptions: any;
|
|
295
|
+
defaultStreamOptions: any;
|
|
294
296
|
}, ContentfulStatusCode, "json">>;
|
|
295
297
|
|
|
296
298
|
export declare function getAgentCardByIdHandler(c: Context): Promise<Response & TypedResponse< {
|
|
@@ -727,6 +729,8 @@ export declare function streamGenerateHandler(c: Context): Promise<Response | un
|
|
|
727
729
|
|
|
728
730
|
export declare function streamGenerateHandler_alias_1(c: Context): Promise<Response | undefined>;
|
|
729
731
|
|
|
732
|
+
export declare function streamWorkflowHandler(c: Context): Promise<Response>;
|
|
733
|
+
|
|
730
734
|
declare type TransitiveDependencyResult = {
|
|
731
735
|
resolutions: Record<string, string>;
|
|
732
736
|
usedWorkspacePackages: Set<string>;
|
package/dist/build/index.cjs
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkYHCVXGZM_cjs = require('../chunk-YHCVXGZM.cjs');
|
|
4
4
|
var chunkWK63QOD5_cjs = require('../chunk-WK63QOD5.cjs');
|
|
5
|
+
var chunk4VC5Z4YR_cjs = require('../chunk-4VC5Z4YR.cjs');
|
|
5
6
|
var chunkOJY5LJPT_cjs = require('../chunk-OJY5LJPT.cjs');
|
|
6
7
|
var chunkIMGVLBV7_cjs = require('../chunk-IMGVLBV7.cjs');
|
|
7
|
-
var chunk4VC5Z4YR_cjs = require('../chunk-4VC5Z4YR.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -24,6 +24,14 @@ Object.defineProperty(exports, "writeTelemetryConfig", {
|
|
|
24
24
|
enumerable: true,
|
|
25
25
|
get: function () { return chunkWK63QOD5_cjs.writeTelemetryConfig; }
|
|
26
26
|
});
|
|
27
|
+
Object.defineProperty(exports, "Deps", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return chunk4VC5Z4YR_cjs.Deps; }
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "FileService", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () { return chunk4VC5Z4YR_cjs.FileService; }
|
|
34
|
+
});
|
|
27
35
|
Object.defineProperty(exports, "analyzeBundle", {
|
|
28
36
|
enumerable: true,
|
|
29
37
|
get: function () { return chunkOJY5LJPT_cjs.analyzeBundle; }
|
|
@@ -40,11 +48,3 @@ Object.defineProperty(exports, "getBundlerInputOptions", {
|
|
|
40
48
|
enumerable: true,
|
|
41
49
|
get: function () { return chunkIMGVLBV7_cjs.getInputOptions; }
|
|
42
50
|
});
|
|
43
|
-
Object.defineProperty(exports, "Deps", {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () { return chunk4VC5Z4YR_cjs.Deps; }
|
|
46
|
-
});
|
|
47
|
-
Object.defineProperty(exports, "FileService", {
|
|
48
|
-
enumerable: true,
|
|
49
|
-
get: function () { return chunk4VC5Z4YR_cjs.FileService; }
|
|
50
|
-
});
|
package/dist/build/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createWatcher, getServerOptions, getInputOptions as getWatcherInputOptions } from '../chunk-5ZQI6XPC.js';
|
|
2
2
|
export { writeTelemetryConfig } from '../chunk-O3VM5GJZ.js';
|
|
3
|
+
export { Deps, FileService } from '../chunk-UV4RQQ3R.js';
|
|
3
4
|
export { analyzeBundle, getBundlerOptions } from '../chunk-W46BY5GT.js';
|
|
4
5
|
export { createBundler, getInputOptions as getBundlerInputOptions } from '../chunk-AOSWYZKN.js';
|
|
5
|
-
export { Deps, FileService } from '../chunk-UV4RQQ3R.js';
|
package/dist/bundler/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkUJIBCTVU_cjs = require('../chunk-UJIBCTVU.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "Bundler", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkUJIBCTVU_cjs.Bundler; }
|
|
10
10
|
});
|
package/dist/bundler/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Bundler } from '../chunk-
|
|
1
|
+
export { Bundler } from '../chunk-GIF6UX5W.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { writeTelemetryConfig } from './chunk-O3VM5GJZ.js';
|
|
2
|
+
import { DepsService, FileService } from './chunk-UV4RQQ3R.js';
|
|
2
3
|
import { analyzeBundle } from './chunk-W46BY5GT.js';
|
|
3
4
|
import { createBundler, getInputOptions } from './chunk-AOSWYZKN.js';
|
|
4
|
-
import { DepsService, FileService } from './chunk-UV4RQQ3R.js';
|
|
5
5
|
import { existsSync } from 'node:fs';
|
|
6
6
|
import { writeFile, stat } from 'node:fs/promises';
|
|
7
7
|
import { join, dirname } from 'node:path';
|
|
@@ -9,6 +9,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
9
9
|
import { MastraBundler } from '@mastra/core/bundler';
|
|
10
10
|
import virtual from '@rollup/plugin-virtual';
|
|
11
11
|
import fsExtra, { emptyDir, ensureDir, copy, readJSON } from 'fs-extra/esm';
|
|
12
|
+
import { globby } from 'globby';
|
|
12
13
|
import resolveFrom from 'resolve-from';
|
|
13
14
|
import slugify from '@sindresorhus/slugify';
|
|
14
15
|
import { findWorkspaces, findWorkspacesRoot } from 'find-workspaces';
|
|
@@ -203,22 +204,25 @@ var Bundler = class extends MastraBundler {
|
|
|
203
204
|
async getToolsInputOptions(toolsPaths) {
|
|
204
205
|
const inputs = {};
|
|
205
206
|
for (const toolPath of toolsPaths) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
207
|
+
const expandedPaths = await globby(toolPath, {});
|
|
208
|
+
for (const path of expandedPaths) {
|
|
209
|
+
if (await fsExtra.pathExists(path)) {
|
|
210
|
+
const fileService = new FileService();
|
|
211
|
+
const entryFile = fileService.getFirstExistingFile([
|
|
212
|
+
join(path, "index.ts"),
|
|
213
|
+
join(path, "index.js"),
|
|
214
|
+
path
|
|
215
|
+
// if path itself is a file
|
|
216
|
+
]);
|
|
217
|
+
if (!entryFile || (await stat(entryFile)).isDirectory()) {
|
|
218
|
+
this.logger.warn(`No entry file found in ${path}, skipping...`);
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
const uniqueToolID = crypto.randomUUID();
|
|
222
|
+
inputs[`tools/${uniqueToolID}`] = entryFile;
|
|
223
|
+
} else {
|
|
224
|
+
this.logger.warn(`Tool path ${path} does not exist, skipping...`);
|
|
217
225
|
}
|
|
218
|
-
const uniqueToolID = crypto.randomUUID();
|
|
219
|
-
inputs[`tools/${uniqueToolID}`] = entryFile;
|
|
220
|
-
} else {
|
|
221
|
-
this.logger.warn(`Tool path ${toolPath} does not exist, skipping...`);
|
|
222
226
|
}
|
|
223
227
|
}
|
|
224
228
|
return inputs;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkWK63QOD5_cjs = require('./chunk-WK63QOD5.cjs');
|
|
4
|
+
var chunk4VC5Z4YR_cjs = require('./chunk-4VC5Z4YR.cjs');
|
|
4
5
|
var chunkOJY5LJPT_cjs = require('./chunk-OJY5LJPT.cjs');
|
|
5
6
|
var chunkIMGVLBV7_cjs = require('./chunk-IMGVLBV7.cjs');
|
|
6
|
-
var chunk4VC5Z4YR_cjs = require('./chunk-4VC5Z4YR.cjs');
|
|
7
7
|
var fs = require('fs');
|
|
8
8
|
var promises = require('fs/promises');
|
|
9
9
|
var path = require('path');
|
|
@@ -11,6 +11,7 @@ var url = require('url');
|
|
|
11
11
|
var bundler = require('@mastra/core/bundler');
|
|
12
12
|
var virtual = require('@rollup/plugin-virtual');
|
|
13
13
|
var fsExtra = require('fs-extra/esm');
|
|
14
|
+
var globby = require('globby');
|
|
14
15
|
var resolveFrom = require('resolve-from');
|
|
15
16
|
var slugify = require('@sindresorhus/slugify');
|
|
16
17
|
var findWorkspaces = require('find-workspaces');
|
|
@@ -130,7 +131,7 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
130
131
|
}
|
|
131
132
|
async writeInstrumentationFile(outputDirectory) {
|
|
132
133
|
const instrumentationFile = path.join(outputDirectory, "instrumentation.mjs");
|
|
133
|
-
const __dirname = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-
|
|
134
|
+
const __dirname = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-UJIBCTVU.cjs', document.baseURI).href))));
|
|
134
135
|
await fsExtra.copy(path.join(__dirname, "templates", "instrumentation-template.js"), instrumentationFile);
|
|
135
136
|
}
|
|
136
137
|
async writePackageJson(outputDirectory, dependencies, resolutions) {
|
|
@@ -213,22 +214,25 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
213
214
|
async getToolsInputOptions(toolsPaths) {
|
|
214
215
|
const inputs = {};
|
|
215
216
|
for (const toolPath of toolsPaths) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
217
|
+
const expandedPaths = await globby.globby(toolPath, {});
|
|
218
|
+
for (const path$1 of expandedPaths) {
|
|
219
|
+
if (await fsExtra__default.default.pathExists(path$1)) {
|
|
220
|
+
const fileService = new chunk4VC5Z4YR_cjs.FileService();
|
|
221
|
+
const entryFile = fileService.getFirstExistingFile([
|
|
222
|
+
path.join(path$1, "index.ts"),
|
|
223
|
+
path.join(path$1, "index.js"),
|
|
224
|
+
path$1
|
|
225
|
+
// if path itself is a file
|
|
226
|
+
]);
|
|
227
|
+
if (!entryFile || (await promises.stat(entryFile)).isDirectory()) {
|
|
228
|
+
this.logger.warn(`No entry file found in ${path$1}, skipping...`);
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
const uniqueToolID = crypto.randomUUID();
|
|
232
|
+
inputs[`tools/${uniqueToolID}`] = entryFile;
|
|
233
|
+
} else {
|
|
234
|
+
this.logger.warn(`Tool path ${path$1} does not exist, skipping...`);
|
|
227
235
|
}
|
|
228
|
-
const uniqueToolID = crypto.randomUUID();
|
|
229
|
-
inputs[`tools/${uniqueToolID}`] = entryFile;
|
|
230
|
-
} else {
|
|
231
|
-
this.logger.warn(`Tool path ${toolPath} does not exist, skipping...`);
|
|
232
236
|
}
|
|
233
237
|
}
|
|
234
238
|
return inputs;
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var chunkOJY5LJPT_cjs = require('./chunk-OJY5LJPT.cjs');
|
|
3
|
+
var chunkUJIBCTVU_cjs = require('./chunk-UJIBCTVU.cjs');
|
|
5
4
|
var chunk4VC5Z4YR_cjs = require('./chunk-4VC5Z4YR.cjs');
|
|
5
|
+
var chunkOJY5LJPT_cjs = require('./chunk-OJY5LJPT.cjs');
|
|
6
6
|
var babel = require('@babel/core');
|
|
7
7
|
var rollup = require('rollup');
|
|
8
8
|
var esbuild = require('rollup-plugin-esbuild');
|
|
@@ -33,7 +33,7 @@ var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
|
|
|
33
33
|
var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
|
|
34
34
|
|
|
35
35
|
// src/deploy/base.ts
|
|
36
|
-
var Deployer = class extends
|
|
36
|
+
var Deployer = class extends chunkUJIBCTVU_cjs.Bundler {
|
|
37
37
|
deps = new chunk4VC5Z4YR_cjs.DepsService();
|
|
38
38
|
constructor(args) {
|
|
39
39
|
super(args.name, "DEPLOYER");
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Bundler } from './chunk-
|
|
2
|
-
import { recursiveRemoveNonReferencedNodes } from './chunk-W46BY5GT.js';
|
|
1
|
+
import { Bundler } from './chunk-GIF6UX5W.js';
|
|
3
2
|
import { DepsService, FileService } from './chunk-UV4RQQ3R.js';
|
|
4
3
|
export { Deps, FileService, createChildProcessLogger, createPinoStream } from './chunk-UV4RQQ3R.js';
|
|
4
|
+
import { recursiveRemoveNonReferencedNodes } from './chunk-W46BY5GT.js';
|
|
5
5
|
import * as babel from '@babel/core';
|
|
6
6
|
import babel__default from '@babel/core';
|
|
7
7
|
import { rollup } from 'rollup';
|
package/dist/server/index.cjs
CHANGED
|
@@ -4180,16 +4180,16 @@ function watchWorkflowHandler(c2) {
|
|
|
4180
4180
|
workflowId,
|
|
4181
4181
|
runId
|
|
4182
4182
|
});
|
|
4183
|
+
const reader = result.getReader();
|
|
4183
4184
|
stream4.onAbort(() => {
|
|
4184
|
-
|
|
4185
|
-
return result.cancel();
|
|
4186
|
-
}
|
|
4185
|
+
void reader.cancel("request aborted");
|
|
4187
4186
|
});
|
|
4188
|
-
|
|
4189
|
-
|
|
4187
|
+
let chunkResult;
|
|
4188
|
+
while ((chunkResult = await reader.read()) && !chunkResult.done) {
|
|
4189
|
+
await stream4.write(JSON.stringify(chunkResult.value) + "");
|
|
4190
4190
|
}
|
|
4191
4191
|
} catch (err) {
|
|
4192
|
-
|
|
4192
|
+
mastra.getLogger().error("Error in watch stream: " + (err?.message ?? "Unknown error"));
|
|
4193
4193
|
}
|
|
4194
4194
|
},
|
|
4195
4195
|
async (err) => {
|
|
@@ -4200,6 +4200,46 @@ function watchWorkflowHandler(c2) {
|
|
|
4200
4200
|
return handleError(error, "Error watching workflow");
|
|
4201
4201
|
}
|
|
4202
4202
|
}
|
|
4203
|
+
async function streamWorkflowHandler(c2) {
|
|
4204
|
+
try {
|
|
4205
|
+
const mastra = c2.get("mastra");
|
|
4206
|
+
const logger2 = mastra.getLogger();
|
|
4207
|
+
const workflowId = c2.req.param("workflowId");
|
|
4208
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4209
|
+
const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
4210
|
+
const runId = c2.req.query("runId");
|
|
4211
|
+
return streaming.stream(
|
|
4212
|
+
c2,
|
|
4213
|
+
async (stream4) => {
|
|
4214
|
+
try {
|
|
4215
|
+
const result = workflows.streamWorkflowHandler({
|
|
4216
|
+
mastra,
|
|
4217
|
+
workflowId,
|
|
4218
|
+
runId,
|
|
4219
|
+
inputData,
|
|
4220
|
+
runtimeContext,
|
|
4221
|
+
runtimeContextFromRequest
|
|
4222
|
+
});
|
|
4223
|
+
const reader = result.stream.getReader();
|
|
4224
|
+
stream4.onAbort(() => {
|
|
4225
|
+
void reader.cancel("request aborted");
|
|
4226
|
+
});
|
|
4227
|
+
let chunkResult;
|
|
4228
|
+
while ((chunkResult = await reader.read()) && !chunkResult.done) {
|
|
4229
|
+
await stream4.write(JSON.stringify(chunkResult.value) + "");
|
|
4230
|
+
}
|
|
4231
|
+
} catch (err) {
|
|
4232
|
+
console.log(err);
|
|
4233
|
+
}
|
|
4234
|
+
},
|
|
4235
|
+
async (err) => {
|
|
4236
|
+
logger2.error("Error in workflow stream: " + err?.message);
|
|
4237
|
+
}
|
|
4238
|
+
);
|
|
4239
|
+
} catch (error) {
|
|
4240
|
+
return handleError(error, "Error streaming workflow");
|
|
4241
|
+
}
|
|
4242
|
+
}
|
|
4203
4243
|
async function resumeAsyncWorkflowHandler(c2) {
|
|
4204
4244
|
try {
|
|
4205
4245
|
const mastra = c2.get("mastra");
|
|
@@ -6299,6 +6339,53 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6299
6339
|
}),
|
|
6300
6340
|
watchLegacyWorkflowHandler
|
|
6301
6341
|
);
|
|
6342
|
+
app.post(
|
|
6343
|
+
"/api/workflows/:workflowId/stream",
|
|
6344
|
+
h({
|
|
6345
|
+
description: "Stream workflow in real-time",
|
|
6346
|
+
parameters: [
|
|
6347
|
+
{
|
|
6348
|
+
name: "workflowId",
|
|
6349
|
+
in: "path",
|
|
6350
|
+
required: true,
|
|
6351
|
+
schema: { type: "string" }
|
|
6352
|
+
},
|
|
6353
|
+
{
|
|
6354
|
+
name: "runId",
|
|
6355
|
+
in: "query",
|
|
6356
|
+
required: false,
|
|
6357
|
+
schema: { type: "string" }
|
|
6358
|
+
}
|
|
6359
|
+
],
|
|
6360
|
+
requestBody: {
|
|
6361
|
+
required: true,
|
|
6362
|
+
content: {
|
|
6363
|
+
"application/json": {
|
|
6364
|
+
schema: {
|
|
6365
|
+
type: "object",
|
|
6366
|
+
properties: {
|
|
6367
|
+
inputData: { type: "object" },
|
|
6368
|
+
runtimeContext: {
|
|
6369
|
+
type: "object",
|
|
6370
|
+
description: "Runtime context for the workflow execution"
|
|
6371
|
+
}
|
|
6372
|
+
}
|
|
6373
|
+
}
|
|
6374
|
+
}
|
|
6375
|
+
}
|
|
6376
|
+
},
|
|
6377
|
+
responses: {
|
|
6378
|
+
200: {
|
|
6379
|
+
description: "vNext workflow run started"
|
|
6380
|
+
},
|
|
6381
|
+
404: {
|
|
6382
|
+
description: "vNext workflow not found"
|
|
6383
|
+
}
|
|
6384
|
+
},
|
|
6385
|
+
tags: ["vNextWorkflows"]
|
|
6386
|
+
}),
|
|
6387
|
+
streamWorkflowHandler
|
|
6388
|
+
);
|
|
6302
6389
|
app.get(
|
|
6303
6390
|
"/api/workflows",
|
|
6304
6391
|
h({
|
package/dist/server/index.js
CHANGED
|
@@ -32,7 +32,7 @@ import { getTelemetryHandler as getTelemetryHandler$1, storeTelemetryHandler as
|
|
|
32
32
|
import { executeAgentToolHandler as executeAgentToolHandler$1, getToolsHandler as getToolsHandler$1, getToolByIdHandler as getToolByIdHandler$1, executeToolHandler as executeToolHandler$1 } from '@mastra/server/handlers/tools';
|
|
33
33
|
import { upsertVectors as upsertVectors$1, createIndex as createIndex$1, queryVectors as queryVectors$1, listIndexes as listIndexes$1, describeIndex as describeIndex$1, deleteIndex as deleteIndex$1 } from '@mastra/server/handlers/vector';
|
|
34
34
|
import { getSpeakersHandler as getSpeakersHandler$1, generateSpeechHandler, transcribeSpeechHandler } from '@mastra/server/handlers/voice';
|
|
35
|
-
import { getWorkflowsHandler as getWorkflowsHandler$1, getWorkflowByIdHandler as getWorkflowByIdHandler$1, getWorkflowRunsHandler as getWorkflowRunsHandler$1, resumeWorkflowHandler as resumeWorkflowHandler$1, resumeAsyncWorkflowHandler as resumeAsyncWorkflowHandler$1, createWorkflowRunHandler as createWorkflowRunHandler$1, startAsyncWorkflowHandler as startAsyncWorkflowHandler$1, startWorkflowRunHandler as startWorkflowRunHandler$1, watchWorkflowHandler as watchWorkflowHandler$1 } from '@mastra/server/handlers/workflows';
|
|
35
|
+
import { streamWorkflowHandler as streamWorkflowHandler$1, getWorkflowsHandler as getWorkflowsHandler$1, getWorkflowByIdHandler as getWorkflowByIdHandler$1, getWorkflowRunsHandler as getWorkflowRunsHandler$1, resumeWorkflowHandler as resumeWorkflowHandler$1, resumeAsyncWorkflowHandler as resumeAsyncWorkflowHandler$1, createWorkflowRunHandler as createWorkflowRunHandler$1, startAsyncWorkflowHandler as startAsyncWorkflowHandler$1, startWorkflowRunHandler as startWorkflowRunHandler$1, watchWorkflowHandler as watchWorkflowHandler$1 } from '@mastra/server/handlers/workflows';
|
|
36
36
|
|
|
37
37
|
// src/server/index.ts
|
|
38
38
|
var RequestError = class extends Error {
|
|
@@ -4174,16 +4174,16 @@ function watchWorkflowHandler(c2) {
|
|
|
4174
4174
|
workflowId,
|
|
4175
4175
|
runId
|
|
4176
4176
|
});
|
|
4177
|
+
const reader = result.getReader();
|
|
4177
4178
|
stream4.onAbort(() => {
|
|
4178
|
-
|
|
4179
|
-
return result.cancel();
|
|
4180
|
-
}
|
|
4179
|
+
void reader.cancel("request aborted");
|
|
4181
4180
|
});
|
|
4182
|
-
|
|
4183
|
-
|
|
4181
|
+
let chunkResult;
|
|
4182
|
+
while ((chunkResult = await reader.read()) && !chunkResult.done) {
|
|
4183
|
+
await stream4.write(JSON.stringify(chunkResult.value) + "");
|
|
4184
4184
|
}
|
|
4185
4185
|
} catch (err) {
|
|
4186
|
-
|
|
4186
|
+
mastra.getLogger().error("Error in watch stream: " + (err?.message ?? "Unknown error"));
|
|
4187
4187
|
}
|
|
4188
4188
|
},
|
|
4189
4189
|
async (err) => {
|
|
@@ -4194,6 +4194,46 @@ function watchWorkflowHandler(c2) {
|
|
|
4194
4194
|
return handleError(error, "Error watching workflow");
|
|
4195
4195
|
}
|
|
4196
4196
|
}
|
|
4197
|
+
async function streamWorkflowHandler(c2) {
|
|
4198
|
+
try {
|
|
4199
|
+
const mastra = c2.get("mastra");
|
|
4200
|
+
const logger2 = mastra.getLogger();
|
|
4201
|
+
const workflowId = c2.req.param("workflowId");
|
|
4202
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4203
|
+
const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
4204
|
+
const runId = c2.req.query("runId");
|
|
4205
|
+
return stream(
|
|
4206
|
+
c2,
|
|
4207
|
+
async (stream4) => {
|
|
4208
|
+
try {
|
|
4209
|
+
const result = streamWorkflowHandler$1({
|
|
4210
|
+
mastra,
|
|
4211
|
+
workflowId,
|
|
4212
|
+
runId,
|
|
4213
|
+
inputData,
|
|
4214
|
+
runtimeContext,
|
|
4215
|
+
runtimeContextFromRequest
|
|
4216
|
+
});
|
|
4217
|
+
const reader = result.stream.getReader();
|
|
4218
|
+
stream4.onAbort(() => {
|
|
4219
|
+
void reader.cancel("request aborted");
|
|
4220
|
+
});
|
|
4221
|
+
let chunkResult;
|
|
4222
|
+
while ((chunkResult = await reader.read()) && !chunkResult.done) {
|
|
4223
|
+
await stream4.write(JSON.stringify(chunkResult.value) + "");
|
|
4224
|
+
}
|
|
4225
|
+
} catch (err) {
|
|
4226
|
+
console.log(err);
|
|
4227
|
+
}
|
|
4228
|
+
},
|
|
4229
|
+
async (err) => {
|
|
4230
|
+
logger2.error("Error in workflow stream: " + err?.message);
|
|
4231
|
+
}
|
|
4232
|
+
);
|
|
4233
|
+
} catch (error) {
|
|
4234
|
+
return handleError(error, "Error streaming workflow");
|
|
4235
|
+
}
|
|
4236
|
+
}
|
|
4197
4237
|
async function resumeAsyncWorkflowHandler(c2) {
|
|
4198
4238
|
try {
|
|
4199
4239
|
const mastra = c2.get("mastra");
|
|
@@ -6293,6 +6333,53 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6293
6333
|
}),
|
|
6294
6334
|
watchLegacyWorkflowHandler
|
|
6295
6335
|
);
|
|
6336
|
+
app.post(
|
|
6337
|
+
"/api/workflows/:workflowId/stream",
|
|
6338
|
+
h({
|
|
6339
|
+
description: "Stream workflow in real-time",
|
|
6340
|
+
parameters: [
|
|
6341
|
+
{
|
|
6342
|
+
name: "workflowId",
|
|
6343
|
+
in: "path",
|
|
6344
|
+
required: true,
|
|
6345
|
+
schema: { type: "string" }
|
|
6346
|
+
},
|
|
6347
|
+
{
|
|
6348
|
+
name: "runId",
|
|
6349
|
+
in: "query",
|
|
6350
|
+
required: false,
|
|
6351
|
+
schema: { type: "string" }
|
|
6352
|
+
}
|
|
6353
|
+
],
|
|
6354
|
+
requestBody: {
|
|
6355
|
+
required: true,
|
|
6356
|
+
content: {
|
|
6357
|
+
"application/json": {
|
|
6358
|
+
schema: {
|
|
6359
|
+
type: "object",
|
|
6360
|
+
properties: {
|
|
6361
|
+
inputData: { type: "object" },
|
|
6362
|
+
runtimeContext: {
|
|
6363
|
+
type: "object",
|
|
6364
|
+
description: "Runtime context for the workflow execution"
|
|
6365
|
+
}
|
|
6366
|
+
}
|
|
6367
|
+
}
|
|
6368
|
+
}
|
|
6369
|
+
}
|
|
6370
|
+
},
|
|
6371
|
+
responses: {
|
|
6372
|
+
200: {
|
|
6373
|
+
description: "vNext workflow run started"
|
|
6374
|
+
},
|
|
6375
|
+
404: {
|
|
6376
|
+
description: "vNext workflow not found"
|
|
6377
|
+
}
|
|
6378
|
+
},
|
|
6379
|
+
tags: ["vNextWorkflows"]
|
|
6380
|
+
}),
|
|
6381
|
+
streamWorkflowHandler
|
|
6382
|
+
);
|
|
6296
6383
|
app.get(
|
|
6297
6384
|
"/api/workflows",
|
|
6298
6385
|
h({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer",
|
|
3
|
-
"version": "0.10.1-alpha.
|
|
3
|
+
"version": "0.10.1-alpha.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -100,6 +100,7 @@
|
|
|
100
100
|
"esbuild": "^0.25.1",
|
|
101
101
|
"find-workspaces": "^0.3.1",
|
|
102
102
|
"fs-extra": "^11.3.0",
|
|
103
|
+
"globby": "^14.1.0",
|
|
103
104
|
"hono": "^4.7.4",
|
|
104
105
|
"resolve-from": "^5.0.0",
|
|
105
106
|
"rollup": "^4.35.0",
|
|
@@ -107,7 +108,7 @@
|
|
|
107
108
|
"rollup-plugin-node-externals": "^8.0.0",
|
|
108
109
|
"typescript-paths": "^1.5.1",
|
|
109
110
|
"zod": "^3.24.3",
|
|
110
|
-
"@mastra/server": "^0.10.
|
|
111
|
+
"@mastra/server": "^0.10.1-alpha.3"
|
|
111
112
|
},
|
|
112
113
|
"devDependencies": {
|
|
113
114
|
"@hono/node-server": "^1.13.8",
|
|
@@ -127,8 +128,8 @@
|
|
|
127
128
|
"typescript": "^5.8.2",
|
|
128
129
|
"vitest": "^2.1.9",
|
|
129
130
|
"@internal/lint": "0.0.6",
|
|
130
|
-
"@mastra/
|
|
131
|
-
"@mastra/
|
|
131
|
+
"@mastra/core": "0.10.1-alpha.3",
|
|
132
|
+
"@mastra/mcp": "^0.10.1-alpha.0"
|
|
132
133
|
},
|
|
133
134
|
"peerDependencies": {
|
|
134
135
|
"@mastra/core": "^0.10.0"
|