@mastra/deployer 0.11.1 → 0.12.0-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/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-D73JIE6N.cjs → chunk-DNEQ6Q5S.cjs} +2 -2
- package/dist/index.cjs +3 -3
- package/dist/index.js +2 -2
- package/dist/server/index.cjs +99 -57
- package/dist/server/index.js +90 -48
- package/dist/templates/instrumentation-template.js +2 -0
- package/package.json +8 -8
- package/dist/{chunk-DB7LRMOC.js → chunk-3KEQFYU7.js} +1 -1
package/dist/build/index.cjs
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkTK2RG7LU_cjs = require('../chunk-TK2RG7LU.cjs');
|
|
4
4
|
var chunkE7ZSCQUV_cjs = require('../chunk-E7ZSCQUV.cjs');
|
|
5
|
+
var chunkF25LATVR_cjs = require('../chunk-F25LATVR.cjs');
|
|
5
6
|
var chunkWTGMSQT5_cjs = require('../chunk-WTGMSQT5.cjs');
|
|
6
7
|
var chunkMOG6ASL4_cjs = require('../chunk-MOG6ASL4.cjs');
|
|
7
|
-
var chunkF25LATVR_cjs = require('../chunk-F25LATVR.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -24,6 +24,14 @@ Object.defineProperty(exports, "writeTelemetryConfig", {
|
|
|
24
24
|
enumerable: true,
|
|
25
25
|
get: function () { return chunkE7ZSCQUV_cjs.writeTelemetryConfig; }
|
|
26
26
|
});
|
|
27
|
+
Object.defineProperty(exports, "Deps", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return chunkF25LATVR_cjs.Deps; }
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "FileService", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () { return chunkF25LATVR_cjs.FileService; }
|
|
34
|
+
});
|
|
27
35
|
Object.defineProperty(exports, "analyzeBundle", {
|
|
28
36
|
enumerable: true,
|
|
29
37
|
get: function () { return chunkWTGMSQT5_cjs.analyzeBundle; }
|
|
@@ -40,11 +48,3 @@ Object.defineProperty(exports, "getBundlerInputOptions", {
|
|
|
40
48
|
enumerable: true,
|
|
41
49
|
get: function () { return chunkMOG6ASL4_cjs.getInputOptions; }
|
|
42
50
|
});
|
|
43
|
-
Object.defineProperty(exports, "Deps", {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () { return chunkF25LATVR_cjs.Deps; }
|
|
46
|
-
});
|
|
47
|
-
Object.defineProperty(exports, "FileService", {
|
|
48
|
-
enumerable: true,
|
|
49
|
-
get: function () { return chunkF25LATVR_cjs.FileService; }
|
|
50
|
-
});
|
package/dist/build/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createWatcher, getServerOptions, getInputOptions as getWatcherInputOptions } from '../chunk-APPDEIPA.js';
|
|
2
2
|
export { writeTelemetryConfig } from '../chunk-NB6XIOPQ.js';
|
|
3
|
+
export { Deps, FileService } from '../chunk-7HFWRNM7.js';
|
|
3
4
|
export { analyzeBundle, getBundlerOptions } from '../chunk-TLGEPS44.js';
|
|
4
5
|
export { createBundler, getInputOptions as getBundlerInputOptions } from '../chunk-HZNWZQHG.js';
|
|
5
|
-
export { Deps, FileService } from '../chunk-7HFWRNM7.js';
|
package/dist/bundler/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkDNEQ6Q5S_cjs = require('../chunk-DNEQ6Q5S.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 chunkDNEQ6Q5S_cjs.Bundler; }
|
|
10
10
|
});
|
package/dist/bundler/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Bundler } from '../chunk-
|
|
1
|
+
export { Bundler } from '../chunk-3KEQFYU7.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkE7ZSCQUV_cjs = require('./chunk-E7ZSCQUV.cjs');
|
|
4
|
+
var chunkF25LATVR_cjs = require('./chunk-F25LATVR.cjs');
|
|
4
5
|
var chunkWTGMSQT5_cjs = require('./chunk-WTGMSQT5.cjs');
|
|
5
6
|
var chunkMOG6ASL4_cjs = require('./chunk-MOG6ASL4.cjs');
|
|
6
|
-
var chunkF25LATVR_cjs = require('./chunk-F25LATVR.cjs');
|
|
7
7
|
var fs = require('fs');
|
|
8
8
|
var promises = require('fs/promises');
|
|
9
9
|
var path = require('path');
|
|
@@ -170,7 +170,7 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
170
170
|
}
|
|
171
171
|
async writeInstrumentationFile(outputDirectory, customInstrumentationFile) {
|
|
172
172
|
const instrumentationFile = path.join(outputDirectory, "instrumentation.mjs");
|
|
173
|
-
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-
|
|
173
|
+
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-DNEQ6Q5S.cjs', document.baseURI).href))));
|
|
174
174
|
if (customInstrumentationFile) {
|
|
175
175
|
await fsExtra.copy(customInstrumentationFile, instrumentationFile);
|
|
176
176
|
} else {
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var chunkWTGMSQT5_cjs = require('./chunk-WTGMSQT5.cjs');
|
|
3
|
+
var chunkDNEQ6Q5S_cjs = require('./chunk-DNEQ6Q5S.cjs');
|
|
5
4
|
var chunkF25LATVR_cjs = require('./chunk-F25LATVR.cjs');
|
|
5
|
+
var chunkWTGMSQT5_cjs = require('./chunk-WTGMSQT5.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 chunkDNEQ6Q5S_cjs.Bundler {
|
|
37
37
|
deps = new chunkF25LATVR_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-TLGEPS44.js';
|
|
1
|
+
import { Bundler } from './chunk-3KEQFYU7.js';
|
|
3
2
|
import { DepsService, FileService } from './chunk-7HFWRNM7.js';
|
|
4
3
|
export { Deps, FileService, createChildProcessLogger, createPinoStream } from './chunk-7HFWRNM7.js';
|
|
4
|
+
import { recursiveRemoveNonReferencedNodes } from './chunk-TLGEPS44.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
|
@@ -6,9 +6,9 @@ var posix = require('path/posix');
|
|
|
6
6
|
var http = require('http');
|
|
7
7
|
var http2 = require('http2');
|
|
8
8
|
var stream = require('stream');
|
|
9
|
-
var filepath = require('hono/utils/filepath');
|
|
10
9
|
var mime = require('hono/utils/mime');
|
|
11
10
|
var fs = require('fs');
|
|
11
|
+
var path = require('path');
|
|
12
12
|
var html = require('hono/html');
|
|
13
13
|
var core = require('@mastra/core');
|
|
14
14
|
var runtimeContext = require('@mastra/core/runtime-context');
|
|
@@ -68,6 +68,7 @@ var Request = class extends GlobalRequest {
|
|
|
68
68
|
super(input, options);
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
|
+
var wrapBodyStream = Symbol("wrapBodyStream");
|
|
71
72
|
var newRequestFromIncoming = (method, url, incoming, abortController) => {
|
|
72
73
|
const headerRecord = [];
|
|
73
74
|
const rawHeaders = incoming.rawHeaders;
|
|
@@ -101,6 +102,23 @@ var newRequestFromIncoming = (method, url, incoming, abortController) => {
|
|
|
101
102
|
controller.close();
|
|
102
103
|
}
|
|
103
104
|
});
|
|
105
|
+
} else if (incoming[wrapBodyStream]) {
|
|
106
|
+
let reader;
|
|
107
|
+
init.body = new ReadableStream({
|
|
108
|
+
async pull(controller) {
|
|
109
|
+
try {
|
|
110
|
+
reader ||= stream.Readable.toWeb(incoming).getReader();
|
|
111
|
+
const { done, value } = await reader.read();
|
|
112
|
+
if (done) {
|
|
113
|
+
controller.close();
|
|
114
|
+
} else {
|
|
115
|
+
controller.enqueue(value);
|
|
116
|
+
}
|
|
117
|
+
} catch (error) {
|
|
118
|
+
controller.error(error);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
});
|
|
104
122
|
} else {
|
|
105
123
|
init.body = stream.Readable.toWeb(incoming);
|
|
106
124
|
}
|
|
@@ -270,26 +288,23 @@ function writeFromReadableStream(stream6, writable) {
|
|
|
270
288
|
if (stream6.locked) {
|
|
271
289
|
throw new TypeError("ReadableStream is locked.");
|
|
272
290
|
} else if (writable.destroyed) {
|
|
273
|
-
stream6.cancel();
|
|
274
291
|
return;
|
|
275
292
|
}
|
|
276
293
|
const reader = stream6.getReader();
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
294
|
+
const handleError2 = () => {
|
|
295
|
+
};
|
|
296
|
+
writable.on("error", handleError2);
|
|
297
|
+
reader.read().then(flow, handleStreamError);
|
|
280
298
|
return reader.closed.finally(() => {
|
|
281
|
-
writable.off("
|
|
282
|
-
writable.off("error", cancel);
|
|
299
|
+
writable.off("error", handleError2);
|
|
283
300
|
});
|
|
284
|
-
function
|
|
285
|
-
reader.cancel(error).catch(() => {
|
|
286
|
-
});
|
|
301
|
+
function handleStreamError(error) {
|
|
287
302
|
if (error) {
|
|
288
303
|
writable.destroy(error);
|
|
289
304
|
}
|
|
290
305
|
}
|
|
291
306
|
function onDrain() {
|
|
292
|
-
reader.read().then(flow,
|
|
307
|
+
reader.read().then(flow, handleStreamError);
|
|
293
308
|
}
|
|
294
309
|
function flow({ done, value }) {
|
|
295
310
|
try {
|
|
@@ -298,10 +313,10 @@ function writeFromReadableStream(stream6, writable) {
|
|
|
298
313
|
} else if (!writable.write(value)) {
|
|
299
314
|
writable.once("drain", onDrain);
|
|
300
315
|
} else {
|
|
301
|
-
return reader.read().then(flow,
|
|
316
|
+
return reader.read().then(flow, handleStreamError);
|
|
302
317
|
}
|
|
303
318
|
} catch (e2) {
|
|
304
|
-
|
|
319
|
+
handleStreamError(e2);
|
|
305
320
|
}
|
|
306
321
|
}
|
|
307
322
|
}
|
|
@@ -338,6 +353,7 @@ global.fetch = (info, init) => {
|
|
|
338
353
|
};
|
|
339
354
|
return webFetch(info, init);
|
|
340
355
|
};
|
|
356
|
+
var outgoingEnded = Symbol("outgoingEnded");
|
|
341
357
|
var regBuffer = /^no$/i;
|
|
342
358
|
var regContentType = /^(application\/json\b|text\/(?!event-stream\b))/i;
|
|
343
359
|
var handleRequestError = () => new Response(null, {
|
|
@@ -383,10 +399,11 @@ var responseViaCache = async (res, outgoing) => {
|
|
|
383
399
|
outgoing.end(new Uint8Array(await body.arrayBuffer()));
|
|
384
400
|
} else {
|
|
385
401
|
flushHeaders(outgoing);
|
|
386
|
-
|
|
402
|
+
await writeFromReadableStream(body, outgoing)?.catch(
|
|
387
403
|
(e2) => handleResponseError(e2, outgoing)
|
|
388
404
|
);
|
|
389
405
|
}
|
|
406
|
+
outgoing[outgoingEnded]?.();
|
|
390
407
|
};
|
|
391
408
|
var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
392
409
|
if (res instanceof Promise) {
|
|
@@ -431,8 +448,10 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
|
431
448
|
outgoing.writeHead(res.status, resHeaderRecord);
|
|
432
449
|
outgoing.end();
|
|
433
450
|
}
|
|
451
|
+
outgoing[outgoingEnded]?.();
|
|
434
452
|
};
|
|
435
453
|
var getRequestListener = (fetchCallback, options = {}) => {
|
|
454
|
+
const autoCleanupIncoming = options.autoCleanupIncoming ?? true;
|
|
436
455
|
if (options.overrideGlobalObjects !== false && global.Request !== Request) {
|
|
437
456
|
Object.defineProperty(global, "Request", {
|
|
438
457
|
value: Request
|
|
@@ -445,15 +464,44 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
445
464
|
let res, req;
|
|
446
465
|
try {
|
|
447
466
|
req = newRequest(incoming, options.hostname);
|
|
467
|
+
let incomingEnded = !autoCleanupIncoming || incoming.method === "GET" || incoming.method === "HEAD";
|
|
468
|
+
if (!incomingEnded) {
|
|
469
|
+
incoming[wrapBodyStream] = true;
|
|
470
|
+
incoming.on("end", () => {
|
|
471
|
+
incomingEnded = true;
|
|
472
|
+
});
|
|
473
|
+
if (incoming instanceof http2.Http2ServerRequest) {
|
|
474
|
+
outgoing[outgoingEnded] = () => {
|
|
475
|
+
if (!incomingEnded) {
|
|
476
|
+
setTimeout(() => {
|
|
477
|
+
if (!incomingEnded) {
|
|
478
|
+
setTimeout(() => {
|
|
479
|
+
incoming.destroy();
|
|
480
|
+
outgoing.destroy();
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
}
|
|
448
488
|
outgoing.on("close", () => {
|
|
449
489
|
const abortController = req[abortControllerKey];
|
|
450
|
-
if (
|
|
451
|
-
|
|
490
|
+
if (abortController) {
|
|
491
|
+
if (incoming.errored) {
|
|
492
|
+
req[abortControllerKey].abort(incoming.errored.toString());
|
|
493
|
+
} else if (!outgoing.writableFinished) {
|
|
494
|
+
req[abortControllerKey].abort("Client connection prematurely closed.");
|
|
495
|
+
}
|
|
452
496
|
}
|
|
453
|
-
if (
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
497
|
+
if (!incomingEnded) {
|
|
498
|
+
setTimeout(() => {
|
|
499
|
+
if (!incomingEnded) {
|
|
500
|
+
setTimeout(() => {
|
|
501
|
+
incoming.destroy();
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
});
|
|
457
505
|
}
|
|
458
506
|
});
|
|
459
507
|
res = fetchCallback(req, { incoming, outgoing });
|
|
@@ -487,7 +535,8 @@ var createAdaptorServer = (options) => {
|
|
|
487
535
|
const fetchCallback = options.fetch;
|
|
488
536
|
const requestListener = getRequestListener(fetchCallback, {
|
|
489
537
|
hostname: options.hostname,
|
|
490
|
-
overrideGlobalObjects: options.overrideGlobalObjects
|
|
538
|
+
overrideGlobalObjects: options.overrideGlobalObjects,
|
|
539
|
+
autoCleanupIncoming: options.autoCleanupIncoming
|
|
491
540
|
});
|
|
492
541
|
const createServer = options.createServer || http.createServer;
|
|
493
542
|
const server = createServer(options.serverOptions || {}, requestListener);
|
|
@@ -524,9 +573,6 @@ var createStreamBody = (stream6) => {
|
|
|
524
573
|
});
|
|
525
574
|
return body;
|
|
526
575
|
};
|
|
527
|
-
var addCurrentDirPrefix = (path) => {
|
|
528
|
-
return `./${path}`;
|
|
529
|
-
};
|
|
530
576
|
var getStats = (path) => {
|
|
531
577
|
let stats;
|
|
532
578
|
try {
|
|
@@ -536,46 +582,42 @@ var getStats = (path) => {
|
|
|
536
582
|
return stats;
|
|
537
583
|
};
|
|
538
584
|
var serveStatic = (options = { root: "" }) => {
|
|
585
|
+
const root = options.root || "";
|
|
586
|
+
const optionPath = options.path;
|
|
539
587
|
return async (c2, next) => {
|
|
540
588
|
if (c2.finalized) {
|
|
541
589
|
return next();
|
|
542
590
|
}
|
|
543
591
|
let filename;
|
|
544
|
-
|
|
545
|
-
filename =
|
|
546
|
-
} catch {
|
|
547
|
-
await options.onNotFound?.(c2.req.path, c2);
|
|
548
|
-
return next();
|
|
549
|
-
}
|
|
550
|
-
let path = filepath.getFilePathWithoutDefaultDocument({
|
|
551
|
-
filename: options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename,
|
|
552
|
-
root: options.root
|
|
553
|
-
});
|
|
554
|
-
if (path) {
|
|
555
|
-
path = addCurrentDirPrefix(path);
|
|
592
|
+
if (optionPath) {
|
|
593
|
+
filename = optionPath;
|
|
556
594
|
} else {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
defaultDocument: options.index ?? "index.html"
|
|
565
|
-
});
|
|
566
|
-
if (path) {
|
|
567
|
-
path = addCurrentDirPrefix(path);
|
|
568
|
-
} else {
|
|
595
|
+
try {
|
|
596
|
+
filename = decodeURIComponent(c2.req.path);
|
|
597
|
+
if (/(?:^|[\/\\])\.\.(?:$|[\/\\])/.test(filename)) {
|
|
598
|
+
throw new Error();
|
|
599
|
+
}
|
|
600
|
+
} catch {
|
|
601
|
+
await options.onNotFound?.(c2.req.path, c2);
|
|
569
602
|
return next();
|
|
570
603
|
}
|
|
571
|
-
|
|
604
|
+
}
|
|
605
|
+
let path$1 = path.join(
|
|
606
|
+
root,
|
|
607
|
+
!optionPath && options.rewriteRequestPath ? options.rewriteRequestPath(filename, c2) : filename
|
|
608
|
+
);
|
|
609
|
+
let stats = getStats(path$1);
|
|
610
|
+
if (stats && stats.isDirectory()) {
|
|
611
|
+
const indexFile = options.index ?? "index.html";
|
|
612
|
+
path$1 = path.join(path$1, indexFile);
|
|
613
|
+
stats = getStats(path$1);
|
|
572
614
|
}
|
|
573
615
|
if (!stats) {
|
|
574
|
-
await options.onNotFound?.(path, c2);
|
|
616
|
+
await options.onNotFound?.(path$1, c2);
|
|
575
617
|
return next();
|
|
576
618
|
}
|
|
577
|
-
await options.onFound?.(path, c2);
|
|
578
|
-
const mimeType = mime.getMimeType(path);
|
|
619
|
+
await options.onFound?.(path$1, c2);
|
|
620
|
+
const mimeType = mime.getMimeType(path$1);
|
|
579
621
|
c2.header("Content-Type", mimeType || "application/octet-stream");
|
|
580
622
|
if (options.precompressed && (!mimeType || COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
|
|
581
623
|
const acceptEncodingSet = new Set(
|
|
@@ -585,12 +627,12 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
585
627
|
if (!acceptEncodingSet.has(encoding)) {
|
|
586
628
|
continue;
|
|
587
629
|
}
|
|
588
|
-
const precompressedStats = getStats(path + ENCODINGS[encoding]);
|
|
630
|
+
const precompressedStats = getStats(path$1 + ENCODINGS[encoding]);
|
|
589
631
|
if (precompressedStats) {
|
|
590
632
|
c2.header("Content-Encoding", encoding);
|
|
591
633
|
c2.header("Vary", "Accept-Encoding", { append: true });
|
|
592
634
|
stats = precompressedStats;
|
|
593
|
-
path = path + ENCODINGS[encoding];
|
|
635
|
+
path$1 = path$1 + ENCODINGS[encoding];
|
|
594
636
|
break;
|
|
595
637
|
}
|
|
596
638
|
}
|
|
@@ -604,7 +646,7 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
604
646
|
const range = c2.req.header("range") || "";
|
|
605
647
|
if (!range) {
|
|
606
648
|
c2.header("Content-Length", size.toString());
|
|
607
|
-
return c2.body(createStreamBody(fs.createReadStream(path)), 200);
|
|
649
|
+
return c2.body(createStreamBody(fs.createReadStream(path$1)), 200);
|
|
608
650
|
}
|
|
609
651
|
c2.header("Accept-Ranges", "bytes");
|
|
610
652
|
c2.header("Date", stats.birthtime.toUTCString());
|
|
@@ -615,7 +657,7 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
615
657
|
end = size - 1;
|
|
616
658
|
}
|
|
617
659
|
const chunksize = end - start + 1;
|
|
618
|
-
const stream6 = fs.createReadStream(path, { start, end });
|
|
660
|
+
const stream6 = fs.createReadStream(path$1, { start, end });
|
|
619
661
|
c2.header("Content-Length", chunksize.toString());
|
|
620
662
|
c2.header("Content-Range", `bytes ${start}-${end}/${stats.size}`);
|
|
621
663
|
return c2.body(createStreamBody(stream6), 206);
|
|
@@ -739,7 +781,7 @@ var middleware = (options) => async (c2) => {
|
|
|
739
781
|
);
|
|
740
782
|
};
|
|
741
783
|
|
|
742
|
-
// ../../node_modules/.pnpm/hono-openapi@0.4.8_hono@4.8.4_openapi-types@12.1.3_zod@3.25.
|
|
784
|
+
// ../../node_modules/.pnpm/hono-openapi@0.4.8_hono@4.8.4_openapi-types@12.1.3_zod@3.25.76/node_modules/hono-openapi/utils.js
|
|
743
785
|
var e = Symbol("openapi");
|
|
744
786
|
var n = ["GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH", "TRACE"];
|
|
745
787
|
var s2 = (e2) => e2.charAt(0).toUpperCase() + e2.slice(1);
|
package/dist/server/index.js
CHANGED
|
@@ -4,9 +4,9 @@ import { join } from 'path/posix';
|
|
|
4
4
|
import { createServer } from 'http';
|
|
5
5
|
import { Http2ServerRequest } from 'http2';
|
|
6
6
|
import { Writable, Readable } from 'stream';
|
|
7
|
-
import { getFilePathWithoutDefaultDocument, getFilePath } from 'hono/utils/filepath';
|
|
8
7
|
import { getMimeType } from 'hono/utils/mime';
|
|
9
8
|
import { createReadStream, lstatSync } from 'fs';
|
|
9
|
+
import { join as join$1 } from 'path';
|
|
10
10
|
import { html } from 'hono/html';
|
|
11
11
|
import { Telemetry } from '@mastra/core';
|
|
12
12
|
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
@@ -61,6 +61,7 @@ var Request = class extends GlobalRequest {
|
|
|
61
61
|
super(input, options);
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
+
var wrapBodyStream = Symbol("wrapBodyStream");
|
|
64
65
|
var newRequestFromIncoming = (method, url, incoming, abortController) => {
|
|
65
66
|
const headerRecord = [];
|
|
66
67
|
const rawHeaders = incoming.rawHeaders;
|
|
@@ -94,6 +95,23 @@ var newRequestFromIncoming = (method, url, incoming, abortController) => {
|
|
|
94
95
|
controller.close();
|
|
95
96
|
}
|
|
96
97
|
});
|
|
98
|
+
} else if (incoming[wrapBodyStream]) {
|
|
99
|
+
let reader;
|
|
100
|
+
init.body = new ReadableStream({
|
|
101
|
+
async pull(controller) {
|
|
102
|
+
try {
|
|
103
|
+
reader ||= Readable.toWeb(incoming).getReader();
|
|
104
|
+
const { done, value } = await reader.read();
|
|
105
|
+
if (done) {
|
|
106
|
+
controller.close();
|
|
107
|
+
} else {
|
|
108
|
+
controller.enqueue(value);
|
|
109
|
+
}
|
|
110
|
+
} catch (error) {
|
|
111
|
+
controller.error(error);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
97
115
|
} else {
|
|
98
116
|
init.body = Readable.toWeb(incoming);
|
|
99
117
|
}
|
|
@@ -263,26 +281,23 @@ function writeFromReadableStream(stream6, writable) {
|
|
|
263
281
|
if (stream6.locked) {
|
|
264
282
|
throw new TypeError("ReadableStream is locked.");
|
|
265
283
|
} else if (writable.destroyed) {
|
|
266
|
-
stream6.cancel();
|
|
267
284
|
return;
|
|
268
285
|
}
|
|
269
286
|
const reader = stream6.getReader();
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
287
|
+
const handleError2 = () => {
|
|
288
|
+
};
|
|
289
|
+
writable.on("error", handleError2);
|
|
290
|
+
reader.read().then(flow, handleStreamError);
|
|
273
291
|
return reader.closed.finally(() => {
|
|
274
|
-
writable.off("
|
|
275
|
-
writable.off("error", cancel);
|
|
292
|
+
writable.off("error", handleError2);
|
|
276
293
|
});
|
|
277
|
-
function
|
|
278
|
-
reader.cancel(error).catch(() => {
|
|
279
|
-
});
|
|
294
|
+
function handleStreamError(error) {
|
|
280
295
|
if (error) {
|
|
281
296
|
writable.destroy(error);
|
|
282
297
|
}
|
|
283
298
|
}
|
|
284
299
|
function onDrain() {
|
|
285
|
-
reader.read().then(flow,
|
|
300
|
+
reader.read().then(flow, handleStreamError);
|
|
286
301
|
}
|
|
287
302
|
function flow({ done, value }) {
|
|
288
303
|
try {
|
|
@@ -291,10 +306,10 @@ function writeFromReadableStream(stream6, writable) {
|
|
|
291
306
|
} else if (!writable.write(value)) {
|
|
292
307
|
writable.once("drain", onDrain);
|
|
293
308
|
} else {
|
|
294
|
-
return reader.read().then(flow,
|
|
309
|
+
return reader.read().then(flow, handleStreamError);
|
|
295
310
|
}
|
|
296
311
|
} catch (e2) {
|
|
297
|
-
|
|
312
|
+
handleStreamError(e2);
|
|
298
313
|
}
|
|
299
314
|
}
|
|
300
315
|
}
|
|
@@ -331,6 +346,7 @@ global.fetch = (info, init) => {
|
|
|
331
346
|
};
|
|
332
347
|
return webFetch(info, init);
|
|
333
348
|
};
|
|
349
|
+
var outgoingEnded = Symbol("outgoingEnded");
|
|
334
350
|
var regBuffer = /^no$/i;
|
|
335
351
|
var regContentType = /^(application\/json\b|text\/(?!event-stream\b))/i;
|
|
336
352
|
var handleRequestError = () => new Response(null, {
|
|
@@ -376,10 +392,11 @@ var responseViaCache = async (res, outgoing) => {
|
|
|
376
392
|
outgoing.end(new Uint8Array(await body.arrayBuffer()));
|
|
377
393
|
} else {
|
|
378
394
|
flushHeaders(outgoing);
|
|
379
|
-
|
|
395
|
+
await writeFromReadableStream(body, outgoing)?.catch(
|
|
380
396
|
(e2) => handleResponseError(e2, outgoing)
|
|
381
397
|
);
|
|
382
398
|
}
|
|
399
|
+
outgoing[outgoingEnded]?.();
|
|
383
400
|
};
|
|
384
401
|
var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
385
402
|
if (res instanceof Promise) {
|
|
@@ -424,8 +441,10 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
|
424
441
|
outgoing.writeHead(res.status, resHeaderRecord);
|
|
425
442
|
outgoing.end();
|
|
426
443
|
}
|
|
444
|
+
outgoing[outgoingEnded]?.();
|
|
427
445
|
};
|
|
428
446
|
var getRequestListener = (fetchCallback, options = {}) => {
|
|
447
|
+
const autoCleanupIncoming = options.autoCleanupIncoming ?? true;
|
|
429
448
|
if (options.overrideGlobalObjects !== false && global.Request !== Request) {
|
|
430
449
|
Object.defineProperty(global, "Request", {
|
|
431
450
|
value: Request
|
|
@@ -438,15 +457,44 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
438
457
|
let res, req;
|
|
439
458
|
try {
|
|
440
459
|
req = newRequest(incoming, options.hostname);
|
|
460
|
+
let incomingEnded = !autoCleanupIncoming || incoming.method === "GET" || incoming.method === "HEAD";
|
|
461
|
+
if (!incomingEnded) {
|
|
462
|
+
incoming[wrapBodyStream] = true;
|
|
463
|
+
incoming.on("end", () => {
|
|
464
|
+
incomingEnded = true;
|
|
465
|
+
});
|
|
466
|
+
if (incoming instanceof Http2ServerRequest) {
|
|
467
|
+
outgoing[outgoingEnded] = () => {
|
|
468
|
+
if (!incomingEnded) {
|
|
469
|
+
setTimeout(() => {
|
|
470
|
+
if (!incomingEnded) {
|
|
471
|
+
setTimeout(() => {
|
|
472
|
+
incoming.destroy();
|
|
473
|
+
outgoing.destroy();
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
}
|
|
441
481
|
outgoing.on("close", () => {
|
|
442
482
|
const abortController = req[abortControllerKey];
|
|
443
|
-
if (
|
|
444
|
-
|
|
483
|
+
if (abortController) {
|
|
484
|
+
if (incoming.errored) {
|
|
485
|
+
req[abortControllerKey].abort(incoming.errored.toString());
|
|
486
|
+
} else if (!outgoing.writableFinished) {
|
|
487
|
+
req[abortControllerKey].abort("Client connection prematurely closed.");
|
|
488
|
+
}
|
|
445
489
|
}
|
|
446
|
-
if (
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
490
|
+
if (!incomingEnded) {
|
|
491
|
+
setTimeout(() => {
|
|
492
|
+
if (!incomingEnded) {
|
|
493
|
+
setTimeout(() => {
|
|
494
|
+
incoming.destroy();
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
});
|
|
450
498
|
}
|
|
451
499
|
});
|
|
452
500
|
res = fetchCallback(req, { incoming, outgoing });
|
|
@@ -480,7 +528,8 @@ var createAdaptorServer = (options) => {
|
|
|
480
528
|
const fetchCallback = options.fetch;
|
|
481
529
|
const requestListener = getRequestListener(fetchCallback, {
|
|
482
530
|
hostname: options.hostname,
|
|
483
|
-
overrideGlobalObjects: options.overrideGlobalObjects
|
|
531
|
+
overrideGlobalObjects: options.overrideGlobalObjects,
|
|
532
|
+
autoCleanupIncoming: options.autoCleanupIncoming
|
|
484
533
|
});
|
|
485
534
|
const createServer$1 = options.createServer || createServer;
|
|
486
535
|
const server = createServer$1(options.serverOptions || {}, requestListener);
|
|
@@ -517,9 +566,6 @@ var createStreamBody = (stream6) => {
|
|
|
517
566
|
});
|
|
518
567
|
return body;
|
|
519
568
|
};
|
|
520
|
-
var addCurrentDirPrefix = (path) => {
|
|
521
|
-
return `./${path}`;
|
|
522
|
-
};
|
|
523
569
|
var getStats = (path) => {
|
|
524
570
|
let stats;
|
|
525
571
|
try {
|
|
@@ -529,38 +575,34 @@ var getStats = (path) => {
|
|
|
529
575
|
return stats;
|
|
530
576
|
};
|
|
531
577
|
var serveStatic = (options = { root: "" }) => {
|
|
578
|
+
const root = options.root || "";
|
|
579
|
+
const optionPath = options.path;
|
|
532
580
|
return async (c2, next) => {
|
|
533
581
|
if (c2.finalized) {
|
|
534
582
|
return next();
|
|
535
583
|
}
|
|
536
584
|
let filename;
|
|
537
|
-
|
|
538
|
-
filename =
|
|
539
|
-
} catch {
|
|
540
|
-
await options.onNotFound?.(c2.req.path, c2);
|
|
541
|
-
return next();
|
|
542
|
-
}
|
|
543
|
-
let path = getFilePathWithoutDefaultDocument({
|
|
544
|
-
filename: options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename,
|
|
545
|
-
root: options.root
|
|
546
|
-
});
|
|
547
|
-
if (path) {
|
|
548
|
-
path = addCurrentDirPrefix(path);
|
|
585
|
+
if (optionPath) {
|
|
586
|
+
filename = optionPath;
|
|
549
587
|
} else {
|
|
550
|
-
|
|
588
|
+
try {
|
|
589
|
+
filename = decodeURIComponent(c2.req.path);
|
|
590
|
+
if (/(?:^|[\/\\])\.\.(?:$|[\/\\])/.test(filename)) {
|
|
591
|
+
throw new Error();
|
|
592
|
+
}
|
|
593
|
+
} catch {
|
|
594
|
+
await options.onNotFound?.(c2.req.path, c2);
|
|
595
|
+
return next();
|
|
596
|
+
}
|
|
551
597
|
}
|
|
598
|
+
let path = join$1(
|
|
599
|
+
root,
|
|
600
|
+
!optionPath && options.rewriteRequestPath ? options.rewriteRequestPath(filename, c2) : filename
|
|
601
|
+
);
|
|
552
602
|
let stats = getStats(path);
|
|
553
603
|
if (stats && stats.isDirectory()) {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
root: options.root,
|
|
557
|
-
defaultDocument: options.index ?? "index.html"
|
|
558
|
-
});
|
|
559
|
-
if (path) {
|
|
560
|
-
path = addCurrentDirPrefix(path);
|
|
561
|
-
} else {
|
|
562
|
-
return next();
|
|
563
|
-
}
|
|
604
|
+
const indexFile = options.index ?? "index.html";
|
|
605
|
+
path = join$1(path, indexFile);
|
|
564
606
|
stats = getStats(path);
|
|
565
607
|
}
|
|
566
608
|
if (!stats) {
|
|
@@ -732,7 +774,7 @@ var middleware = (options) => async (c2) => {
|
|
|
732
774
|
);
|
|
733
775
|
};
|
|
734
776
|
|
|
735
|
-
// ../../node_modules/.pnpm/hono-openapi@0.4.8_hono@4.8.4_openapi-types@12.1.3_zod@3.25.
|
|
777
|
+
// ../../node_modules/.pnpm/hono-openapi@0.4.8_hono@4.8.4_openapi-types@12.1.3_zod@3.25.76/node_modules/hono-openapi/utils.js
|
|
736
778
|
var e = Symbol("openapi");
|
|
737
779
|
var n = ["GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH", "TRACE"];
|
|
738
780
|
var s2 = (e2) => e2.charAt(0).toUpperCase() + e2.slice(1);
|
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
|
|
14
14
|
import { telemetry } from './telemetry-config.mjs';
|
|
15
15
|
|
|
16
|
+
globalThis.___MASTRA_TELEMETRY___ = true;
|
|
17
|
+
|
|
16
18
|
class CompositeExporter {
|
|
17
19
|
constructor(exporters) {
|
|
18
20
|
this.exporters = exporters;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"author": "",
|
|
86
86
|
"license": "Apache-2.0",
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@babel/core": "^7.
|
|
88
|
+
"@babel/core": "^7.28.0",
|
|
89
89
|
"@babel/helper-module-imports": "^7.27.1",
|
|
90
90
|
"@neon-rs/load": "^0.1.82",
|
|
91
91
|
"@rollup/plugin-alias": "^5.1.1",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"builtins": "^5.1.0",
|
|
98
98
|
"detect-libc": "^2.0.4",
|
|
99
99
|
"dotenv": "^16.6.1",
|
|
100
|
-
"esbuild": "^0.25.
|
|
100
|
+
"esbuild": "^0.25.8",
|
|
101
101
|
"find-workspaces": "^0.3.1",
|
|
102
102
|
"fs-extra": "^11.3.0",
|
|
103
103
|
"globby": "^14.1.0",
|
|
@@ -108,10 +108,10 @@
|
|
|
108
108
|
"rollup-plugin-node-externals": "^8.0.1",
|
|
109
109
|
"typescript-paths": "^1.5.1",
|
|
110
110
|
"zod": "^3.25.67",
|
|
111
|
-
"@mastra/server": "^0.
|
|
111
|
+
"@mastra/server": "^0.12.0-alpha.0"
|
|
112
112
|
},
|
|
113
113
|
"devDependencies": {
|
|
114
|
-
"@hono/node-server": "^1.
|
|
114
|
+
"@hono/node-server": "^1.17.1",
|
|
115
115
|
"@hono/swagger-ui": "^0.5.2",
|
|
116
116
|
"@microsoft/api-extractor": "^7.52.8",
|
|
117
117
|
"@types/babel__core": "^7.20.5",
|
|
@@ -127,9 +127,9 @@
|
|
|
127
127
|
"type-fest": "^4.41.0",
|
|
128
128
|
"typescript": "^5.8.3",
|
|
129
129
|
"vitest": "^3.2.4",
|
|
130
|
-
"@internal/lint": "0.0.
|
|
131
|
-
"@mastra/
|
|
132
|
-
"@mastra/
|
|
130
|
+
"@internal/lint": "0.0.23",
|
|
131
|
+
"@mastra/core": "0.12.0-alpha.0",
|
|
132
|
+
"@mastra/mcp": "^0.10.7"
|
|
133
133
|
},
|
|
134
134
|
"peerDependencies": {
|
|
135
135
|
"@mastra/core": ">=0.11.0-0 <0.12.0-0"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { writeTelemetryConfig } from './chunk-NB6XIOPQ.js';
|
|
2
|
+
import { DepsService, FileService } from './chunk-7HFWRNM7.js';
|
|
2
3
|
import { analyzeBundle, getBundlerOptions } from './chunk-TLGEPS44.js';
|
|
3
4
|
import { createBundler, getInputOptions } from './chunk-HZNWZQHG.js';
|
|
4
|
-
import { DepsService, FileService } from './chunk-7HFWRNM7.js';
|
|
5
5
|
import { existsSync } from 'fs';
|
|
6
6
|
import { writeFile, stat } from 'fs/promises';
|
|
7
7
|
import { join, dirname } from 'path';
|