@mastra/deployer 0.10.13 → 0.10.15-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/_tsup-dts-rollup.d.cts +844 -0
- package/dist/_tsup-dts-rollup.d.ts +844 -0
- package/dist/build/analyze.cjs +10 -0
- package/dist/build/analyze.d.cts +1 -0
- package/dist/build/analyze.d.ts +1 -0
- package/dist/build/analyze.js +1 -0
- package/dist/build/bundler.cjs +14 -0
- package/dist/build/bundler.d.cts +2 -0
- package/dist/build/bundler.d.ts +2 -0
- package/dist/build/bundler.js +1 -0
- package/dist/build/index.cjs +50 -0
- package/dist/build/index.d.cts +10 -0
- package/dist/build/index.d.ts +10 -0
- package/dist/build/index.js +5 -0
- package/dist/bundler/index.cjs +10 -0
- package/dist/bundler/index.d.cts +1 -0
- package/dist/bundler/index.d.ts +1 -0
- package/dist/bundler/index.js +1 -0
- package/dist/chunk-54KOF3NB.cjs +137 -0
- package/dist/chunk-6QMONK4A.cjs +2 -0
- package/dist/chunk-C4JT7CIH.js +1 -0
- package/dist/chunk-D2DCFCLH.cjs +157 -0
- package/dist/chunk-D6736SJL.js +209 -0
- package/dist/chunk-ENT5RDOI.js +99 -0
- package/dist/chunk-FK2WUSEN.cjs +238 -0
- package/dist/chunk-GPD54HBC.js +380 -0
- package/dist/chunk-HJGC75ZR.js +490 -0
- package/dist/chunk-KCP5ITLV.cjs +412 -0
- package/dist/chunk-M2VZQFTW.cjs +125 -0
- package/dist/chunk-TIC2KT3M.js +146 -0
- package/dist/chunk-UYQZMNZL.js +572 -0
- package/dist/chunk-XKH6F4NE.cjs +604 -0
- package/dist/chunk-YFMAWUII.cjs +502 -0
- package/dist/chunk-Z544XXXK.js +111 -0
- package/dist/index.cjs +194 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +153 -0
- package/dist/server/index.cjs +8446 -0
- package/dist/server/index.d.cts +2 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +8438 -0
- package/dist/services/index.cjs +18 -0
- package/dist/services/index.d.cts +3 -0
- package/dist/services/index.d.ts +3 -0
- package/dist/services/index.js +1 -0
- package/dist/templates/instrumentation-template.js +137 -0
- package/dist/validator/custom-resolver.cjs +52 -0
- package/dist/validator/custom-resolver.d.cts +1 -0
- package/dist/validator/custom-resolver.d.ts +1 -0
- package/dist/validator/custom-resolver.js +50 -0
- package/dist/validator/loader.cjs +7 -0
- package/dist/validator/loader.d.cts +1 -0
- package/dist/validator/loader.d.ts +1 -0
- package/dist/validator/loader.js +4 -0
- package/package.json +5 -5
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkKCP5ITLV_cjs = require('../chunk-KCP5ITLV.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "DepsService", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkKCP5ITLV_cjs.DepsService; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "EnvService", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkKCP5ITLV_cjs.EnvService; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "FileService", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkKCP5ITLV_cjs.FileService; }
|
|
18
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DepsService, EnvService, FileService } from '../chunk-GPD54HBC.js';
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
|
|
2
|
+
import { ExportResultCode } from '@opentelemetry/core';
|
|
3
|
+
import { OTLPTraceExporter as OTLPGrpcExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
|
|
4
|
+
import { OTLPTraceExporter as OTLPHttpExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
5
|
+
import { resourceFromAttributes } from '@opentelemetry/resources';
|
|
6
|
+
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
7
|
+
import {
|
|
8
|
+
ParentBasedSampler,
|
|
9
|
+
TraceIdRatioBasedSampler,
|
|
10
|
+
AlwaysOnSampler,
|
|
11
|
+
AlwaysOffSampler,
|
|
12
|
+
} from '@opentelemetry/sdk-trace-base';
|
|
13
|
+
import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
|
|
14
|
+
import { telemetry } from './telemetry-config.mjs';
|
|
15
|
+
|
|
16
|
+
class CompositeExporter {
|
|
17
|
+
constructor(exporters) {
|
|
18
|
+
this.exporters = exporters;
|
|
19
|
+
}
|
|
20
|
+
export(spans, resultCallback) {
|
|
21
|
+
const telemetryTraceIds = new Set(
|
|
22
|
+
spans.filter((span) => {
|
|
23
|
+
const attrs = span.attributes || {};
|
|
24
|
+
const httpTarget = attrs["http.target"];
|
|
25
|
+
return httpTarget === "/api/telemetry";
|
|
26
|
+
}).map((span) => span.spanContext().traceId)
|
|
27
|
+
);
|
|
28
|
+
const filteredSpans = spans.filter((span) => !telemetryTraceIds.has(span.spanContext().traceId));
|
|
29
|
+
if (filteredSpans.length === 0) {
|
|
30
|
+
resultCallback({ code: ExportResultCode.SUCCESS });
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
void Promise.all(
|
|
34
|
+
this.exporters.map(
|
|
35
|
+
(exporter) => new Promise((resolve) => {
|
|
36
|
+
if (exporter.export) {
|
|
37
|
+
exporter.export(filteredSpans, resolve);
|
|
38
|
+
} else {
|
|
39
|
+
resolve({ code: ExportResultCode.FAILED });
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
)
|
|
43
|
+
).then((results) => {
|
|
44
|
+
const hasError = results.some((r) => r.code === ExportResultCode.FAILED);
|
|
45
|
+
resultCallback({
|
|
46
|
+
code: hasError ? ExportResultCode.FAILED : ExportResultCode.SUCCESS
|
|
47
|
+
});
|
|
48
|
+
}).catch((error) => {
|
|
49
|
+
console.error("[CompositeExporter] Export error:", error);
|
|
50
|
+
resultCallback({ code: ExportResultCode.FAILED, error });
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
shutdown() {
|
|
54
|
+
return Promise.all(this.exporters.map((e) => e.shutdown?.() ?? Promise.resolve())).then(() => void 0);
|
|
55
|
+
}
|
|
56
|
+
forceFlush() {
|
|
57
|
+
return Promise.all(this.exporters.map((e) => e.forceFlush?.() ?? Promise.resolve())).then(() => void 0);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
function getSampler(config) {
|
|
62
|
+
if (!config.sampling) {
|
|
63
|
+
return new AlwaysOnSampler();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!config.enabled) {
|
|
67
|
+
return new AlwaysOffSampler();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
switch (config.sampling.type) {
|
|
71
|
+
case 'ratio':
|
|
72
|
+
return new TraceIdRatioBasedSampler(config.sampling.probability);
|
|
73
|
+
case 'always_on':
|
|
74
|
+
return new AlwaysOnSampler();
|
|
75
|
+
case 'always_off':
|
|
76
|
+
return new AlwaysOffSampler();
|
|
77
|
+
case 'parent_based':
|
|
78
|
+
const rootSampler = new TraceIdRatioBasedSampler(config.sampling.root?.probability || 1.0);
|
|
79
|
+
return new ParentBasedSampler({ root: rootSampler });
|
|
80
|
+
default:
|
|
81
|
+
return new AlwaysOnSampler();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function getExporters(config) {
|
|
86
|
+
const exporters = [];
|
|
87
|
+
|
|
88
|
+
// Add local exporter by default
|
|
89
|
+
if (!config.disableLocalExport) {
|
|
90
|
+
exporters.push(new OTLPHttpExporter({
|
|
91
|
+
url: `http://localhost:${process.env.PORT ?? 4111}/api/telemetry`,
|
|
92
|
+
headers: process.env.MASTRA_DEV ? {
|
|
93
|
+
'x-mastra-dev-playground': 'true',
|
|
94
|
+
} : {},
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (config.export?.type === 'otlp') {
|
|
99
|
+
if (config.export?.protocol === 'grpc') {
|
|
100
|
+
exporters.push(new OTLPGrpcExporter({
|
|
101
|
+
url: config.export.endpoint,
|
|
102
|
+
headers: config.export.headers,
|
|
103
|
+
}));
|
|
104
|
+
} else {
|
|
105
|
+
exporters.push(new OTLPHttpExporter({
|
|
106
|
+
url: config.export.endpoint,
|
|
107
|
+
headers: config.export.headers,
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
} else if (config.export?.type === 'custom') {
|
|
111
|
+
exporters.push(config.export.exporter);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return exporters
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const sampler = getSampler(telemetry);
|
|
118
|
+
const exporters = await getExporters(telemetry);
|
|
119
|
+
const compositeExporter = new CompositeExporter(exporters);
|
|
120
|
+
|
|
121
|
+
const sdk = new NodeSDK({
|
|
122
|
+
resource: resourceFromAttributes({
|
|
123
|
+
[ATTR_SERVICE_NAME]: telemetry.serviceName || 'default-service',
|
|
124
|
+
}),
|
|
125
|
+
sampler,
|
|
126
|
+
traceExporter: compositeExporter,
|
|
127
|
+
instrumentations: [getNodeAutoInstrumentations()],
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
sdk.start();
|
|
131
|
+
|
|
132
|
+
// gracefully shut down the SDK on process exit
|
|
133
|
+
process.on('SIGTERM', () => {
|
|
134
|
+
sdk.shutdown().catch(() => {
|
|
135
|
+
// do nothing
|
|
136
|
+
});
|
|
137
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var promises = require('fs/promises');
|
|
4
|
+
var module$1 = require('module');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
var url = require('url');
|
|
7
|
+
|
|
8
|
+
// src/validator/custom-resolver.ts
|
|
9
|
+
var cache = /* @__PURE__ */ new Map();
|
|
10
|
+
function isBuiltinModule(specifier) {
|
|
11
|
+
return module$1.builtinModules.includes(specifier) || specifier.startsWith("node:") || module$1.builtinModules.includes(specifier.replace(/^node:/, ""));
|
|
12
|
+
}
|
|
13
|
+
function isRelativePath(specifier) {
|
|
14
|
+
return specifier.startsWith("./") || specifier.startsWith("../") || specifier.startsWith("/") || /^[a-zA-Z]:\\/.test(specifier);
|
|
15
|
+
}
|
|
16
|
+
async function getParentPath(specifier, url$1) {
|
|
17
|
+
if (!cache.size) {
|
|
18
|
+
const moduleResolveMap = JSON.parse(
|
|
19
|
+
// cwd refers to the output/build directory
|
|
20
|
+
await promises.readFile(path.join(process.cwd(), "module-resolve-map.json"), "utf-8")
|
|
21
|
+
);
|
|
22
|
+
for (const [id, rest] of Object.entries(moduleResolveMap)) {
|
|
23
|
+
cache.set(url.pathToFileURL(id).toString(), rest);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const importers = cache.get(url$1);
|
|
27
|
+
if (!importers || !importers[specifier]) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const specifierParent = importers[specifier];
|
|
31
|
+
return url.pathToFileURL(specifierParent).toString();
|
|
32
|
+
}
|
|
33
|
+
async function resolve(specifier, context, nextResolve) {
|
|
34
|
+
if (isBuiltinModule(specifier)) {
|
|
35
|
+
return nextResolve(specifier, context);
|
|
36
|
+
}
|
|
37
|
+
if (isRelativePath(specifier)) {
|
|
38
|
+
return nextResolve(specifier, context);
|
|
39
|
+
}
|
|
40
|
+
if (context.parentURL) {
|
|
41
|
+
const parentPath = await getParentPath(specifier, context.parentURL);
|
|
42
|
+
if (parentPath) {
|
|
43
|
+
return nextResolve(specifier, {
|
|
44
|
+
...context,
|
|
45
|
+
parentURL: parentPath
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return nextResolve(specifier, context);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
exports.resolve = resolve;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { resolve } from '../_tsup-dts-rollup.cjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { resolve } from '../_tsup-dts-rollup.js';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { readFile } from 'fs/promises';
|
|
2
|
+
import { builtinModules } from 'module';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { pathToFileURL } from 'url';
|
|
5
|
+
|
|
6
|
+
// src/validator/custom-resolver.ts
|
|
7
|
+
var cache = /* @__PURE__ */ new Map();
|
|
8
|
+
function isBuiltinModule(specifier) {
|
|
9
|
+
return builtinModules.includes(specifier) || specifier.startsWith("node:") || builtinModules.includes(specifier.replace(/^node:/, ""));
|
|
10
|
+
}
|
|
11
|
+
function isRelativePath(specifier) {
|
|
12
|
+
return specifier.startsWith("./") || specifier.startsWith("../") || specifier.startsWith("/") || /^[a-zA-Z]:\\/.test(specifier);
|
|
13
|
+
}
|
|
14
|
+
async function getParentPath(specifier, url) {
|
|
15
|
+
if (!cache.size) {
|
|
16
|
+
const moduleResolveMap = JSON.parse(
|
|
17
|
+
// cwd refers to the output/build directory
|
|
18
|
+
await readFile(join(process.cwd(), "module-resolve-map.json"), "utf-8")
|
|
19
|
+
);
|
|
20
|
+
for (const [id, rest] of Object.entries(moduleResolveMap)) {
|
|
21
|
+
cache.set(pathToFileURL(id).toString(), rest);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const importers = cache.get(url);
|
|
25
|
+
if (!importers || !importers[specifier]) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const specifierParent = importers[specifier];
|
|
29
|
+
return pathToFileURL(specifierParent).toString();
|
|
30
|
+
}
|
|
31
|
+
async function resolve(specifier, context, nextResolve) {
|
|
32
|
+
if (isBuiltinModule(specifier)) {
|
|
33
|
+
return nextResolve(specifier, context);
|
|
34
|
+
}
|
|
35
|
+
if (isRelativePath(specifier)) {
|
|
36
|
+
return nextResolve(specifier, context);
|
|
37
|
+
}
|
|
38
|
+
if (context.parentURL) {
|
|
39
|
+
const parentPath = await getParentPath(specifier, context.parentURL);
|
|
40
|
+
if (parentPath) {
|
|
41
|
+
return nextResolve(specifier, {
|
|
42
|
+
...context,
|
|
43
|
+
parentURL: parentPath
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return nextResolve(specifier, context);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { resolve };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var module$1 = require('module');
|
|
4
|
+
|
|
5
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
6
|
+
// src/validator/loader.ts
|
|
7
|
+
module$1.register("./custom-resolver.js", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('loader.cjs', document.baseURI).href)));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.15-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -108,7 +108,7 @@
|
|
|
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.10.
|
|
111
|
+
"@mastra/server": "^0.10.15-alpha.0"
|
|
112
112
|
},
|
|
113
113
|
"devDependencies": {
|
|
114
114
|
"@hono/node-server": "^1.14.4",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"@types/babel__helper-module-imports": "^7.18.3",
|
|
119
119
|
"@types/fs-extra": "^11.0.4",
|
|
120
120
|
"@types/node": "^20.19.0",
|
|
121
|
-
"eslint": "^9.
|
|
121
|
+
"eslint": "^9.30.1",
|
|
122
122
|
"fetch-to-node": "^2.1.0",
|
|
123
123
|
"hono-openapi": "^0.4.8",
|
|
124
124
|
"rollup-plugin-visualizer": "^5.14.0",
|
|
@@ -127,9 +127,9 @@
|
|
|
127
127
|
"type-fest": "^4.41.0",
|
|
128
128
|
"typescript": "^5.8.3",
|
|
129
129
|
"vitest": "^3.2.4",
|
|
130
|
-
"@mastra/core": "0.10.13",
|
|
131
130
|
"@internal/lint": "0.0.19",
|
|
132
|
-
"@mastra/mcp": "^0.10.6"
|
|
131
|
+
"@mastra/mcp": "^0.10.6",
|
|
132
|
+
"@mastra/core": "0.10.15-alpha.0"
|
|
133
133
|
},
|
|
134
134
|
"peerDependencies": {
|
|
135
135
|
"@mastra/core": ">=0.10.9-0 <0.11.0-0"
|