mastra 1.9.2-alpha.2 → 1.9.2
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/CHANGELOG.md +66 -0
- package/dist/analytics/index.js +1 -1
- package/dist/{chunk-7P7J7HCD.js → chunk-LZZOW7IH.js} +9 -7
- package/dist/chunk-LZZOW7IH.js.map +1 -0
- package/dist/{chunk-X3CD6TSG.js → chunk-MVHERJCK.js} +14 -6
- package/dist/chunk-MVHERJCK.js.map +1 -0
- package/dist/commands/actions/create-project.d.ts.map +1 -1
- package/dist/commands/actions/init-project.d.ts.map +1 -1
- package/dist/commands/api/index.d.ts.map +1 -1
- package/dist/commands/api/route-metadata.generated.d.ts +14 -0
- package/dist/commands/api/route-metadata.generated.d.ts.map +1 -1
- package/dist/commands/create/create.d.ts.map +1 -1
- package/dist/commands/create/create.js +2 -2
- package/dist/commands/create/utils.d.ts +7 -1
- package/dist/commands/create/utils.d.ts.map +1 -1
- package/dist/commands/init/utils.d.ts +9 -1
- package/dist/commands/init/utils.d.ts.map +1 -1
- package/dist/commands/server/deploy.d.ts.map +1 -1
- package/dist/commands/studio/deploy.d.ts.map +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +4 -4
- package/dist/docs/references/reference-cli-mastra.md +2 -1
- package/dist/index.js +149 -15
- package/dist/index.js.map +1 -1
- package/dist/studio/assets/{index-ByTje4Bn.js → index-BRXd0NqA.js} +1 -1
- package/dist/studio/assets/{index-B24oOxHS.js → index-BWEYa6Wd.js} +1 -1
- package/dist/studio/assets/{index-BHuOCO43.js → index-BggFNwvl.js} +1 -1
- package/dist/studio/assets/{index-DMol6fsb.js → index-C3PhGaQE.js} +1 -1
- package/dist/studio/assets/{index-DwgQJh00.js → index-C5SMdEFe.js} +1 -1
- package/dist/studio/assets/{index-DVeNgWKz.js → index-C5vFkLuK.js} +1 -1
- package/dist/studio/assets/{index-Bam0E0TT.js → index-CE9VBs4g.js} +1 -1
- package/dist/studio/assets/{index-QfN3P6Mp.js → index-CQiypF1C.js} +1 -1
- package/dist/studio/assets/{index-Bs5zE_pf.js → index-CRI1b2G-.js} +1 -1
- package/dist/studio/assets/{index-QHvMhU_K.js → index-CstG7jfi.js} +1 -1
- package/dist/studio/assets/{index-B60s3NFS.js → index-D51SkQfg.js} +1 -1
- package/dist/studio/assets/{index-B5JiNrav.js → index-DOktXLS1.js} +1 -1
- package/dist/studio/assets/{index-Fju80PoZ.js → index-Djon9qXR.js} +1 -1
- package/dist/studio/assets/{index-DXhJ16KZ.js → index-FWLFiKw6.js} +1 -1
- package/dist/studio/assets/{index-C-89c9VE.js → index-Fdm11Ab_.js} +1 -1
- package/dist/studio/assets/{index-DKHpHjJ7.js → index-JR4jl4o8.js} +1 -1
- package/dist/studio/assets/{index-CxoAr1EP.js → index-L9uGVUzS.js} +1 -1
- package/dist/studio/assets/{index-CFILG-d5.js → index-QbEQSBCz.js} +1 -1
- package/dist/studio/assets/{main-DGlYsN7R.js → main-l_gW9ha-.js} +135 -135
- package/dist/studio/index.html +1 -1
- package/package.json +7 -7
- package/dist/chunk-7P7J7HCD.js.map +0 -1
- package/dist/chunk-X3CD6TSG.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
import { package_default, create, init, logger, createLogger, listOrgsAction, resolveCurrentOrg, switchOrgAction } from './chunk-
|
|
3
|
-
export { create } from './chunk-
|
|
4
|
-
import { PosthogAnalytics, setAnalytics, COMPONENTS, parseComponents, LLMProvider, parseLlmProvider, parseMcp, parseSkills, checkForPkgJson, getVersionTag, isGitInitialized, checkAndInstallCoreDeps, interactivePrompt, FileService, shouldSkipDotenvLoading, getAnalytics, DepsService } from './chunk-
|
|
5
|
-
export { PosthogAnalytics } from './chunk-
|
|
2
|
+
import { package_default, create, init, logger, createLogger, listOrgsAction, resolveCurrentOrg, switchOrgAction } from './chunk-LZZOW7IH.js';
|
|
3
|
+
export { create } from './chunk-LZZOW7IH.js';
|
|
4
|
+
import { PosthogAnalytics, setAnalytics, COMPONENTS, parseComponents, LLMProvider, parseLlmProvider, parseMcp, parseSkills, checkForPkgJson, getVersionTag, isGitInitialized, checkAndInstallCoreDeps, interactivePrompt, FileService, shouldSkipDotenvLoading, getAnalytics, DepsService } from './chunk-MVHERJCK.js';
|
|
5
|
+
export { PosthogAnalytics } from './chunk-MVHERJCK.js';
|
|
6
6
|
import { fetchOrgs } from './chunk-4Z57PBTZ.js';
|
|
7
7
|
import { getToken, getCurrentOrgId, validateOrgAccess, loadCredentials, verifyToken, tryRefreshToken, login, clearCredentials } from './chunk-EXG3XKBK.js';
|
|
8
8
|
import { platformFetch, MASTRA_PLATFORM_API_URL, authHeaders, throwApiError, MASTRA_STUDIO_URL, createApiClient, extractApiErrorDetail } from './chunk-L2SGSIJI.js';
|
|
@@ -757,6 +757,14 @@ var buildProject = async (args) => {
|
|
|
757
757
|
var origin3 = process.env.MASTRA_ANALYTICS_ORIGIN;
|
|
758
758
|
var createProject = async (projectNameArg, args) => {
|
|
759
759
|
const projectName = projectNameArg || args.projectName;
|
|
760
|
+
if (args.observability !== void 0) {
|
|
761
|
+
analytics.trackEvent("cli_observability_selected", {
|
|
762
|
+
command: "create",
|
|
763
|
+
enabled: args.observability,
|
|
764
|
+
answer: args.observability ? "yes" : "no",
|
|
765
|
+
selection_method: "cli_args"
|
|
766
|
+
});
|
|
767
|
+
}
|
|
760
768
|
await analytics.trackCommandExecution({
|
|
761
769
|
command: "create",
|
|
762
770
|
args: { ...args, projectName },
|
|
@@ -799,6 +807,14 @@ var createProject = async (projectNameArg, args) => {
|
|
|
799
807
|
// src/commands/actions/init-project.ts
|
|
800
808
|
var origin4 = process.env.MASTRA_ANALYTICS_ORIGIN;
|
|
801
809
|
var initProject = async (args) => {
|
|
810
|
+
if (args.observability !== void 0) {
|
|
811
|
+
analytics.trackEvent("cli_observability_selected", {
|
|
812
|
+
command: "init",
|
|
813
|
+
enabled: args.observability,
|
|
814
|
+
answer: args.observability ? "yes" : "no",
|
|
815
|
+
selection_method: "cli_args"
|
|
816
|
+
});
|
|
817
|
+
}
|
|
802
818
|
await analytics.trackCommandExecution({
|
|
803
819
|
command: "init",
|
|
804
820
|
args: { ...args },
|
|
@@ -808,7 +824,13 @@ var initProject = async (args) => {
|
|
|
808
824
|
const skipGitInit = await isGitInitialized({ cwd: process.cwd() });
|
|
809
825
|
await checkAndInstallCoreDeps(Boolean(args?.example || args?.default), versionTag);
|
|
810
826
|
if (!Object.keys(args).length) {
|
|
811
|
-
const result = await interactivePrompt({
|
|
827
|
+
const result = await interactivePrompt({
|
|
828
|
+
options: {
|
|
829
|
+
command: "init",
|
|
830
|
+
onObservabilitySelected: (event) => analytics.trackEvent("cli_observability_selected", event)
|
|
831
|
+
},
|
|
832
|
+
skip: { gitInit: skipGitInit }
|
|
833
|
+
});
|
|
812
834
|
await init({
|
|
813
835
|
...result,
|
|
814
836
|
llmApiKey: result?.llmApiKey,
|
|
@@ -1525,7 +1547,16 @@ async function resolveProject(token, orgId, projectConfig, flagProject, defaultN
|
|
|
1525
1547
|
}
|
|
1526
1548
|
if (flagProject) {
|
|
1527
1549
|
const projects2 = await fetchProjects(token, orgId);
|
|
1528
|
-
const
|
|
1550
|
+
const byId = projects2.find((proj) => proj.id === flagProject);
|
|
1551
|
+
const bySlug = projects2.find((proj) => proj.slug === flagProject);
|
|
1552
|
+
const byName = projects2.filter((proj) => proj.name === flagProject);
|
|
1553
|
+
if (!byId && !bySlug && byName.length > 1) {
|
|
1554
|
+
p5.cancel(
|
|
1555
|
+
`Multiple projects are named "${flagProject}". Pass --project with the project id or slug to disambiguate.`
|
|
1556
|
+
);
|
|
1557
|
+
process.exit(1);
|
|
1558
|
+
}
|
|
1559
|
+
const match = byId ?? bySlug ?? (byName.length === 1 ? byName[0] : void 0);
|
|
1529
1560
|
if (match) {
|
|
1530
1561
|
return { existing: true, projectId: match.id, projectName: match.name, projectSlug: match.slug ?? match.name };
|
|
1531
1562
|
}
|
|
@@ -5386,6 +5417,59 @@ var API_ROUTE_METADATA = {
|
|
|
5386
5417
|
"paginationProperty": "pagination"
|
|
5387
5418
|
}
|
|
5388
5419
|
},
|
|
5420
|
+
"GET /observability/traces/light": {
|
|
5421
|
+
"method": "GET",
|
|
5422
|
+
"path": "/observability/traces/light",
|
|
5423
|
+
"pathParams": [],
|
|
5424
|
+
"queryParams": [
|
|
5425
|
+
"dateRange",
|
|
5426
|
+
"direction",
|
|
5427
|
+
"endedAt",
|
|
5428
|
+
"entityId",
|
|
5429
|
+
"entityName",
|
|
5430
|
+
"entityType",
|
|
5431
|
+
"entityVersionId",
|
|
5432
|
+
"environment",
|
|
5433
|
+
"experimentId",
|
|
5434
|
+
"field",
|
|
5435
|
+
"hasChildError",
|
|
5436
|
+
"metadata",
|
|
5437
|
+
"name",
|
|
5438
|
+
"organizationId",
|
|
5439
|
+
"page",
|
|
5440
|
+
"parentEntityId",
|
|
5441
|
+
"parentEntityName",
|
|
5442
|
+
"parentEntityType",
|
|
5443
|
+
"parentEntityVersionId",
|
|
5444
|
+
"perPage",
|
|
5445
|
+
"requestId",
|
|
5446
|
+
"resourceId",
|
|
5447
|
+
"rootEntityId",
|
|
5448
|
+
"rootEntityName",
|
|
5449
|
+
"rootEntityType",
|
|
5450
|
+
"rootEntityVersionId",
|
|
5451
|
+
"runId",
|
|
5452
|
+
"scope",
|
|
5453
|
+
"serviceName",
|
|
5454
|
+
"sessionId",
|
|
5455
|
+
"source",
|
|
5456
|
+
"spanType",
|
|
5457
|
+
"startedAt",
|
|
5458
|
+
"status",
|
|
5459
|
+
"tags",
|
|
5460
|
+
"threadId",
|
|
5461
|
+
"traceId",
|
|
5462
|
+
"userId"
|
|
5463
|
+
],
|
|
5464
|
+
"bodyParams": [],
|
|
5465
|
+
"hasQuery": true,
|
|
5466
|
+
"hasBody": false,
|
|
5467
|
+
"responseShape": {
|
|
5468
|
+
"kind": "object-property",
|
|
5469
|
+
"listProperty": "spans",
|
|
5470
|
+
"paginationProperty": "pagination"
|
|
5471
|
+
}
|
|
5472
|
+
},
|
|
5389
5473
|
"GET /observability/branches": {
|
|
5390
5474
|
"method": "GET",
|
|
5391
5475
|
"path": "/observability/branches",
|
|
@@ -9353,7 +9437,15 @@ function registerApiCommand(program2) {
|
|
|
9353
9437
|
]
|
|
9354
9438
|
});
|
|
9355
9439
|
const trace = api.command("trace").description("Inspect observability traces");
|
|
9356
|
-
addAction(trace, "list", "GET /observability/traces", {
|
|
9440
|
+
addAction(trace, "list", "GET /observability/traces/light", {
|
|
9441
|
+
description: "List observability traces",
|
|
9442
|
+
list: true,
|
|
9443
|
+
verboseRouteKey: "GET /observability/traces",
|
|
9444
|
+
examples: [
|
|
9445
|
+
{ description: "List lightweight traces", command: `mastra api trace list '{"page":0,"perPage":20}'` },
|
|
9446
|
+
{ description: "List full traces", command: `mastra api trace list '{"page":0,"perPage":20}' --verbose` }
|
|
9447
|
+
]
|
|
9448
|
+
});
|
|
9357
9449
|
addAction(trace, "get", "GET /observability/traces/:traceId/light", {
|
|
9358
9450
|
description: "Get trace details",
|
|
9359
9451
|
verboseRouteKey: "GET /observability/traces/:traceId",
|
|
@@ -9625,6 +9717,9 @@ function parseCommandName(name) {
|
|
|
9625
9717
|
function isUnauthorizedError(error) {
|
|
9626
9718
|
return error instanceof ApiCliError && error.code === "HTTP_ERROR" && error.details.status === 401;
|
|
9627
9719
|
}
|
|
9720
|
+
function isNotFoundError(error) {
|
|
9721
|
+
return error instanceof ApiCliError && error.code === "HTTP_ERROR" && (error.details.status === 404 || error.details.status === 405);
|
|
9722
|
+
}
|
|
9628
9723
|
async function shutdownApiAnalytics(analytics2) {
|
|
9629
9724
|
if (!analytics2) {
|
|
9630
9725
|
return;
|
|
@@ -9658,14 +9753,33 @@ async function executeDescriptor(descriptor, positionalValues, inputText, option
|
|
|
9658
9753
|
input: requestInput
|
|
9659
9754
|
};
|
|
9660
9755
|
let response;
|
|
9756
|
+
let effectiveDescriptor = requestDescriptor;
|
|
9661
9757
|
try {
|
|
9662
9758
|
response = await requestApi(requestOptions);
|
|
9663
9759
|
} catch (error) {
|
|
9664
|
-
if (
|
|
9665
|
-
|
|
9760
|
+
if (target.fallbackHeaders && isUnauthorizedError(error)) {
|
|
9761
|
+
response = await requestApi({ ...requestOptions, headers: target.fallbackHeaders });
|
|
9762
|
+
} else if (!options.verbose && descriptor.verbose && isNotFoundError(error)) {
|
|
9763
|
+
const verboseDescriptor = { ...descriptor, ...descriptor.verbose };
|
|
9764
|
+
const verboseInput = parseInput(verboseDescriptor, inputText);
|
|
9765
|
+
const verbosePathParams = resolvePathParams(verboseDescriptor, positionalValues, verboseInput);
|
|
9766
|
+
const verboseRequestInput = stripPathParamsFromInput(verboseInput, verbosePathParams);
|
|
9767
|
+
response = await requestApi({
|
|
9768
|
+
...requestOptions,
|
|
9769
|
+
descriptor: verboseDescriptor,
|
|
9770
|
+
pathParams: verbosePathParams,
|
|
9771
|
+
input: verboseRequestInput
|
|
9772
|
+
});
|
|
9773
|
+
effectiveDescriptor = verboseDescriptor;
|
|
9774
|
+
} else {
|
|
9775
|
+
throw error;
|
|
9776
|
+
}
|
|
9666
9777
|
}
|
|
9667
|
-
const normalized = normalizeData(
|
|
9668
|
-
writeJson(
|
|
9778
|
+
const normalized = normalizeData(effectiveDescriptor, normalizeResponse(response));
|
|
9779
|
+
writeJson(
|
|
9780
|
+
normalizeSuccess(normalized, effectiveDescriptor.list, effectiveDescriptor.responseShape),
|
|
9781
|
+
options.pretty
|
|
9782
|
+
);
|
|
9669
9783
|
} catch (error) {
|
|
9670
9784
|
const apiError = error instanceof ApiCliError ? error : toApiCliError(error);
|
|
9671
9785
|
writeJson(errorEnvelope(apiError), options.pretty, process.stderr);
|
|
@@ -9956,11 +10070,31 @@ async function resolveProject2(token, orgId, projectConfig, flagProject, default
|
|
|
9956
10070
|
}
|
|
9957
10071
|
if (flagProject) {
|
|
9958
10072
|
const projects = await fetchServerProjects(token, orgId);
|
|
9959
|
-
const
|
|
10073
|
+
const byId = projects.find((proj) => proj.id === flagProject);
|
|
10074
|
+
const bySlug = projects.find((proj) => proj.slug === flagProject);
|
|
10075
|
+
const byName = projects.filter((proj) => proj.name === flagProject);
|
|
10076
|
+
if (!byId && !bySlug && byName.length > 1) {
|
|
10077
|
+
p5.cancel(
|
|
10078
|
+
`Multiple projects are named "${flagProject}". Pass --project with the project id or slug to disambiguate.`
|
|
10079
|
+
);
|
|
10080
|
+
process.exit(1);
|
|
10081
|
+
}
|
|
10082
|
+
const match = byId ?? bySlug ?? (byName.length === 1 ? byName[0] : void 0);
|
|
9960
10083
|
if (match) {
|
|
9961
10084
|
return { projectId: match.id, projectName: match.name, projectSlug: match.slug ?? match.name };
|
|
9962
10085
|
}
|
|
9963
|
-
|
|
10086
|
+
if (!autoAccept) {
|
|
10087
|
+
const confirmed = await p5.confirm({
|
|
10088
|
+
message: `No project named "${flagProject}" found. Create it?`
|
|
10089
|
+
});
|
|
10090
|
+
if (p5.isCancel(confirmed) || !confirmed) {
|
|
10091
|
+
p5.cancel("Deploy cancelled.");
|
|
10092
|
+
process.exit(0);
|
|
10093
|
+
}
|
|
10094
|
+
}
|
|
10095
|
+
const created = await createServerProject(token, orgId, flagProject);
|
|
10096
|
+
p5.log.success(`Created project "${created.name}"`);
|
|
10097
|
+
return { projectId: created.id, projectName: created.name, projectSlug: created.slug ?? created.name };
|
|
9964
10098
|
}
|
|
9965
10099
|
if (projectConfig?.projectId && projectConfig.organizationId === orgId) {
|
|
9966
10100
|
return {
|
|
@@ -10940,7 +11074,7 @@ program.command("start").description("Start your built Mastra application").opti
|
|
|
10940
11074
|
"Comma-separated list of custom arguments to pass to the Node.js process. IE: --require=newrelic"
|
|
10941
11075
|
).action(startProject);
|
|
10942
11076
|
var studioCommand = program.command("studio").description("Manage Mastra Studio").option("-p, --port <port>", "Port to run the studio on (default: 3000)").option("-e, --env <env>", "Custom env file to include in the studio").option("-h, --server-host <serverHost>", "Host of the Mastra API server (default: localhost)").option("-s, --server-port <serverPort>", "Port of the Mastra API server (default: 4111)").option("-x, --server-protocol <serverProtocol>", "Protocol of the Mastra API server (default: http)").option("--server-api-prefix <serverApiPrefix>", "API route prefix of the Mastra server (default: /api)").option("--request-context-presets <file>", "Path to request context presets JSON file").action(startStudio);
|
|
10943
|
-
var deployCommand = studioCommand.command("deploy [dir]").description("Deploy studio").option("--org <id>", "Organization ID").option("--project <id>", "Project ID").option("-y, --yes", "Auto-accept defaults without confirmation").option("-c, --config <file>", "Project config file path (default: .mastra-project.json)").option("--env-file <file>", "Env file to deploy (for example: .env.production)").option("--skip-build", "Skip the build step and use existing .mastra/output").option("--skip-preflight", "Skip the pre-deploy build/env validation").option("--debug", "Enable debug logs", false).action(wrapAction(deployAction));
|
|
11077
|
+
var deployCommand = studioCommand.command("deploy [dir]").description("Deploy studio").option("--org <id>", "Organization ID").option("--project <id>", "Project ID, slug, or name (creates new project if not found)").option("-y, --yes", "Auto-accept defaults without confirmation").option("-c, --config <file>", "Project config file path (default: .mastra-project.json)").option("--env-file <file>", "Env file to deploy (for example: .env.production)").option("--skip-build", "Skip the build step and use existing .mastra/output").option("--skip-preflight", "Skip the pre-deploy build/env validation").option("--debug", "Enable debug logs", false).action(wrapAction(deployAction));
|
|
10944
11078
|
deployCommand.command("list").description("List deployed studios").action(wrapAction(deploysAction));
|
|
10945
11079
|
deployCommand.command("status <deploy-id>").description("Show deploy status").option("-w, --watch", "Watch for status changes").action(wrapAction(statusAction));
|
|
10946
11080
|
deployCommand.command("logs <deploy-id>").description("Show deploy logs").option("-f, --follow", "Stream logs in real time").option("--tail <n>", "Number of recent log lines").action(wrapAction(logsAction));
|
|
@@ -10963,7 +11097,7 @@ var authTokens = authCommand.command("tokens").description("Manage API tokens").
|
|
|
10963
11097
|
authTokens.command("create <name>").description("Create a new API token").action(wrapAction(createTokenAction));
|
|
10964
11098
|
authTokens.command("revoke <token-id>").description("Revoke an API token").action(wrapAction(revokeTokenAction));
|
|
10965
11099
|
var serverCommand = program.command("server").description("Manage Mastra Server deployments");
|
|
10966
|
-
var serverDeployCommand = serverCommand.command("deploy [dir]").description("Deploy to Mastra Server").option("--org <id>", "Organization ID").option("--project <id>", "Project ID").option("-y, --yes", "Auto-accept defaults without confirmation").option("-c, --config <file>", "Project config file path (default: .mastra-project.json)").option("--env-file <file>", "Env file to deploy (for example: .env.production)").option("--skip-build", "Skip the build step and deploy the existing .mastra/output directory").option("--skip-preflight", "Skip the pre-deploy build/env validation").option("--debug", "Enable debug logs", false).action(wrapAction(serverDeployAction));
|
|
11100
|
+
var serverDeployCommand = serverCommand.command("deploy [dir]").description("Deploy to Mastra Server").option("--org <id>", "Organization ID").option("--project <id>", "Project ID, slug, or name (creates new project if not found)").option("-y, --yes", "Auto-accept defaults without confirmation").option("-c, --config <file>", "Project config file path (default: .mastra-project.json)").option("--env-file <file>", "Env file to deploy (for example: .env.production)").option("--skip-build", "Skip the build step and deploy the existing .mastra/output directory").option("--skip-preflight", "Skip the pre-deploy build/env validation").option("--debug", "Enable debug logs", false).action(wrapAction(serverDeployAction));
|
|
10967
11101
|
if (coreFeatures.has("deploy-diagnosis")) {
|
|
10968
11102
|
serverDeployCommand.command("suggestions [deploy-id]").description("Show deploy suggestions for a failed deploy").option("--org <id>", "Organization ID").action(wrapAction(serverSuggestionsAction));
|
|
10969
11103
|
}
|