mastracode 0.32.3-alpha.0 → 0.32.3-alpha.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 +28 -0
- package/dist/acp.cjs +6 -11
- package/dist/acp.js +2 -3
- package/dist/cli.cjs +200 -240
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +200 -234
- package/dist/cli.js.map +1 -1
- package/dist/headless.cjs +6 -11
- package/dist/headless.js +2 -3
- package/dist/index.cjs +6 -11
- package/dist/index.js +2 -3
- package/dist/plugin.cjs +6 -11
- package/dist/plugin.js +2 -3
- package/dist/tui/commands/login.d.ts.map +1 -1
- package/dist/tui/display.d.ts.map +1 -1
- package/dist/tui/mastra-tui.d.ts.map +1 -1
- package/dist/tui/om-defaults.d.ts +8 -0
- package/dist/tui/om-defaults.d.ts.map +1 -0
- package/dist/tui/onboarding-inline.d.ts +4 -1
- package/dist/tui/onboarding-inline.d.ts.map +1 -1
- package/dist/tui-DQUNQTkz.js +21591 -0
- package/dist/tui-DQUNQTkz.js.map +1 -0
- package/dist/tui-G-b6reo7.cjs +21737 -0
- package/dist/tui-G-b6reo7.cjs.map +1 -0
- package/dist/tui.cjs +20 -76
- package/dist/tui.js +2 -3
- package/package.json +13 -13
- package/dist/acp.cjs.map +0 -1
- package/dist/acp.js.map +0 -1
- package/dist/chunk-LDCL2KGF.cjs +0 -21856
- package/dist/chunk-LDCL2KGF.cjs.map +0 -1
- package/dist/chunk-N3CNDPYJ.js +0 -21807
- package/dist/chunk-N3CNDPYJ.js.map +0 -1
- package/dist/headless.cjs.map +0 -1
- package/dist/headless.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/plugin.cjs.map +0 -1
- package/dist/plugin.js.map +0 -1
- package/dist/tui.cjs.map +0 -1
- package/dist/tui.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# mastracode
|
|
2
2
|
|
|
3
|
+
## 0.32.3-alpha.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed observational memory staying on the Gemini default after you sign in to Anthropic or OpenAI. First-run setup and `/login` now select the small, cheap OM model of the provider you just connected, and the TUI tells you when it does. An OM model you picked yourself is never replaced. ([#20291](https://github.com/mastra-ai/mastra/pull/20291))
|
|
8
|
+
|
|
9
|
+
Providers with no cheap OM model (GitHub Copilot, xAI) no longer pin observation and reflection to their full-size coding model — OM stays open so a later login can set it.
|
|
10
|
+
|
|
11
|
+
When an OM run fails, the hint names the model OM is using and keeps the advice for the actual failure, so an authentication error still points at `/login` and a rate limit still tells you to wait, alongside `/memory` to switch OM models.
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`a211d09`](https://github.com/mastra-ai/mastra/commit/a211d09185dc65a746534914cf38b67f21ee9bac), [`f014c26`](https://github.com/mastra-ai/mastra/commit/f014c26f3445118b684e286ee5819b46dfa943a0), [`05db566`](https://github.com/mastra-ai/mastra/commit/05db566fcbdcbf33d0bffca0c72ec30129e2e3ca), [`05db566`](https://github.com/mastra-ai/mastra/commit/05db566fcbdcbf33d0bffca0c72ec30129e2e3ca), [`8dadb6a`](https://github.com/mastra-ai/mastra/commit/8dadb6abfe449b7f8b129663671cc614f2cceeef), [`e075db9`](https://github.com/mastra-ai/mastra/commit/e075db9715c836bae5dfc37c50248492af397c3b), [`8124754`](https://github.com/mastra-ai/mastra/commit/8124754ae89fbc69f8136d1df4a91904d0f84c4e)]:
|
|
14
|
+
- @mastra/core@1.54.0-alpha.2
|
|
15
|
+
- @mastra/code-sdk@1.1.0-alpha.2
|
|
16
|
+
- @mastra/pg@1.18.0-alpha.2
|
|
17
|
+
- @mastra/libsql@1.18.0-alpha.1
|
|
18
|
+
|
|
19
|
+
## 0.32.3-alpha.1
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [[`ce93a3c`](https://github.com/mastra-ai/mastra/commit/ce93a3c114ea1cbfbd576f3db41d7c26c9844f5b), [`5718a22`](https://github.com/mastra-ai/mastra/commit/5718a229281dcfd36bcd1f42a242e3717e510a33), [`5807d3a`](https://github.com/mastra-ai/mastra/commit/5807d3ae1d259b8b7d6df7e5bf2b485c694af9c8), [`57661af`](https://github.com/mastra-ai/mastra/commit/57661afeca52ff9af4e72675ede2134fa503d5a5), [`57661af`](https://github.com/mastra-ai/mastra/commit/57661afeca52ff9af4e72675ede2134fa503d5a5), [`273bb71`](https://github.com/mastra-ai/mastra/commit/273bb71e82e74b656f3906288239429899398c0c), [`57661af`](https://github.com/mastra-ai/mastra/commit/57661afeca52ff9af4e72675ede2134fa503d5a5), [`57661af`](https://github.com/mastra-ai/mastra/commit/57661afeca52ff9af4e72675ede2134fa503d5a5), [`5718a22`](https://github.com/mastra-ai/mastra/commit/5718a229281dcfd36bcd1f42a242e3717e510a33), [`57661af`](https://github.com/mastra-ai/mastra/commit/57661afeca52ff9af4e72675ede2134fa503d5a5), [`d1b7e3a`](https://github.com/mastra-ai/mastra/commit/d1b7e3a978a309a5653eeaa490d2d6c7c53bd093), [`c093146`](https://github.com/mastra-ai/mastra/commit/c0931466404d3c521308ea119cb165bb7e695155), [`d1b7e3a`](https://github.com/mastra-ai/mastra/commit/d1b7e3a978a309a5653eeaa490d2d6c7c53bd093)]:
|
|
24
|
+
- @mastra/core@1.54.0-alpha.1
|
|
25
|
+
- @mastra/pg@1.18.0-alpha.1
|
|
26
|
+
- @mastra/duckdb@1.5.2-alpha.0
|
|
27
|
+
- @mastra/observability@1.16.3-alpha.0
|
|
28
|
+
- @mastra/code-sdk@1.0.3-alpha.1
|
|
29
|
+
- @mastra/mcp@1.15.0
|
|
30
|
+
|
|
3
31
|
## 0.32.3-alpha.0
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/dist/acp.cjs
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.keys(acp).forEach(function (k) {
|
|
8
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
1
|
+
var _mastra_code_sdk_acp = require("@mastra/code-sdk/acp");
|
|
2
|
+
Object.keys(_mastra_code_sdk_acp).forEach(function(k) {
|
|
3
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
9
4
|
enumerable: true,
|
|
10
|
-
get: function
|
|
5
|
+
get: function() {
|
|
6
|
+
return _mastra_code_sdk_acp[k];
|
|
7
|
+
}
|
|
11
8
|
});
|
|
12
9
|
});
|
|
13
|
-
//# sourceMappingURL=acp.cjs.map
|
|
14
|
-
//# sourceMappingURL=acp.cjs.map
|
package/dist/acp.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
|
|
3
|
-
//# sourceMappingURL=acp.js.map
|
|
1
|
+
export * from "@mastra/code-sdk/acp";
|
|
2
|
+
export {};
|
package/dist/cli.cjs
CHANGED
|
@@ -1,275 +1,235 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
-
|
|
18
|
-
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
19
|
-
|
|
2
|
+
const require_tui = require("./tui-G-b6reo7.cjs");
|
|
3
|
+
let _mastra_code_sdk = require("@mastra/code-sdk");
|
|
4
|
+
let fs = require("fs");
|
|
5
|
+
fs = require_tui.__toESM(fs, 1);
|
|
6
|
+
let _mastra_code_sdk_analytics = require("@mastra/code-sdk/analytics");
|
|
7
|
+
let _mastra_code_sdk_error_classification = require("@mastra/code-sdk/error-classification");
|
|
8
|
+
let _mastra_code_sdk_headless_index = require("@mastra/code-sdk/headless/index");
|
|
9
|
+
let _mastra_code_sdk_onboarding_settings = require("@mastra/code-sdk/onboarding/settings");
|
|
10
|
+
let _mastra_code_sdk_plugins_scaffold = require("@mastra/code-sdk/plugins/scaffold");
|
|
11
|
+
let _mastra_code_sdk_utils_debug_log = require("@mastra/code-sdk/utils/debug-log");
|
|
12
|
+
let _mastra_code_sdk_utils_stdin_pipe = require("@mastra/code-sdk/utils/stdin-pipe");
|
|
13
|
+
let _mastra_code_sdk_utils_thread_lock = require("@mastra/code-sdk/utils/thread-lock");
|
|
14
|
+
//#region src/version.ts
|
|
20
15
|
function getCurrentVersion() {
|
|
21
|
-
|
|
22
|
-
return "0.32.3-alpha.0";
|
|
23
|
-
}
|
|
16
|
+
return "0.32.3-alpha.2";
|
|
24
17
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/main.ts
|
|
20
|
+
/**
|
|
21
|
+
* Main entry point for Mastra Code TUI.
|
|
22
|
+
*/
|
|
23
|
+
let controller;
|
|
24
|
+
let mcpManager;
|
|
25
|
+
let hookManager;
|
|
26
|
+
let authStorage;
|
|
27
|
+
let signalsPubSub;
|
|
28
|
+
let storageMaintenance;
|
|
29
|
+
let analytics;
|
|
30
|
+
let tui;
|
|
31
|
+
let storageClosed = false;
|
|
36
32
|
function isTruthyEnv(name) {
|
|
37
|
-
|
|
33
|
+
return [
|
|
34
|
+
"1",
|
|
35
|
+
"true",
|
|
36
|
+
"yes",
|
|
37
|
+
"on"
|
|
38
|
+
].includes(process.env[name]?.trim().toLowerCase() ?? "");
|
|
38
39
|
}
|
|
39
40
|
function resolveInitialStateFromEnv() {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
const currentModelId = process.env.MASTRACODE_MODEL_ID?.trim();
|
|
42
|
+
const initialState = {};
|
|
43
|
+
if (currentModelId) initialState.currentModelId = currentModelId;
|
|
44
|
+
if (isTruthyEnv("MASTRACODE_YOLO")) initialState.yolo = true;
|
|
45
|
+
return Object.keys(initialState).length > 0 ? initialState : void 0;
|
|
45
46
|
}
|
|
46
47
|
process.on("uncaughtException", (error) => {
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
if ((0, _mastra_code_sdk_error_classification.isStreamDestroyedError)(error)) return;
|
|
49
|
+
handleFatalError(error);
|
|
49
50
|
});
|
|
50
51
|
process.on("unhandledRejection", (reason) => {
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
if ((0, _mastra_code_sdk_error_classification.isStreamDestroyedError)(reason)) return;
|
|
53
|
+
handleFatalError(reason instanceof Error ? reason : new Error(String(reason)));
|
|
53
54
|
});
|
|
54
55
|
async function tuiMain(pipedInput) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
});
|
|
125
|
-
tui.run().catch((error) => {
|
|
126
|
-
handleFatalError(error);
|
|
127
|
-
});
|
|
128
|
-
if (settings$1.browser.enabled) {
|
|
129
|
-
void loadBrowser().then((browser) => {
|
|
130
|
-
if (!browser) return;
|
|
131
|
-
controller.setBrowser(browser);
|
|
132
|
-
void session.state.set({ activeBrowserSettings: settings$1.browser }).catch(() => {
|
|
133
|
-
});
|
|
134
|
-
}).catch(() => {
|
|
135
|
-
});
|
|
136
|
-
}
|
|
56
|
+
const settings = (0, _mastra_code_sdk_onboarding_settings.loadSettings)();
|
|
57
|
+
let browserPromise;
|
|
58
|
+
const loadBrowser = () => {
|
|
59
|
+
browserPromise ??= (0, _mastra_code_sdk_onboarding_settings.createBrowserFromSettings)(settings.browser);
|
|
60
|
+
return browserPromise;
|
|
61
|
+
};
|
|
62
|
+
const initialState = resolveInitialStateFromEnv();
|
|
63
|
+
const result = await (0, _mastra_code_sdk.createMastraCode)({
|
|
64
|
+
unixSocketPubSub: !isTruthyEnv("MASTRACODE_DISABLE_UNIX_SOCKET_PUBSUB"),
|
|
65
|
+
disableMcp: isTruthyEnv("MASTRACODE_DISABLE_MCP"),
|
|
66
|
+
disableHooks: isTruthyEnv("MASTRACODE_DISABLE_HOOKS"),
|
|
67
|
+
...isTruthyEnv("MASTRACODE_DISABLE_MEMORY") ? { memory: false } : {},
|
|
68
|
+
...initialState ? { initialState } : {}
|
|
69
|
+
});
|
|
70
|
+
controller = result.controller;
|
|
71
|
+
mcpManager = result.mcpManager;
|
|
72
|
+
hookManager = result.hookManager;
|
|
73
|
+
authStorage = result.authStorage;
|
|
74
|
+
signalsPubSub = result.signalsPubSub;
|
|
75
|
+
storageMaintenance = result.storageMaintenance;
|
|
76
|
+
if (result.storageWarning) console.info(`⚠ ${result.storageWarning}`);
|
|
77
|
+
if (result.observabilityWarning) console.info(`⚠ ${result.observabilityWarning}`);
|
|
78
|
+
(0, _mastra_code_sdk_utils_debug_log.setupDebugLogging)();
|
|
79
|
+
const envTheme = process.env.MASTRA_THEME?.toLowerCase();
|
|
80
|
+
let themeMode;
|
|
81
|
+
let detectedBgHex;
|
|
82
|
+
if (envTheme === "dark" || envTheme === "light") themeMode = envTheme;
|
|
83
|
+
else {
|
|
84
|
+
const themePref = (0, _mastra_code_sdk_onboarding_settings.loadSettings)().preferences.theme;
|
|
85
|
+
if (themePref === "dark" || themePref === "light") themeMode = themePref;
|
|
86
|
+
else {
|
|
87
|
+
const detection = await require_tui.detectTerminalTheme();
|
|
88
|
+
themeMode = detection.mode;
|
|
89
|
+
detectedBgHex = detection.detectedBgHex;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
require_tui.applyThemeMode(themeMode, detectedBgHex);
|
|
93
|
+
const session = result.session;
|
|
94
|
+
analytics = (0, _mastra_code_sdk_analytics.createMastraCodeAnalytics)({ version: getCurrentVersion() });
|
|
95
|
+
analytics.capture("mastracode_session_started", {
|
|
96
|
+
mode: session.mode.get(),
|
|
97
|
+
resourceId: session.identity.getResourceId(),
|
|
98
|
+
hasAuthStorage: Boolean(authStorage),
|
|
99
|
+
hasMcp: Boolean(mcpManager),
|
|
100
|
+
theme: themeMode
|
|
101
|
+
});
|
|
102
|
+
tui = new require_tui.MastraTUI({
|
|
103
|
+
controller,
|
|
104
|
+
session,
|
|
105
|
+
hookManager,
|
|
106
|
+
analytics,
|
|
107
|
+
authStorage,
|
|
108
|
+
mcpManager,
|
|
109
|
+
pluginManager: result.pluginManager,
|
|
110
|
+
storageMaintenance: result.storageMaintenance,
|
|
111
|
+
appName: "Mastra Code",
|
|
112
|
+
version: getCurrentVersion(),
|
|
113
|
+
inlineQuestions: true,
|
|
114
|
+
githubSignals: result.githubSignals,
|
|
115
|
+
...pipedInput ? { initialMessage: `The following was piped via stdin:\n\n${pipedInput}` } : {}
|
|
116
|
+
});
|
|
117
|
+
tui.run().catch((error) => {
|
|
118
|
+
handleFatalError(error);
|
|
119
|
+
});
|
|
120
|
+
if (settings.browser.enabled) loadBrowser().then((browser) => {
|
|
121
|
+
if (!browser) return;
|
|
122
|
+
controller.setBrowser(browser);
|
|
123
|
+
session.state.set({ activeBrowserSettings: settings.browser }).catch(() => {});
|
|
124
|
+
}).catch(() => {});
|
|
137
125
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
126
|
+
const asyncCleanup = async () => {
|
|
127
|
+
(0, _mastra_code_sdk_utils_thread_lock.releaseAllThreadLocks)();
|
|
128
|
+
const closeSignalsPubSub = signalsPubSub?.close;
|
|
129
|
+
await Promise.allSettled([
|
|
130
|
+
mcpManager?.disconnect(),
|
|
131
|
+
controller?.getMastra()?.stopWorkers(),
|
|
132
|
+
controller?.stopIntervals(),
|
|
133
|
+
closeSignalsPubSub?.(),
|
|
134
|
+
analytics?.shutdown()
|
|
135
|
+
]);
|
|
136
|
+
if (!storageClosed) {
|
|
137
|
+
storageClosed = true;
|
|
138
|
+
await storageMaintenance?.closeStorage?.().catch(() => {});
|
|
139
|
+
}
|
|
153
140
|
};
|
|
154
141
|
process.on("beforeExit", () => {
|
|
155
|
-
|
|
142
|
+
asyncCleanup();
|
|
156
143
|
});
|
|
157
144
|
process.on("exit", () => {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
if (process.stdin.setRawMode) {
|
|
168
|
-
process.stdin.setRawMode(false);
|
|
169
|
-
}
|
|
170
|
-
} catch {
|
|
171
|
-
}
|
|
172
|
-
chunkLDCL2KGF_cjs.restoreTerminalForeground();
|
|
173
|
-
threadLock.releaseAllThreadLocks();
|
|
145
|
+
try {
|
|
146
|
+
tui?.stop();
|
|
147
|
+
} catch {}
|
|
148
|
+
try {
|
|
149
|
+
process.stdout.write("\x1B[?2004l\x1B[<u\x1B[>4;0m\x1B[?25h");
|
|
150
|
+
if (process.stdin.setRawMode) process.stdin.setRawMode(false);
|
|
151
|
+
} catch {}
|
|
152
|
+
require_tui.restoreTerminalForeground();
|
|
153
|
+
(0, _mastra_code_sdk_utils_thread_lock.releaseAllThreadLocks)();
|
|
174
154
|
});
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
void asyncCleanup().finally(() => process.exit(0));
|
|
155
|
+
const handleTermSignal = () => {
|
|
156
|
+
try {
|
|
157
|
+
tui?.stop();
|
|
158
|
+
} catch {}
|
|
159
|
+
asyncCleanup().finally(() => process.exit(0));
|
|
181
160
|
};
|
|
182
161
|
process.on("SIGINT", handleTermSignal);
|
|
183
162
|
process.on("SIGTERM", handleTermSignal);
|
|
184
163
|
process.on("SIGHUP", handleTermSignal);
|
|
185
164
|
function hasEconnrefused(err, depth = 0) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
165
|
+
if (!err || depth > 5) return false;
|
|
166
|
+
const e = err;
|
|
167
|
+
if (e.code === "ECONNREFUSED") return true;
|
|
168
|
+
if (e.cause) return hasEconnrefused(e.cause, depth + 1);
|
|
169
|
+
if (Array.isArray(e.errors)) return e.errors.some((inner) => hasEconnrefused(inner, depth + 1));
|
|
170
|
+
return false;
|
|
192
171
|
}
|
|
193
172
|
function pluginMain(args) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
173
|
+
if (args[0] !== "scaffold") {
|
|
174
|
+
process.stderr.write("Usage: mastracode plugin scaffold <dir> [--id acme.foo] [--name \"Foo Tools\"]\n");
|
|
175
|
+
process.exit(1);
|
|
176
|
+
}
|
|
177
|
+
const dir = args[1];
|
|
178
|
+
if (!dir) {
|
|
179
|
+
process.stderr.write("Usage: mastracode plugin scaffold <dir> [--id acme.foo] [--name \"Foo Tools\"]\n");
|
|
180
|
+
process.exit(1);
|
|
181
|
+
}
|
|
182
|
+
const id = readFlag(args, "--id");
|
|
183
|
+
const name = readFlag(args, "--name");
|
|
184
|
+
const targetDir = (0, _mastra_code_sdk_plugins_scaffold.scaffoldPlugin)(dir, {
|
|
185
|
+
...id ? { id } : {},
|
|
186
|
+
...name ? { name } : {}
|
|
187
|
+
});
|
|
188
|
+
process.stdout.write(`${(0, _mastra_code_sdk_plugins_scaffold.formatScaffoldSuccess)(targetDir)}\n`);
|
|
208
189
|
}
|
|
209
190
|
function readFlag(args, flag) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
return value;
|
|
191
|
+
const index = args.indexOf(flag);
|
|
192
|
+
if (index === -1) return void 0;
|
|
193
|
+
const value = args[index + 1];
|
|
194
|
+
if (!value || value.startsWith("--")) throw new Error(`Missing value for ${flag}`);
|
|
195
|
+
return value;
|
|
217
196
|
}
|
|
218
197
|
function handleFatalError(error) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
);
|
|
233
|
-
process.exit(1);
|
|
234
|
-
}
|
|
235
|
-
const msg = `Fatal error: ${error instanceof Error ? error.message : String(error)}`;
|
|
236
|
-
write(msg);
|
|
237
|
-
try {
|
|
238
|
-
const crashLog = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${msg}
|
|
239
|
-
${error instanceof Error && error.stack ? error.stack + "\n" : ""}`;
|
|
240
|
-
fs__default.default.appendFileSync("/tmp/mastra-crash.log", crashLog);
|
|
241
|
-
} catch {
|
|
242
|
-
}
|
|
243
|
-
if (error instanceof Error && error.stack) {
|
|
244
|
-
write(error.stack);
|
|
245
|
-
}
|
|
246
|
-
process.exit(1);
|
|
198
|
+
const write = (msg) => process.stderr.write(msg + "\n");
|
|
199
|
+
if (hasEconnrefused(error)) {
|
|
200
|
+
write(`\nFailed to connect to PostgreSQL at ${(0, _mastra_code_sdk_onboarding_settings.loadSettings)().storage?.pg?.connectionString ?? "localhost:5432"}.\nMake sure the database is running and accessible.\n\nTo switch back to LibSQL:\n Set MASTRA_STORAGE_BACKEND=libsql or change the backend in /settings\n`);
|
|
201
|
+
process.exit(1);
|
|
202
|
+
}
|
|
203
|
+
const msg = `Fatal error: ${error instanceof Error ? error.message : String(error)}`;
|
|
204
|
+
write(msg);
|
|
205
|
+
try {
|
|
206
|
+
const crashLog = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${msg}\n${error instanceof Error && error.stack ? error.stack + "\n" : ""}`;
|
|
207
|
+
fs.default.appendFileSync("/tmp/mastra-crash.log", crashLog);
|
|
208
|
+
} catch {}
|
|
209
|
+
if (error instanceof Error && error.stack) write(error.stack);
|
|
210
|
+
process.exit(1);
|
|
247
211
|
}
|
|
248
212
|
async function main() {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
process.stderr.write("No TTY available \u2014 falling back to headless mode.\n");
|
|
266
|
-
return index.runMCCli(pipedInput);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
return tuiMain(pipedInput);
|
|
213
|
+
if (process.argv[2] === "plugin") return pluginMain(process.argv.slice(3));
|
|
214
|
+
if ((0, _mastra_code_sdk_headless_index.hasHeadlessFlag)(process.argv) || process.argv.includes("--help") || process.argv.includes("-h")) return (0, _mastra_code_sdk_headless_index.runMCCli)();
|
|
215
|
+
if (process.argv.includes("--acp")) {
|
|
216
|
+
const { acpMain } = await import("@mastra/code-sdk/acp/index");
|
|
217
|
+
return acpMain({ dangerousAutoApprove: process.argv.includes("--dangerous-auto-approve") });
|
|
218
|
+
}
|
|
219
|
+
let pipedInput = null;
|
|
220
|
+
if (!process.stdin.isTTY) {
|
|
221
|
+
process.stderr.write("Reading piped input...\n");
|
|
222
|
+
pipedInput = await (0, _mastra_code_sdk_utils_stdin_pipe.drainPipedStdin)();
|
|
223
|
+
if (!(0, _mastra_code_sdk_utils_stdin_pipe.reopenStdinFromTTY)()) {
|
|
224
|
+
process.stderr.write("No TTY available — falling back to headless mode.\n");
|
|
225
|
+
return (0, _mastra_code_sdk_headless_index.runMCCli)(pipedInput);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return tuiMain(pipedInput);
|
|
270
229
|
}
|
|
271
230
|
main().catch((error) => {
|
|
272
|
-
|
|
231
|
+
handleFatalError(error);
|
|
273
232
|
});
|
|
274
|
-
//#
|
|
233
|
+
//#endregion
|
|
234
|
+
|
|
275
235
|
//# sourceMappingURL=cli.cjs.map
|