@mastra/code-sdk 0.2.0-alpha.3 → 0.2.0-alpha.4
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
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @mastra/code-sdk
|
|
2
2
|
|
|
3
|
+
## 0.2.0-alpha.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Added on-disk verification to the update utilities: `runUpdate` now returns the package manager's stderr, and the new `performUpdate` locates the running install, delegates the update to the tool that owns it (for example vite-plus), verifies the on-disk version when available, and reports when a readable installed version remains unchanged. ([#18792](https://github.com/mastra-ai/mastra/pull/18792))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`4cfdd64`](https://github.com/mastra-ai/mastra/commit/4cfdd645794feaea0c4ea711e70ecdfbef0c5b8e)]:
|
|
10
|
+
- @mastra/core@1.52.0-alpha.4
|
|
11
|
+
|
|
3
12
|
## 0.2.0-alpha.3
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -44,9 +44,58 @@ export declare function fetchChangelog(version: string): Promise<string | null>;
|
|
|
44
44
|
* as a concise bullet list suitable for terminal display.
|
|
45
45
|
*/
|
|
46
46
|
export declare function parseChangelog(markdown: string, version: string): string | null;
|
|
47
|
+
/** Result of attempting an auto-update: exit status plus captured stderr. */
|
|
48
|
+
export interface UpdateResult {
|
|
49
|
+
ok: boolean;
|
|
50
|
+
stderr?: string;
|
|
51
|
+
}
|
|
47
52
|
/**
|
|
48
53
|
* Run the appropriate global install command to update mastracode.
|
|
49
|
-
*
|
|
54
|
+
* Exit code 0 does not prove the running binary changed (the install may land
|
|
55
|
+
* in a location the PATH shim doesn't use) — verify with {@link locateOwnInstall}.
|
|
50
56
|
*/
|
|
51
|
-
export declare function runUpdate(pm: PackageManager, targetVersion: string): Promise<
|
|
57
|
+
export declare function runUpdate(pm: PackageManager, targetVersion: string): Promise<UpdateResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Find the installed mastracode package the running binary belongs to (walking
|
|
60
|
+
* up from `process.argv[1]`) and read its version fresh from disk. Returns
|
|
61
|
+
* null when it can't be determined, e.g. when running from source.
|
|
62
|
+
*/
|
|
63
|
+
export declare function locateOwnInstall(): {
|
|
64
|
+
dir: string;
|
|
65
|
+
version: string | null;
|
|
66
|
+
} | null;
|
|
67
|
+
export type UpdateOutcome = {
|
|
68
|
+
status: 'updated';
|
|
69
|
+
message: string;
|
|
70
|
+
} | {
|
|
71
|
+
status: 'unchanged';
|
|
72
|
+
message: string;
|
|
73
|
+
} | {
|
|
74
|
+
status: 'failed';
|
|
75
|
+
message: string;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Decide what to tell the user after {@link runUpdate}: `updated` when the
|
|
79
|
+
* on-disk version matches the target (or can't be determined), `unchanged`
|
|
80
|
+
* when the package manager succeeded but the running install didn't change,
|
|
81
|
+
* `failed` on error (with the package manager's stderr).
|
|
82
|
+
*/
|
|
83
|
+
export declare function resolveUpdateOutcome(opts: {
|
|
84
|
+
pm: PackageManager;
|
|
85
|
+
targetVersion: string;
|
|
86
|
+
result: UpdateResult;
|
|
87
|
+
install: {
|
|
88
|
+
dir: string;
|
|
89
|
+
version: string | null;
|
|
90
|
+
} | null;
|
|
91
|
+
/** Overrides the suggested manual command, e.g. when the update was delegated to the owning tool. */
|
|
92
|
+
manualCommand?: string;
|
|
93
|
+
}): UpdateOutcome;
|
|
94
|
+
/**
|
|
95
|
+
* Update mastracode and verify the result: delegates to the tool that owns the
|
|
96
|
+
* running install when we recognize it, skips the install when it isn't
|
|
97
|
+
* managed by `pm`, otherwise runs the package manager. Every executed update
|
|
98
|
+
* is verified against the on-disk version.
|
|
99
|
+
*/
|
|
100
|
+
export declare function performUpdate(pm: PackageManager, targetVersion: string): Promise<UpdateOutcome>;
|
|
52
101
|
//# sourceMappingURL=update-check.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-check.d.ts","sourceRoot":"","sources":["../../src/utils/update-check.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"update-check.d.ts","sourceRoot":"","sources":["../../src/utils/update-check.ts"],"names":[],"mappings":"AAAA;;GAEG;AAmBH,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAW7D;;;;;;;;;;GAUG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,cAAc,CAAC,CA+CpE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAY9E;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAS1C;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAcjE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAevE;AAKD;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAe5E;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAiD/E;AAED,6EAA6E;AAC7E,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAE1F;AA0CD;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,CA6BjF;AAED,MAAM,MAAM,aAAa,GACrB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACxC;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE;IACzC,EAAE,EAAE,cAAc,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IACxD,qGAAqG;IACrG,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GAAG,aAAa,CAsBhB;AAuDD;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,EAAE,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAoCrG"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
2
|
import { readFileSync, realpathSync } from "node:fs";
|
|
3
|
-
import {
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { dirname, join, resolve, sep } from "node:path";
|
|
4
5
|
import { fileURLToPath } from "node:url";
|
|
5
6
|
const PACKAGE_NAME = "mastracode";
|
|
6
7
|
const NPM_REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
|
|
7
8
|
const FETCH_TIMEOUT_MS = 5e3;
|
|
9
|
+
const USE_SHELL = process.platform === "win32";
|
|
8
10
|
function matchPM(str) {
|
|
9
11
|
if (/pnpm/i.test(str)) return "pnpm";
|
|
10
12
|
if (/\byarn\b/i.test(str)) return "yarn";
|
|
@@ -37,9 +39,14 @@ async function detectPackageManager() {
|
|
|
37
39
|
} catch {
|
|
38
40
|
}
|
|
39
41
|
const pnpmResult = await new Promise((resolve2) => {
|
|
40
|
-
execFile(
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
execFile(
|
|
43
|
+
"pnpm",
|
|
44
|
+
["list", "-g", "--depth=0", PACKAGE_NAME],
|
|
45
|
+
{ timeout: 3e3, shell: USE_SHELL },
|
|
46
|
+
(error, stdout) => {
|
|
47
|
+
resolve2(!error && stdout.includes(PACKAGE_NAME));
|
|
48
|
+
}
|
|
49
|
+
);
|
|
43
50
|
});
|
|
44
51
|
if (pnpmResult) return "pnpm";
|
|
45
52
|
return "npm";
|
|
@@ -144,10 +151,17 @@ function parseChangelog(markdown, version) {
|
|
|
144
151
|
return entries.map((e) => ` \u2022 ${e}`).join("\n");
|
|
145
152
|
}
|
|
146
153
|
function runUpdate(pm, targetVersion) {
|
|
147
|
-
|
|
154
|
+
return execUpdate(pm, buildInstallArgs(pm, targetVersion));
|
|
155
|
+
}
|
|
156
|
+
function execUpdate(cmd, args) {
|
|
148
157
|
return new Promise((resolve2) => {
|
|
149
|
-
execFile(
|
|
150
|
-
|
|
158
|
+
execFile(cmd, args, { timeout: 6e4, shell: USE_SHELL }, (error, _stdout, stderr) => {
|
|
159
|
+
const captured = (stderr ?? "").trim();
|
|
160
|
+
if (error) {
|
|
161
|
+
resolve2({ ok: false, stderr: captured || error.message });
|
|
162
|
+
} else {
|
|
163
|
+
resolve2({ ok: true, stderr: captured || void 0 });
|
|
164
|
+
}
|
|
151
165
|
});
|
|
152
166
|
});
|
|
153
167
|
}
|
|
@@ -164,6 +178,113 @@ function buildInstallArgs(pm, version) {
|
|
|
164
178
|
return ["install", "-g", pkg];
|
|
165
179
|
}
|
|
166
180
|
}
|
|
181
|
+
const MAX_UPDATE_ERROR_LINES = 5;
|
|
182
|
+
function formatUpdaterError(stderr) {
|
|
183
|
+
if (!stderr) return null;
|
|
184
|
+
const lines = stderr.split("\n").map((line) => line.trimEnd()).filter((line) => line.trim().length > 0);
|
|
185
|
+
if (lines.length === 0) return null;
|
|
186
|
+
return lines.slice(-MAX_UPDATE_ERROR_LINES).join("\n");
|
|
187
|
+
}
|
|
188
|
+
function locateOwnInstall() {
|
|
189
|
+
const entry = process.argv[1];
|
|
190
|
+
if (!entry) return null;
|
|
191
|
+
let dir;
|
|
192
|
+
try {
|
|
193
|
+
dir = dirname(realpathSync(entry));
|
|
194
|
+
} catch {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
let previous = "";
|
|
198
|
+
while (dir && dir !== previous) {
|
|
199
|
+
try {
|
|
200
|
+
const pkg = JSON.parse(readFileSync(resolve(dir, "package.json"), "utf-8"));
|
|
201
|
+
if (pkg.name === PACKAGE_NAME) {
|
|
202
|
+
return { dir, version: typeof pkg.version === "string" ? pkg.version : null };
|
|
203
|
+
}
|
|
204
|
+
} catch {
|
|
205
|
+
}
|
|
206
|
+
previous = dir;
|
|
207
|
+
dir = dirname(dir);
|
|
208
|
+
}
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
function resolveUpdateOutcome(opts) {
|
|
212
|
+
const { pm, targetVersion, result, install } = opts;
|
|
213
|
+
const cmd = opts.manualCommand ?? getInstallCommand(pm, targetVersion);
|
|
214
|
+
if (!result.ok) {
|
|
215
|
+
const details = formatUpdaterError(result.stderr);
|
|
216
|
+
let message = `Auto-update failed. Run \`${cmd}\` manually.`;
|
|
217
|
+
if (details) message += `
|
|
218
|
+
|
|
219
|
+
${details}`;
|
|
220
|
+
return { status: "failed", message };
|
|
221
|
+
}
|
|
222
|
+
if (install?.version != null && install.version !== targetVersion) {
|
|
223
|
+
const message = opts.manualCommand ? `The update ran, but the Mastra Code you are running (at ${install.dir}) is still v${install.version}. Try \`${cmd}\` manually.` : `The update installed, but the Mastra Code you are running (at ${install.dir}) is still v${install.version} \u2014 it looks like it is managed by another tool. Update it with that tool, or try \`${cmd}\`.`;
|
|
224
|
+
return { status: "unchanged", message };
|
|
225
|
+
}
|
|
226
|
+
return { status: "updated", message: `Updated to v${targetVersion}. Please restart Mastra Code.` };
|
|
227
|
+
}
|
|
228
|
+
function getGlobalRoot(pm) {
|
|
229
|
+
const args = pm === "yarn" ? ["global", "dir"] : ["root", "-g"];
|
|
230
|
+
return new Promise((res) => {
|
|
231
|
+
execFile(pm, args, { timeout: 1e4, shell: USE_SHELL }, (error, stdout) => {
|
|
232
|
+
const out = (stdout ?? "").trim().split("\n").pop()?.trim();
|
|
233
|
+
if (error || !out) return res(null);
|
|
234
|
+
res(pm === "yarn" ? resolve(out, "node_modules") : out);
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
async function isOwnInstallManagedBy(pm, install) {
|
|
239
|
+
if (!install) return true;
|
|
240
|
+
const root = await getGlobalRoot(pm);
|
|
241
|
+
if (!root) return true;
|
|
242
|
+
try {
|
|
243
|
+
return realpathSync(resolve(root, PACKAGE_NAME)) === install.dir;
|
|
244
|
+
} catch {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
function findInstallOwner(dir, version) {
|
|
249
|
+
if (dir.startsWith(join(homedir(), ".vite-plus") + sep)) {
|
|
250
|
+
return {
|
|
251
|
+
name: "vite-plus",
|
|
252
|
+
exec: { cmd: "vp", args: ["install", "-g", `${PACKAGE_NAME}@${version}`] },
|
|
253
|
+
command: `vp install -g ${PACKAGE_NAME}@${version}`
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
if (dir.split(sep).includes("Cellar")) {
|
|
257
|
+
return { name: "Homebrew", command: `brew upgrade ${PACKAGE_NAME}` };
|
|
258
|
+
}
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
async function performUpdate(pm, targetVersion) {
|
|
262
|
+
if (!/^[\w.+-]+$/.test(targetVersion)) {
|
|
263
|
+
return { status: "failed", message: `Auto-update aborted: unexpected version "${targetVersion}".` };
|
|
264
|
+
}
|
|
265
|
+
const install = locateOwnInstall();
|
|
266
|
+
const owner = install ? findInstallOwner(install.dir, targetVersion) : null;
|
|
267
|
+
if (owner) {
|
|
268
|
+
if (!owner.exec) {
|
|
269
|
+
const message = `Your Mastra Code install (at ${install.dir}) is managed by ${owner.name}. Update it with \`${owner.command}\`.`;
|
|
270
|
+
return { status: "unchanged", message };
|
|
271
|
+
}
|
|
272
|
+
const result2 = await execUpdate(owner.exec.cmd, owner.exec.args);
|
|
273
|
+
return resolveUpdateOutcome({
|
|
274
|
+
pm,
|
|
275
|
+
targetVersion,
|
|
276
|
+
result: result2,
|
|
277
|
+
install: locateOwnInstall(),
|
|
278
|
+
manualCommand: owner.command
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
if (!await isOwnInstallManagedBy(pm, install)) {
|
|
282
|
+
const message = `Your Mastra Code install (at ${install.dir}) is not managed by ${pm} \u2014 it looks like it was installed by another tool. Update it with that tool, or try \`${getInstallCommand(pm, targetVersion)}\`.`;
|
|
283
|
+
return { status: "unchanged", message };
|
|
284
|
+
}
|
|
285
|
+
const result = await runUpdate(pm, targetVersion);
|
|
286
|
+
return resolveUpdateOutcome({ pm, targetVersion, result, install: locateOwnInstall() });
|
|
287
|
+
}
|
|
167
288
|
export {
|
|
168
289
|
detectPackageManager,
|
|
169
290
|
fetchChangelog,
|
|
@@ -171,7 +292,10 @@ export {
|
|
|
171
292
|
getCurrentVersion,
|
|
172
293
|
getInstallCommand,
|
|
173
294
|
isNewerVersion,
|
|
295
|
+
locateOwnInstall,
|
|
174
296
|
parseChangelog,
|
|
297
|
+
performUpdate,
|
|
298
|
+
resolveUpdateOutcome,
|
|
175
299
|
runUpdate
|
|
176
300
|
};
|
|
177
301
|
//# sourceMappingURL=update-check.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/update-check.ts"],"sourcesContent":["/**\n * Check for newer versions of mastracode on npm.\n */\n\nimport { execFile } from 'node:child_process';\nimport { readFileSync, realpathSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\ndeclare const MASTRACODE_VERSION: string | undefined;\n\nconst PACKAGE_NAME = 'mastracode';\nconst NPM_REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;\n\n/** Timeout for the npm registry fetch (ms). */\nconst FETCH_TIMEOUT_MS = 5_000;\n\nexport type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun';\n\nfunction matchPM(str: string): PackageManager | null {\n // Order matters: check pnpm before npm since \"npm\" is a substring of some paths\n if (/pnpm/i.test(str)) return 'pnpm';\n if (/\\byarn\\b/i.test(str)) return 'yarn';\n if (/\\bbun\\b/i.test(str)) return 'bun';\n if (/\\bnpm\\b/i.test(str)) return 'npm';\n return null;\n}\n\n/**\n * Detect which package manager was used to install mastracode globally.\n *\n * Uses a multi-tier approach:\n * 1. npm_config_user_agent env var (set when run via `pnpm run`, `npm run`, etc.)\n * 2. npm_execpath env var (fallback for script-based invocation)\n * 3. NODE_PATH env var (set by pnpm global bin stubs)\n * 4. Resolved path of the running script (process.argv[1])\n * 5. Shell-out to `pnpm list -g` to check if pnpm manages the package\n * 6. Falls back to 'npm'\n */\nexport async function detectPackageManager(): Promise<PackageManager> {\n // Tier 1: npm_config_user_agent (most reliable when available)\n const userAgent = process.env.npm_config_user_agent;\n if (userAgent) {\n const pm = matchPM(userAgent);\n if (pm) return pm;\n }\n\n // Tier 2: npm_execpath\n const execPath = process.env.npm_execpath;\n if (execPath) {\n const pm = matchPM(execPath);\n if (pm) return pm;\n }\n\n // Tier 3: NODE_PATH (pnpm global stubs set this to paths containing .pnpm)\n const nodePath = process.env.NODE_PATH;\n if (nodePath) {\n if (/[/\\\\]\\.pnpm[/\\\\]/.test(nodePath) || /[/\\\\]pnpm[/\\\\]/.test(nodePath)) return 'pnpm';\n if (/[/\\\\]\\.yarn[/\\\\]/.test(nodePath)) return 'yarn';\n if (/[/\\\\]\\.bun[/\\\\]/.test(nodePath)) return 'bun';\n }\n\n // Tier 4: Resolved script path\n try {\n const scriptPath = realpathSync(process.argv[1] ?? '');\n if (/[/\\\\]\\.?pnpm[/\\\\]/.test(scriptPath)) return 'pnpm';\n if (/[/\\\\]\\.?yarn[/\\\\]/.test(scriptPath)) return 'yarn';\n if (/[/\\\\]\\.?bun[/\\\\]/.test(scriptPath)) return 'bun';\n } catch {\n // realpathSync can fail if argv[1] is missing/broken — fall through\n }\n\n // Tier 5: Check if the package is in pnpm's global store (non-blocking)\n const pnpmResult = await new Promise<boolean>(resolve => {\n execFile('pnpm', ['list', '-g', '--depth=0', PACKAGE_NAME], { timeout: 3_000 }, (error, stdout) => {\n resolve(!error && stdout.includes(PACKAGE_NAME));\n });\n });\n if (pnpmResult) return 'pnpm';\n\n return 'npm';\n}\n\n/**\n * Build the shell command string a user would run to install/update globally.\n */\nexport function getInstallCommand(pm: PackageManager, version?: string): string {\n const pkg = version ? `${PACKAGE_NAME}@${version}` : `${PACKAGE_NAME}@latest`;\n switch (pm) {\n case 'pnpm':\n return `pnpm add -g ${pkg}`;\n case 'yarn':\n return `yarn global add ${pkg}`;\n case 'bun':\n return `bun add -g ${pkg}`;\n default:\n return `npm install -g ${pkg}`;\n }\n}\n\n/**\n * Read the current version, injected at build time by tsup's `define` option.\n * Falls back to reading package.json at runtime (e.g. when running from source with tsx).\n */\nexport function getCurrentVersion(): string {\n if (typeof MASTRACODE_VERSION !== 'undefined') {\n return MASTRACODE_VERSION;\n }\n // Fallback for running from source (e.g. pnpx tsx mastracode/src/main.ts)\n const dir = dirname(fileURLToPath(import.meta.url));\n const pkgPath = resolve(dir, '../../package.json');\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));\n return pkg.version;\n}\n\n/**\n * Fetch the latest published version from npm.\n * Returns null if the fetch fails (network error, timeout, etc.).\n */\nexport async function fetchLatestVersion(): Promise<string | null> {\n if (process.env.MASTRACODE_UPDATE_LATEST_VERSION) return process.env.MASTRACODE_UPDATE_LATEST_VERSION;\n\n try {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);\n const res = await fetch(NPM_REGISTRY_URL, { signal: controller.signal });\n clearTimeout(timeout);\n if (!res.ok) return null;\n const data = (await res.json()) as { version?: string };\n return data.version ?? null;\n } catch {\n return null;\n }\n}\n\n/**\n * Simple semver comparison: returns true if `latest` is newer than `current`.\n * Handles standard x.y.z versions. Ignores pre-release tags.\n */\nexport function isNewerVersion(current: string, latest: string): boolean {\n const parse = (v: string) =>\n v\n .replace(/^v/, '')\n .split('-')[0]!\n .split('.')\n .map(s => {\n const n = Number(s);\n return Number.isFinite(n) ? n : 0;\n });\n const [cMajor = 0, cMinor = 0, cPatch = 0] = parse(current);\n const [lMajor = 0, lMinor = 0, lPatch = 0] = parse(latest);\n if (lMajor !== cMajor) return lMajor > cMajor;\n if (lMinor !== cMinor) return lMinor > cMinor;\n return lPatch > cPatch;\n}\n\n/** Max entries to show in the changelog summary. */\nconst MAX_CHANGELOG_ENTRIES = 20;\n\n/**\n * Fetch the CHANGELOG.md for a specific published version from the npm CDN\n * and extract a human-readable summary of changes.\n * Returns null if the fetch fails or the changelog can't be parsed.\n */\nexport async function fetchChangelog(version: string): Promise<string | null> {\n if (process.env.MASTRACODE_UPDATE_CHANGELOG) return process.env.MASTRACODE_UPDATE_CHANGELOG;\n\n try {\n const url = `https://unpkg.com/${PACKAGE_NAME}@${version}/CHANGELOG.md`;\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);\n const res = await fetch(url, { signal: controller.signal });\n clearTimeout(timeout);\n if (!res.ok) return null;\n const text = await res.text();\n return parseChangelog(text, version);\n } catch {\n return null;\n }\n}\n\n/**\n * Extract the changelog section for a specific version and format it\n * as a concise bullet list suitable for terminal display.\n */\nexport function parseChangelog(markdown: string, version: string): string | null {\n const versionHeader = `## ${version}`;\n const startIdx = markdown.indexOf(versionHeader);\n if (startIdx === -1) return null;\n\n const afterHeader = startIdx + versionHeader.length;\n const nextHeaderIdx = markdown.indexOf('\\n## ', afterHeader);\n const section = nextHeaderIdx === -1 ? markdown.slice(afterHeader) : markdown.slice(afterHeader, nextHeaderIdx);\n\n const lines = section.split('\\n');\n const entries: string[] = [];\n let skipIndented = false;\n\n for (let i = 0; i < lines.length; i++) {\n const raw = lines[i]!;\n const trimmed = raw.trim();\n\n // Only match top-level entries (no leading whitespace before \"- \")\n const isTopLevel = raw === trimmed && trimmed.startsWith('- ');\n if (!isTopLevel) {\n // Skip indented sub-items (e.g. dependency list entries)\n if (skipIndented && /^\\s+-\\s/.test(raw)) continue;\n skipIndented = false;\n continue;\n }\n\n // Skip dependency update entries and their sub-items\n if (/^- Updated dependenc/i.test(trimmed)) {\n skipIndented = true;\n continue;\n }\n skipIndented = false;\n\n let entry = trimmed.slice(2);\n // Strip markdown links: [text](url) → text\n entry = entry.replace(/\\[([^\\]]+)\\]\\([^)]+\\)/g, '$1');\n // Strip PR references like (#15760)\n entry = entry.replace(/\\s*\\(#\\d+\\)\\s*/g, ' ');\n // Strip commit SHA references like (`abc123`)\n entry = entry.replace(/\\s*\\(`[a-f0-9]+`\\)\\s*/g, ' ');\n // Trim trailing periods for cleaner bullet display\n entry = entry.replace(/\\.\\s*$/, '');\n entry = entry.trim();\n if (entry) entries.push(entry);\n if (entries.length >= MAX_CHANGELOG_ENTRIES) break;\n }\n\n if (entries.length === 0) return null;\n return entries.map(e => ` • ${e}`).join('\\n');\n}\n\n/**\n * Run the appropriate global install command to update mastracode.\n * Returns true on success, false on failure.\n */\nexport function runUpdate(pm: PackageManager, targetVersion: string): Promise<boolean> {\n const args = buildInstallArgs(pm, targetVersion);\n return new Promise(resolve => {\n execFile(pm, args, { timeout: 60_000 }, error => {\n resolve(!error);\n });\n });\n}\n\nfunction buildInstallArgs(pm: PackageManager, version: string): string[] {\n const pkg = `${PACKAGE_NAME}@${version}`;\n switch (pm) {\n case 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KAAK;AACH,aAAO,CAAC,OAAO,MAAM,GAAG;AAAA,IAC1B,KAAK;AACH,aAAO,CAAC,UAAU,OAAO,GAAG;AAAA,IAC9B,KAAK;AACH,aAAO,CAAC,OAAO,MAAM,GAAG;AAAA,IAC1B;AACE,aAAO,CAAC,WAAW,MAAM,GAAG;AAAA,EAChC;AACF;","names":["resolve"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/update-check.ts"],"sourcesContent":["/**\n * Check for newer versions of mastracode on npm.\n */\n\nimport { execFile } from 'node:child_process';\nimport { readFileSync, realpathSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { dirname, join, resolve, sep } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\ndeclare const MASTRACODE_VERSION: string | undefined;\n\nconst PACKAGE_NAME = 'mastracode';\nconst NPM_REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;\n\n/** Timeout for the npm registry fetch (ms). */\nconst FETCH_TIMEOUT_MS = 5_000;\n\n// Package managers and vp are .cmd shims on Windows; execFile can't spawn those without a shell (EINVAL).\nconst USE_SHELL = process.platform === 'win32';\n\nexport type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun';\n\nfunction matchPM(str: string): PackageManager | null {\n // Order matters: check pnpm before npm since \"npm\" is a substring of some paths\n if (/pnpm/i.test(str)) return 'pnpm';\n if (/\\byarn\\b/i.test(str)) return 'yarn';\n if (/\\bbun\\b/i.test(str)) return 'bun';\n if (/\\bnpm\\b/i.test(str)) return 'npm';\n return null;\n}\n\n/**\n * Detect which package manager was used to install mastracode globally.\n *\n * Uses a multi-tier approach:\n * 1. npm_config_user_agent env var (set when run via `pnpm run`, `npm run`, etc.)\n * 2. npm_execpath env var (fallback for script-based invocation)\n * 3. NODE_PATH env var (set by pnpm global bin stubs)\n * 4. Resolved path of the running script (process.argv[1])\n * 5. Shell-out to `pnpm list -g` to check if pnpm manages the package\n * 6. Falls back to 'npm'\n */\nexport async function detectPackageManager(): Promise<PackageManager> {\n // Tier 1: npm_config_user_agent (most reliable when available)\n const userAgent = process.env.npm_config_user_agent;\n if (userAgent) {\n const pm = matchPM(userAgent);\n if (pm) return pm;\n }\n\n // Tier 2: npm_execpath\n const execPath = process.env.npm_execpath;\n if (execPath) {\n const pm = matchPM(execPath);\n if (pm) return pm;\n }\n\n // Tier 3: NODE_PATH (pnpm global stubs set this to paths containing .pnpm)\n const nodePath = process.env.NODE_PATH;\n if (nodePath) {\n if (/[/\\\\]\\.pnpm[/\\\\]/.test(nodePath) || /[/\\\\]pnpm[/\\\\]/.test(nodePath)) return 'pnpm';\n if (/[/\\\\]\\.yarn[/\\\\]/.test(nodePath)) return 'yarn';\n if (/[/\\\\]\\.bun[/\\\\]/.test(nodePath)) return 'bun';\n }\n\n // Tier 4: Resolved script path\n try {\n const scriptPath = realpathSync(process.argv[1] ?? '');\n if (/[/\\\\]\\.?pnpm[/\\\\]/.test(scriptPath)) return 'pnpm';\n if (/[/\\\\]\\.?yarn[/\\\\]/.test(scriptPath)) return 'yarn';\n if (/[/\\\\]\\.?bun[/\\\\]/.test(scriptPath)) return 'bun';\n } catch {\n // realpathSync can fail if argv[1] is missing/broken — fall through\n }\n\n // Tier 5: Check if the package is in pnpm's global store (non-blocking)\n const pnpmResult = await new Promise<boolean>(resolve => {\n execFile(\n 'pnpm',\n ['list', '-g', '--depth=0', PACKAGE_NAME],\n { timeout: 3_000, shell: USE_SHELL },\n (error, stdout) => {\n resolve(!error && stdout.includes(PACKAGE_NAME));\n },\n );\n });\n if (pnpmResult) return 'pnpm';\n\n return 'npm';\n}\n\n/**\n * Build the shell command string a user would run to install/update globally.\n */\nexport function getInstallCommand(pm: PackageManager, version?: string): string {\n const pkg = version ? `${PACKAGE_NAME}@${version}` : `${PACKAGE_NAME}@latest`;\n switch (pm) {\n case 'pnpm':\n return `pnpm add -g ${pkg}`;\n case 'yarn':\n return `yarn global add ${pkg}`;\n case 'bun':\n return `bun add -g ${pkg}`;\n default:\n return `npm install -g ${pkg}`;\n }\n}\n\n/**\n * Read the current version, injected at build time by tsup's `define` option.\n * Falls back to reading package.json at runtime (e.g. when running from source with tsx).\n */\nexport function getCurrentVersion(): string {\n if (typeof MASTRACODE_VERSION !== 'undefined') {\n return MASTRACODE_VERSION;\n }\n // Fallback for running from source (e.g. pnpx tsx mastracode/src/main.ts)\n const dir = dirname(fileURLToPath(import.meta.url));\n const pkgPath = resolve(dir, '../../package.json');\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));\n return pkg.version;\n}\n\n/**\n * Fetch the latest published version from npm.\n * Returns null if the fetch fails (network error, timeout, etc.).\n */\nexport async function fetchLatestVersion(): Promise<string | null> {\n if (process.env.MASTRACODE_UPDATE_LATEST_VERSION) return process.env.MASTRACODE_UPDATE_LATEST_VERSION;\n\n try {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);\n const res = await fetch(NPM_REGISTRY_URL, { signal: controller.signal });\n clearTimeout(timeout);\n if (!res.ok) return null;\n const data = (await res.json()) as { version?: string };\n return data.version ?? null;\n } catch {\n return null;\n }\n}\n\n/**\n * Simple semver comparison: returns true if `latest` is newer than `current`.\n * Handles standard x.y.z versions. Ignores pre-release tags.\n */\nexport function isNewerVersion(current: string, latest: string): boolean {\n const parse = (v: string) =>\n v\n .replace(/^v/, '')\n .split('-')[0]!\n .split('.')\n .map(s => {\n const n = Number(s);\n return Number.isFinite(n) ? n : 0;\n });\n const [cMajor = 0, cMinor = 0, cPatch = 0] = parse(current);\n const [lMajor = 0, lMinor = 0, lPatch = 0] = parse(latest);\n if (lMajor !== cMajor) return lMajor > cMajor;\n if (lMinor !== cMinor) return lMinor > cMinor;\n return lPatch > cPatch;\n}\n\n/** Max entries to show in the changelog summary. */\nconst MAX_CHANGELOG_ENTRIES = 20;\n\n/**\n * Fetch the CHANGELOG.md for a specific published version from the npm CDN\n * and extract a human-readable summary of changes.\n * Returns null if the fetch fails or the changelog can't be parsed.\n */\nexport async function fetchChangelog(version: string): Promise<string | null> {\n if (process.env.MASTRACODE_UPDATE_CHANGELOG) return process.env.MASTRACODE_UPDATE_CHANGELOG;\n\n try {\n const url = `https://unpkg.com/${PACKAGE_NAME}@${version}/CHANGELOG.md`;\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);\n const res = await fetch(url, { signal: controller.signal });\n clearTimeout(timeout);\n if (!res.ok) return null;\n const text = await res.text();\n return parseChangelog(text, version);\n } catch {\n return null;\n }\n}\n\n/**\n * Extract the changelog section for a specific version and format it\n * as a concise bullet list suitable for terminal display.\n */\nexport function parseChangelog(markdown: string, version: string): string | null {\n const versionHeader = `## ${version}`;\n const startIdx = markdown.indexOf(versionHeader);\n if (startIdx === -1) return null;\n\n const afterHeader = startIdx + versionHeader.length;\n const nextHeaderIdx = markdown.indexOf('\\n## ', afterHeader);\n const section = nextHeaderIdx === -1 ? markdown.slice(afterHeader) : markdown.slice(afterHeader, nextHeaderIdx);\n\n const lines = section.split('\\n');\n const entries: string[] = [];\n let skipIndented = false;\n\n for (let i = 0; i < lines.length; i++) {\n const raw = lines[i]!;\n const trimmed = raw.trim();\n\n // Only match top-level entries (no leading whitespace before \"- \")\n const isTopLevel = raw === trimmed && trimmed.startsWith('- ');\n if (!isTopLevel) {\n // Skip indented sub-items (e.g. dependency list entries)\n if (skipIndented && /^\\s+-\\s/.test(raw)) continue;\n skipIndented = false;\n continue;\n }\n\n // Skip dependency update entries and their sub-items\n if (/^- Updated dependenc/i.test(trimmed)) {\n skipIndented = true;\n continue;\n }\n skipIndented = false;\n\n let entry = trimmed.slice(2);\n // Strip markdown links: [text](url) → text\n entry = entry.replace(/\\[([^\\]]+)\\]\\([^)]+\\)/g, '$1');\n // Strip PR references like (#15760)\n entry = entry.replace(/\\s*\\(#\\d+\\)\\s*/g, ' ');\n // Strip commit SHA references like (`abc123`)\n entry = entry.replace(/\\s*\\(`[a-f0-9]+`\\)\\s*/g, ' ');\n // Trim trailing periods for cleaner bullet display\n entry = entry.replace(/\\.\\s*$/, '');\n entry = entry.trim();\n if (entry) entries.push(entry);\n if (entries.length >= MAX_CHANGELOG_ENTRIES) break;\n }\n\n if (entries.length === 0) return null;\n return entries.map(e => ` • ${e}`).join('\\n');\n}\n\n/** Result of attempting an auto-update: exit status plus captured stderr. */\nexport interface UpdateResult {\n ok: boolean;\n stderr?: string;\n}\n\n/**\n * Run the appropriate global install command to update mastracode.\n * Exit code 0 does not prove the running binary changed (the install may land\n * in a location the PATH shim doesn't use) — verify with {@link locateOwnInstall}.\n */\nexport function runUpdate(pm: PackageManager, targetVersion: string): Promise<UpdateResult> {\n return execUpdate(pm, buildInstallArgs(pm, targetVersion));\n}\n\nfunction execUpdate(cmd: string, args: string[]): Promise<UpdateResult> {\n return new Promise(resolve => {\n execFile(cmd, args, { timeout: 60_000, shell: USE_SHELL }, (error, _stdout, stderr) => {\n const captured = (stderr ?? '').trim();\n if (error) {\n resolve({ ok: false, stderr: captured || error.message });\n } else {\n resolve({ ok: true, stderr: captured || undefined });\n }\n });\n });\n}\n\nfunction buildInstallArgs(pm: PackageManager, version: string): string[] {\n const pkg = `${PACKAGE_NAME}@${version}`;\n switch (pm) {\n case 'pnpm':\n return ['add', '-g', pkg];\n case 'yarn':\n return ['global', 'add', pkg];\n case 'bun':\n return ['add', '-g', pkg];\n default:\n return ['install', '-g', pkg];\n }\n}\n\n/** Max stderr lines to surface when an update fails. */\nconst MAX_UPDATE_ERROR_LINES = 5;\n\nfunction formatUpdaterError(stderr: string | undefined): string | null {\n if (!stderr) return null;\n const lines = stderr\n .split('\\n')\n .map(line => line.trimEnd())\n .filter(line => line.trim().length > 0);\n if (lines.length === 0) return null;\n return lines.slice(-MAX_UPDATE_ERROR_LINES).join('\\n');\n}\n\n/**\n * Find the installed mastracode package the running binary belongs to (walking\n * up from `process.argv[1]`) and read its version fresh from disk. Returns\n * null when it can't be determined, e.g. when running from source.\n */\nexport function locateOwnInstall(): { dir: string; version: string | null } | null {\n const entry = process.argv[1];\n if (!entry) return null;\n\n let dir: string;\n try {\n dir = dirname(realpathSync(entry));\n } catch {\n return null;\n }\n\n let previous = '';\n while (dir && dir !== previous) {\n try {\n const pkg = JSON.parse(readFileSync(resolve(dir, 'package.json'), 'utf-8')) as {\n name?: string;\n version?: string;\n };\n if (pkg.name === PACKAGE_NAME) {\n return { dir, version: typeof pkg.version === 'string' ? pkg.version : null };\n }\n } catch {\n // Not a readable manifest — keep walking up.\n }\n previous = dir;\n dir = dirname(dir);\n }\n\n return null;\n}\n\nexport type UpdateOutcome =\n | { status: 'updated'; message: string }\n | { status: 'unchanged'; message: string }\n | { status: 'failed'; message: string };\n\n/**\n * Decide what to tell the user after {@link runUpdate}: `updated` when the\n * on-disk version matches the target (or can't be determined), `unchanged`\n * when the package manager succeeded but the running install didn't change,\n * `failed` on error (with the package manager's stderr).\n */\nexport function resolveUpdateOutcome(opts: {\n pm: PackageManager;\n targetVersion: string;\n result: UpdateResult;\n install: { dir: string; version: string | null } | null;\n /** Overrides the suggested manual command, e.g. when the update was delegated to the owning tool. */\n manualCommand?: string;\n}): UpdateOutcome {\n const { pm, targetVersion, result, install } = opts;\n const cmd = opts.manualCommand ?? getInstallCommand(pm, targetVersion);\n\n if (!result.ok) {\n const details = formatUpdaterError(result.stderr);\n let message = `Auto-update failed. Run \\`${cmd}\\` manually.`;\n if (details) message += `\\n\\n${details}`;\n return { status: 'failed', message };\n }\n\n if (install?.version != null && install.version !== targetVersion) {\n const message = opts.manualCommand\n ? `The update ran, but the Mastra Code you are running (at ${install.dir}) is still ` +\n `v${install.version}. Try \\`${cmd}\\` manually.`\n : `The update installed, but the Mastra Code you are running (at ${install.dir}) is still ` +\n `v${install.version} — it looks like it is managed by another tool. Update it with that tool, ` +\n `or try \\`${cmd}\\`.`;\n return { status: 'unchanged', message };\n }\n\n return { status: 'updated', message: `Updated to v${targetVersion}. Please restart Mastra Code.` };\n}\n\n/** Global node_modules directory the package manager installs into, or null when unknown. */\nfunction getGlobalRoot(pm: PackageManager): Promise<string | null> {\n const args = pm === 'yarn' ? ['global', 'dir'] : ['root', '-g'];\n return new Promise(res => {\n execFile(pm, args, { timeout: 10_000, shell: USE_SHELL }, (error, stdout) => {\n const out = (stdout ?? '').trim().split('\\n').pop()?.trim();\n if (error || !out) return res(null);\n res(pm === 'yarn' ? resolve(out, 'node_modules') : out);\n });\n });\n}\n\n/**\n * Whether updating via `pm` would touch the install the running binary uses.\n * Fail-open: returns true when either side can't be determined, so the update\n * proceeds and the post-install verification has the final word.\n */\nasync function isOwnInstallManagedBy(pm: PackageManager, install: { dir: string } | null): Promise<boolean> {\n if (!install) return true;\n const root = await getGlobalRoot(pm);\n if (!root) return true;\n try {\n return realpathSync(resolve(root, PACKAGE_NAME)) === install.dir;\n } catch {\n // Package absent from the pm's global root: installing there can't affect the running binary.\n return false;\n }\n}\n\n/** A tool other than a package manager that owns the running install, matched by path. */\ninterface InstallOwner {\n name: string;\n /** Command to run to delegate the update; omitted when we only suggest `command` to the user. */\n exec?: { cmd: string; args: string[] };\n command: string;\n}\n\nfunction findInstallOwner(dir: string, version: string): InstallOwner | null {\n if (dir.startsWith(join(homedir(), '.vite-plus') + sep)) {\n return {\n name: 'vite-plus',\n exec: { cmd: 'vp', args: ['install', '-g', `${PACKAGE_NAME}@${version}`] },\n command: `vp install -g ${PACKAGE_NAME}@${version}`,\n };\n }\n // Homebrew keeps formulas under <prefix>/Cellar/ whatever the prefix, so match the path segment.\n if (dir.split(sep).includes('Cellar')) {\n // Suggest-only: brew formulas lag npm, and `brew upgrade` can pull unrelated updates.\n return { name: 'Homebrew', command: `brew upgrade ${PACKAGE_NAME}` };\n }\n return null;\n}\n\n/**\n * Update mastracode and verify the result: delegates to the tool that owns the\n * running install when we recognize it, skips the install when it isn't\n * managed by `pm`, otherwise runs the package manager. Every executed update\n * is verified against the on-disk version.\n */\nexport async function performUpdate(pm: PackageManager, targetVersion: string): Promise<UpdateOutcome> {\n // The registry-provided version reaches shell commands on Windows — accept only version tokens.\n if (!/^[\\w.+-]+$/.test(targetVersion)) {\n return { status: 'failed', message: `Auto-update aborted: unexpected version \"${targetVersion}\".` };\n }\n\n const install = locateOwnInstall();\n\n const owner = install ? findInstallOwner(install.dir, targetVersion) : null;\n if (owner) {\n if (!owner.exec) {\n const message =\n `Your Mastra Code install (at ${install!.dir}) is managed by ${owner.name}. ` +\n `Update it with \\`${owner.command}\\`.`;\n return { status: 'unchanged', message };\n }\n const result = await execUpdate(owner.exec.cmd, owner.exec.args);\n return resolveUpdateOutcome({\n pm,\n targetVersion,\n result,\n install: locateOwnInstall(),\n manualCommand: owner.command,\n });\n }\n\n if (!(await isOwnInstallManagedBy(pm, install))) {\n const message =\n `Your Mastra Code install (at ${install!.dir}) is not managed by ${pm} — it looks like it was ` +\n `installed by another tool. Update it with that tool, or try \\`${getInstallCommand(pm, targetVersion)}\\`.`;\n return { status: 'unchanged', message };\n }\n\n const result = await runUpdate(pm, targetVersion);\n // Re-locate so the version reflects what the install just wrote to disk.\n return resolveUpdateOutcome({ pm, targetVersion, result, install: locateOwnInstall() });\n}\n"],"mappings":"AAIA,SAAS,gBAAgB;AACzB,SAAS,cAAc,oBAAoB;AAC3C,SAAS,eAAe;AACxB,SAAS,SAAS,MAAM,SAAS,WAAW;AAC5C,SAAS,qBAAqB;AAI9B,MAAM,eAAe;AACrB,MAAM,mBAAmB,8BAA8B,YAAY;AAGnE,MAAM,mBAAmB;AAGzB,MAAM,YAAY,QAAQ,aAAa;AAIvC,SAAS,QAAQ,KAAoC;AAEnD,MAAI,QAAQ,KAAK,GAAG,EAAG,QAAO;AAC9B,MAAI,YAAY,KAAK,GAAG,EAAG,QAAO;AAClC,MAAI,WAAW,KAAK,GAAG,EAAG,QAAO;AACjC,MAAI,WAAW,KAAK,GAAG,EAAG,QAAO;AACjC,SAAO;AACT;AAaA,eAAsB,uBAAgD;AAEpE,QAAM,YAAY,QAAQ,IAAI;AAC9B,MAAI,WAAW;AACb,UAAM,KAAK,QAAQ,SAAS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AAY,GAAG;AAAA,EACrE;AACA,SAAO;AACT;AAQA,eAAsB,cAAc,IAAoB,eAA+C;AAErG,MAAI,CAAC,aAAa,KAAK,aAAa,GAAG;AACrC,WAAO,EAAE,QAAQ,UAAU,SAAS,4CAA4C,aAAa,KAAK;AAAA,EACpG;AAEA,QAAM,UAAU,iBAAiB;AAEjC,QAAM,QAAQ,UAAU,iBAAiB,QAAQ,KAAK,aAAa,IAAI;AACvE,MAAI,OAAO;AACT,QAAI,CAAC,MAAM,MAAM;AACf,YAAM,UACJ,gCAAgC,QAAS,GAAG,mBAAmB,MAAM,IAAI,sBACrD,MAAM,OAAO;AACnC,aAAO,EAAE,QAAQ,aAAa,QAAQ;AAAA,IACxC;AACA,UAAMC,UAAS,MAAM,WAAW,MAAM,KAAK,KAAK,MAAM,KAAK,IAAI;AAC/D,WAAO,qBAAqB;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,QAAAA;AAAA,MACA,SAAS,iBAAiB;AAAA,MAC1B,eAAe,MAAM;AAAA,IACvB,CAAC;AAAA,EACH;AAEA,MAAI,CAAE,MAAM,sBAAsB,IAAI,OAAO,GAAI;AAC/C,UAAM,UACJ,gCAAgC,QAAS,GAAG,uBAAuB,EAAE,8FACJ,kBAAkB,IAAI,aAAa,CAAC;AACvG,WAAO,EAAE,QAAQ,aAAa,QAAQ;AAAA,EACxC;AAEA,QAAM,SAAS,MAAM,UAAU,IAAI,aAAa;AAEhD,SAAO,qBAAqB,EAAE,IAAI,eAAe,QAAQ,SAAS,iBAAiB,EAAE,CAAC;AACxF;","names":["resolve","result"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/code-sdk",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.4",
|
|
4
4
|
"description": "Mastra Code SDK: the agent core behind Mastra Code (everything except the TUI) — build your own UIs and surfaces on top of it",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -57,16 +57,16 @@
|
|
|
57
57
|
"yaml": "^2.7.1",
|
|
58
58
|
"zod": "^4.3.6",
|
|
59
59
|
"@mastra/agent-browser": "0.4.1",
|
|
60
|
-
"@mastra/
|
|
60
|
+
"@mastra/github-signals": "0.2.2",
|
|
61
61
|
"@mastra/fastembed": "1.2.0",
|
|
62
|
-
"@mastra/core": "1.52.0-alpha.3",
|
|
63
62
|
"@mastra/libsql": "1.16.0",
|
|
64
|
-
"@mastra/
|
|
63
|
+
"@mastra/duckdb": "1.5.1",
|
|
65
64
|
"@mastra/mcp": "1.15.0-alpha.0",
|
|
66
|
-
"@mastra/observability": "1.16.1",
|
|
67
65
|
"@mastra/memory": "1.23.1-alpha.0",
|
|
68
|
-
"@mastra/
|
|
66
|
+
"@mastra/core": "1.52.0-alpha.4",
|
|
67
|
+
"@mastra/observability": "1.16.1",
|
|
69
68
|
"@mastra/schema-compat": "1.3.4",
|
|
69
|
+
"@mastra/pg": "1.16.1-alpha.0",
|
|
70
70
|
"@mastra/stagehand": "0.3.1-alpha.0",
|
|
71
71
|
"@mastra/tavily": "1.1.0"
|
|
72
72
|
},
|