@mastra/codemod 0.0.0-allow-to-pass-a-mastra-url-instance-20251105224938 → 0.0.0-export-agent-memory-from-local-studio-20251112153946
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 +21 -1
- package/README.md +46 -11
- package/dist/codemods/chunk-JNFQ6J6B.js +21 -0
- package/dist/codemods/chunk-JNFQ6J6B.js.map +1 -0
- package/dist/codemods/chunk-LGW3NUAJ.js +32 -0
- package/dist/codemods/chunk-LGW3NUAJ.js.map +1 -0
- package/dist/codemods/chunk-PKCFDS7J.js +177 -0
- package/dist/codemods/chunk-PKCFDS7J.js.map +1 -0
- package/dist/codemods/lib/add-comment.js +6 -54
- package/dist/codemods/lib/add-comment.js.map +1 -1
- package/dist/codemods/lib/create-transformer.js +5 -43
- package/dist/codemods/lib/create-transformer.js.map +1 -1
- package/dist/codemods/lib/utils.js +23 -0
- package/dist/codemods/lib/utils.js.map +1 -0
- package/dist/codemods/v1/agent-abort-signal.js +61 -0
- package/dist/codemods/v1/agent-abort-signal.js.map +1 -0
- package/dist/codemods/v1/agent-generate-stream-v-next.js +26 -0
- package/dist/codemods/v1/agent-generate-stream-v-next.js.map +1 -0
- package/dist/codemods/v1/agent-processor-methods.js +28 -0
- package/dist/codemods/v1/agent-processor-methods.js.map +1 -0
- package/dist/codemods/v1/agent-property-access.js +42 -0
- package/dist/codemods/v1/agent-property-access.js.map +1 -0
- package/dist/codemods/v1/agent-voice.js +37 -0
- package/dist/codemods/v1/agent-voice.js.map +1 -0
- package/dist/codemods/v1/client-get-memory-thread.js +58 -0
- package/dist/codemods/v1/client-get-memory-thread.js.map +1 -0
- package/dist/codemods/v1/client-offset-limit.js +49 -0
- package/dist/codemods/v1/client-offset-limit.js.map +1 -0
- package/dist/codemods/v1/client-sdk-types.js +56 -0
- package/dist/codemods/v1/client-sdk-types.js.map +1 -0
- package/dist/codemods/v1/client-to-ai-sdk-format.js +20 -0
- package/dist/codemods/v1/client-to-ai-sdk-format.js.map +1 -0
- package/dist/codemods/v1/evals-prebuilt-imports.js +24 -0
- package/dist/codemods/v1/evals-prebuilt-imports.js.map +1 -0
- package/dist/codemods/v1/evals-run-experiment.js +20 -0
- package/dist/codemods/v1/evals-run-experiment.js.map +1 -0
- package/dist/codemods/v1/evals-scorer-by-name.js +22 -0
- package/dist/codemods/v1/evals-scorer-by-name.js.map +1 -0
- package/dist/codemods/v1/experimental-auth.js +27 -0
- package/dist/codemods/v1/experimental-auth.js.map +1 -0
- package/dist/codemods/v1/mastra-core-imports.js +8 -44
- package/dist/codemods/v1/mastra-core-imports.js.map +1 -1
- package/dist/codemods/v1/mastra-plural-apis.js +31 -0
- package/dist/codemods/v1/mastra-plural-apis.js.map +1 -0
- package/dist/codemods/v1/mcp-get-tools.js +22 -0
- package/dist/codemods/v1/mcp-get-tools.js.map +1 -0
- package/dist/codemods/v1/mcp-get-toolsets.js +22 -0
- package/dist/codemods/v1/mcp-get-toolsets.js.map +1 -0
- package/dist/codemods/v1/memory-message-v2-type.js +50 -0
- package/dist/codemods/v1/memory-message-v2-type.js.map +1 -0
- package/dist/codemods/v1/memory-query-to-recall.js +22 -0
- package/dist/codemods/v1/memory-query-to-recall.js.map +1 -0
- package/dist/codemods/v1/memory-vector-search-param.js +31 -0
- package/dist/codemods/v1/memory-vector-search-param.js.map +1 -0
- package/dist/codemods/v1/not-implemented/agent-format-parameter.js +53 -0
- package/dist/codemods/v1/not-implemented/agent-format-parameter.js.map +1 -0
- package/dist/codemods/v1/not-implemented/agent-to-step.js +54 -0
- package/dist/codemods/v1/not-implemented/agent-to-step.js.map +1 -0
- package/dist/codemods/v1/not-implemented/mastra-memory.js +50 -0
- package/dist/codemods/v1/not-implemented/mastra-memory.js.map +1 -0
- package/dist/codemods/v1/not-implemented/mastra-required-id.js +112 -0
- package/dist/codemods/v1/not-implemented/mastra-required-id.js.map +1 -0
- package/dist/codemods/v1/runtime-context.js +6 -42
- package/dist/codemods/v1/runtime-context.js.map +1 -1
- package/dist/codemods/v1/storage-get-messages-paginated.js +41 -0
- package/dist/codemods/v1/storage-get-messages-paginated.js.map +1 -0
- package/dist/codemods/v1/storage-get-threads-by-resource.js +23 -0
- package/dist/codemods/v1/storage-get-threads-by-resource.js.map +1 -0
- package/dist/codemods/v1/storage-list-messages-by-id.js +23 -0
- package/dist/codemods/v1/storage-list-messages-by-id.js.map +1 -0
- package/dist/codemods/v1/storage-list-workflow-runs.js +23 -0
- package/dist/codemods/v1/storage-list-workflow-runs.js.map +1 -0
- package/dist/codemods/v1/storage-postgres-schema-name.js +20 -0
- package/dist/codemods/v1/storage-postgres-schema-name.js.map +1 -0
- package/dist/codemods/v1/vector-pg-constructor.js +27 -0
- package/dist/codemods/v1/vector-pg-constructor.js.map +1 -0
- package/dist/codemods/v1/voice-property-names.js +42 -0
- package/dist/codemods/v1/voice-property-names.js.map +1 -0
- package/dist/codemods/v1/workflow-create-run-async.js +22 -0
- package/dist/codemods/v1/workflow-create-run-async.js.map +1 -0
- package/dist/codemods/v1/workflow-list-runs.js +22 -0
- package/dist/codemods/v1/workflow-list-runs.js.map +1 -0
- package/dist/codemods/v1/workflow-run-count.js +53 -0
- package/dist/codemods/v1/workflow-run-count.js.map +1 -0
- package/dist/index.js +114 -27
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTransformer
|
|
3
|
+
} from "../chunk-JNFQ6J6B.js";
|
|
4
|
+
import {
|
|
5
|
+
renameMethods,
|
|
6
|
+
trackClassInstances
|
|
7
|
+
} from "../chunk-PKCFDS7J.js";
|
|
8
|
+
|
|
9
|
+
// src/codemods/v1/agent-generate-stream-v-next.ts
|
|
10
|
+
var agent_generate_stream_v_next_default = createTransformer((fileInfo, api, options, context) => {
|
|
11
|
+
const { j, root } = context;
|
|
12
|
+
const methodRenames = {
|
|
13
|
+
generateVNext: "generate",
|
|
14
|
+
streamVNext: "stream"
|
|
15
|
+
};
|
|
16
|
+
const agentVariables = trackClassInstances(j, root, "Agent");
|
|
17
|
+
const renamed = renameMethods(j, root, agentVariables, methodRenames);
|
|
18
|
+
if (renamed > 0) {
|
|
19
|
+
context.hasChanges = true;
|
|
20
|
+
context.messages.push(`Transformed Agent VNext methods: generateVNext/streamVNext \u2192 generate/stream`);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
export {
|
|
24
|
+
agent_generate_stream_v_next_default as default
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=agent-generate-stream-v-next.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/codemods/v1/agent-generate-stream-v-next.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\nimport { trackClassInstances, renameMethods } from '../lib/utils';\n\n/**\n * Transforms Agent VNext methods to their standard names:\n * - agent.generateVNext() → agent.generate()\n * - agent.streamVNext() → agent.stream()\n *\n * Only transforms methods on variables that were instantiated with `new Agent(...)`\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n // Map of old method names to new method names\n const methodRenames: Record<string, string> = {\n generateVNext: 'generate',\n streamVNext: 'stream',\n };\n\n // Track Agent instances and rename methods efficiently\n const agentVariables = trackClassInstances(j, root, 'Agent');\n const renamed = renameMethods(j, root, agentVariables, methodRenames);\n\n if (renamed > 0) {\n context.hasChanges = true;\n context.messages.push(`Transformed Agent VNext methods: generateVNext/streamVNext → generate/stream`);\n }\n});\n"],"mappings":";;;;;;;;;AAUA,IAAO,uCAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,gBAAwC;AAAA,IAC5C,eAAe;AAAA,IACf,aAAa;AAAA,EACf;AAGA,QAAM,iBAAiB,oBAAoB,GAAG,MAAM,OAAO;AAC3D,QAAM,UAAU,cAAc,GAAG,MAAM,gBAAgB,aAAa;AAEpE,MAAI,UAAU,GAAG;AACf,YAAQ,aAAa;AACrB,YAAQ,SAAS,KAAK,mFAA8E;AAAA,EACtG;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTransformer
|
|
3
|
+
} from "../chunk-JNFQ6J6B.js";
|
|
4
|
+
import {
|
|
5
|
+
renameMethods,
|
|
6
|
+
trackClassInstances
|
|
7
|
+
} from "../chunk-PKCFDS7J.js";
|
|
8
|
+
|
|
9
|
+
// src/codemods/v1/agent-processor-methods.ts
|
|
10
|
+
var agent_processor_methods_default = createTransformer((_fileInfo, _api, _options, context) => {
|
|
11
|
+
const { j, root } = context;
|
|
12
|
+
const methodRenames = {
|
|
13
|
+
getInputProcessors: "listInputProcessors",
|
|
14
|
+
getOutputProcessors: "listOutputProcessors"
|
|
15
|
+
};
|
|
16
|
+
const agentVariables = trackClassInstances(j, root, "Agent");
|
|
17
|
+
const count = renameMethods(j, root, agentVariables, methodRenames);
|
|
18
|
+
if (count > 0) {
|
|
19
|
+
context.hasChanges = true;
|
|
20
|
+
context.messages.push(
|
|
21
|
+
`Transformed Agent processor methods: getInputProcessors/getOutputProcessors \u2192 listInputProcessors/listOutputProcessors`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
export {
|
|
26
|
+
agent_processor_methods_default as default
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=agent-processor-methods.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/codemods/v1/agent-processor-methods.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\nimport { trackClassInstances, renameMethods } from '../lib/utils';\n\n/**\n * Transforms Agent processor methods:\n * - agent.getInputProcessors() → agent.listInputProcessors()\n * - agent.getOutputProcessors() → agent.listOutputProcessors()\n *\n * Only transforms methods on variables that were instantiated with `new Agent(...)`\n */\nexport default createTransformer((_fileInfo, _api, _options, context) => {\n const { j, root } = context;\n\n // Map of old method names to new method names\n const methodRenames: Record<string, string> = {\n getInputProcessors: 'listInputProcessors',\n getOutputProcessors: 'listOutputProcessors',\n };\n\n // Track Agent instances and rename methods in a single optimized pass\n const agentVariables = trackClassInstances(j, root, 'Agent');\n const count = renameMethods(j, root, agentVariables, methodRenames);\n\n if (count > 0) {\n context.hasChanges = true;\n context.messages.push(\n `Transformed Agent processor methods: getInputProcessors/getOutputProcessors → listInputProcessors/listOutputProcessors`,\n );\n }\n});\n"],"mappings":";;;;;;;;;AAUA,IAAO,kCAAQ,kBAAkB,CAAC,WAAW,MAAM,UAAU,YAAY;AACvE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,gBAAwC;AAAA,IAC5C,oBAAoB;AAAA,IACpB,qBAAqB;AAAA,EACvB;AAGA,QAAM,iBAAiB,oBAAoB,GAAG,MAAM,OAAO;AAC3D,QAAM,QAAQ,cAAc,GAAG,MAAM,gBAAgB,aAAa;AAElE,MAAI,QAAQ,GAAG;AACb,YAAQ,aAAa;AACrB,YAAQ,SAAS;AAAA,MACf;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTransformer
|
|
3
|
+
} from "../chunk-JNFQ6J6B.js";
|
|
4
|
+
import {
|
|
5
|
+
trackClassInstances
|
|
6
|
+
} from "../chunk-PKCFDS7J.js";
|
|
7
|
+
|
|
8
|
+
// src/codemods/v1/agent-property-access.ts
|
|
9
|
+
var agent_property_access_default = createTransformer((_fileInfo, _api, _options, context) => {
|
|
10
|
+
const { j, root } = context;
|
|
11
|
+
const propertyToMethod = {
|
|
12
|
+
llm: "getLLM",
|
|
13
|
+
tools: "getTools",
|
|
14
|
+
instructions: "getInstructions"
|
|
15
|
+
};
|
|
16
|
+
const agentVariables = trackClassInstances(j, root, "Agent");
|
|
17
|
+
if (agentVariables.size === 0) return;
|
|
18
|
+
root.find(j.MemberExpression).forEach((path) => {
|
|
19
|
+
const node = path.node;
|
|
20
|
+
if (node.object.type !== "Identifier" || !agentVariables.has(node.object.name)) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (node.property.type !== "Identifier") {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const propertyName = node.property.name;
|
|
27
|
+
const methodName = propertyToMethod[propertyName];
|
|
28
|
+
if (!methodName) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const callExpression = j.callExpression(j.memberExpression(node.object, j.identifier(methodName)), []);
|
|
32
|
+
j(path).replaceWith(callExpression);
|
|
33
|
+
context.hasChanges = true;
|
|
34
|
+
});
|
|
35
|
+
if (context.hasChanges) {
|
|
36
|
+
context.messages.push(`Transformed Agent property access to method calls`);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
export {
|
|
40
|
+
agent_property_access_default as default
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=agent-property-access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/codemods/v1/agent-property-access.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\nimport { trackClassInstances } from '../lib/utils';\n\n/**\n * Transforms Agent property access to method calls.\n * - agent.llm → agent.getLLM()\n * - agent.tools → agent.getTools()\n * - agent.instructions → agent.getInstructions()\n *\n * Only transforms properties on variables that were instantiated with `new Agent(...)`\n */\nexport default createTransformer((_fileInfo, _api, _options, context) => {\n const { j, root } = context;\n\n // Map of property names to their corresponding method names\n const propertyToMethod: Record<string, string> = {\n llm: 'getLLM',\n tools: 'getTools',\n instructions: 'getInstructions',\n };\n\n // Track variable names that are Agent instances\n const agentVariables = trackClassInstances(j, root, 'Agent');\n\n // Early return if no Agent instances found\n if (agentVariables.size === 0) return;\n\n // Find all member expressions where object is an Agent variable and property is one we want to transform\n root.find(j.MemberExpression).forEach(path => {\n const node = path.node;\n\n // Check if the object is an identifier that's an Agent instance\n if (node.object.type !== 'Identifier' || !agentVariables.has(node.object.name)) {\n return;\n }\n\n // Check if the property is one we want to transform\n if (node.property.type !== 'Identifier') {\n return;\n }\n\n const propertyName = node.property.name;\n const methodName = propertyToMethod[propertyName];\n\n if (!methodName) {\n return;\n }\n\n // Transform the member expression to a call expression\n const callExpression = j.callExpression(j.memberExpression(node.object, j.identifier(methodName)), []);\n\n // Replace the member expression with the call expression\n j(path).replaceWith(callExpression);\n\n context.hasChanges = true;\n });\n\n if (context.hasChanges) {\n context.messages.push(`Transformed Agent property access to method calls`);\n }\n});\n"],"mappings":";;;;;;;;AAWA,IAAO,gCAAQ,kBAAkB,CAAC,WAAW,MAAM,UAAU,YAAY;AACvE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,mBAA2C;AAAA,IAC/C,KAAK;AAAA,IACL,OAAO;AAAA,IACP,cAAc;AAAA,EAChB;AAGA,QAAM,iBAAiB,oBAAoB,GAAG,MAAM,OAAO;AAG3D,MAAI,eAAe,SAAS,EAAG;AAG/B,OAAK,KAAK,EAAE,gBAAgB,EAAE,QAAQ,UAAQ;AAC5C,UAAM,OAAO,KAAK;AAGlB,QAAI,KAAK,OAAO,SAAS,gBAAgB,CAAC,eAAe,IAAI,KAAK,OAAO,IAAI,GAAG;AAC9E;AAAA,IACF;AAGA,QAAI,KAAK,SAAS,SAAS,cAAc;AACvC;AAAA,IACF;AAEA,UAAM,eAAe,KAAK,SAAS;AACnC,UAAM,aAAa,iBAAiB,YAAY;AAEhD,QAAI,CAAC,YAAY;AACf;AAAA,IACF;AAGA,UAAM,iBAAiB,EAAE,eAAe,EAAE,iBAAiB,KAAK,QAAQ,EAAE,WAAW,UAAU,CAAC,GAAG,CAAC,CAAC;AAGrG,MAAE,IAAI,EAAE,YAAY,cAAc;AAElC,YAAQ,aAAa;AAAA,EACvB,CAAC;AAED,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS,KAAK,mDAAmD;AAAA,EAC3E;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTransformer
|
|
3
|
+
} from "../chunk-JNFQ6J6B.js";
|
|
4
|
+
import {
|
|
5
|
+
trackClassInstances
|
|
6
|
+
} from "../chunk-PKCFDS7J.js";
|
|
7
|
+
|
|
8
|
+
// src/codemods/v1/agent-voice.ts
|
|
9
|
+
var agent_voice_default = createTransformer((fileInfo, api, options, context) => {
|
|
10
|
+
const { j, root } = context;
|
|
11
|
+
const voiceMethods = /* @__PURE__ */ new Set(["speak", "listen", "getSpeakers"]);
|
|
12
|
+
const agentVariables = trackClassInstances(j, root, "Agent");
|
|
13
|
+
if (agentVariables.size === 0) return;
|
|
14
|
+
root.find(j.CallExpression).forEach((path) => {
|
|
15
|
+
const node = path.node;
|
|
16
|
+
if (node.callee.type !== "MemberExpression") {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const callee = node.callee;
|
|
20
|
+
if (callee.object.type !== "Identifier" || !agentVariables.has(callee.object.name)) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (callee.property.type !== "Identifier" || !voiceMethods.has(callee.property.name)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const newCallee = j.memberExpression(j.memberExpression(callee.object, j.identifier("voice")), callee.property);
|
|
27
|
+
node.callee = newCallee;
|
|
28
|
+
context.hasChanges = true;
|
|
29
|
+
});
|
|
30
|
+
if (context.hasChanges) {
|
|
31
|
+
context.messages.push(`Transformed Agent voice methods to use agent.voice namespace`);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
export {
|
|
35
|
+
agent_voice_default as default
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=agent-voice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/codemods/v1/agent-voice.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\nimport { trackClassInstances } from '../lib/utils';\n\n/**\n * Transforms Agent voice method calls to use agent.voice namespace.\n * - agent.speak(...) → agent.voice.speak(...)\n * - agent.listen() → agent.voice.listen()\n * - agent.getSpeakers() → agent.voice.getSpeakers()\n *\n * Only transforms methods on variables that were instantiated with `new Agent(...)`\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n // Voice methods that should be moved to agent.voice\n const voiceMethods = new Set(['speak', 'listen', 'getSpeakers']);\n\n // Track Agent instances using shared utility\n const agentVariables = trackClassInstances(j, root, 'Agent');\n\n // Early return if no Agent instances found\n if (agentVariables.size === 0) return;\n\n // Find all call expressions that are agent voice methods\n root.find(j.CallExpression).forEach(path => {\n const node = path.node;\n\n // Check if callee is a member expression (e.g., agent.speak)\n if (node.callee.type !== 'MemberExpression') {\n return;\n }\n\n const callee = node.callee;\n\n // Check if the object is an Agent variable\n if (callee.object.type !== 'Identifier' || !agentVariables.has(callee.object.name)) {\n return;\n }\n\n // Check if the property is a voice method\n if (callee.property.type !== 'Identifier' || !voiceMethods.has(callee.property.name)) {\n return;\n }\n\n // Transform agent.method() to agent.voice.method()\n const newCallee = j.memberExpression(j.memberExpression(callee.object, j.identifier('voice')), callee.property);\n\n node.callee = newCallee;\n context.hasChanges = true;\n });\n\n if (context.hasChanges) {\n context.messages.push(`Transformed Agent voice methods to use agent.voice namespace`);\n }\n});\n"],"mappings":";;;;;;;;AAWA,IAAO,sBAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,eAAe,oBAAI,IAAI,CAAC,SAAS,UAAU,aAAa,CAAC;AAG/D,QAAM,iBAAiB,oBAAoB,GAAG,MAAM,OAAO;AAG3D,MAAI,eAAe,SAAS,EAAG;AAG/B,OAAK,KAAK,EAAE,cAAc,EAAE,QAAQ,UAAQ;AAC1C,UAAM,OAAO,KAAK;AAGlB,QAAI,KAAK,OAAO,SAAS,oBAAoB;AAC3C;AAAA,IACF;AAEA,UAAM,SAAS,KAAK;AAGpB,QAAI,OAAO,OAAO,SAAS,gBAAgB,CAAC,eAAe,IAAI,OAAO,OAAO,IAAI,GAAG;AAClF;AAAA,IACF;AAGA,QAAI,OAAO,SAAS,SAAS,gBAAgB,CAAC,aAAa,IAAI,OAAO,SAAS,IAAI,GAAG;AACpF;AAAA,IACF;AAGA,UAAM,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,OAAO,QAAQ,EAAE,WAAW,OAAO,CAAC,GAAG,OAAO,QAAQ;AAE9G,SAAK,SAAS;AACd,YAAQ,aAAa;AAAA,EACvB,CAAC;AAED,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS,KAAK,8DAA8D;AAAA,EACtF;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTransformer
|
|
3
|
+
} from "../chunk-JNFQ6J6B.js";
|
|
4
|
+
|
|
5
|
+
// src/codemods/v1/client-get-memory-thread.ts
|
|
6
|
+
var client_get_memory_thread_default = createTransformer((fileInfo, api, options, context) => {
|
|
7
|
+
const { j, root } = context;
|
|
8
|
+
const clientInstances = /* @__PURE__ */ new Set();
|
|
9
|
+
root.find(j.NewExpression, {
|
|
10
|
+
callee: {
|
|
11
|
+
type: "Identifier",
|
|
12
|
+
name: "MastraClient"
|
|
13
|
+
}
|
|
14
|
+
}).forEach((path) => {
|
|
15
|
+
const parent = path.parent.value;
|
|
16
|
+
if (parent.type === "VariableDeclarator" && parent.id.type === "Identifier") {
|
|
17
|
+
clientInstances.add(parent.id.name);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
root.find(j.CallExpression).filter((path) => {
|
|
21
|
+
const { callee } = path.value;
|
|
22
|
+
if (callee.type !== "MemberExpression") return false;
|
|
23
|
+
if (callee.object.type !== "Identifier") return false;
|
|
24
|
+
if (callee.property.type !== "Identifier") return false;
|
|
25
|
+
return clientInstances.has(callee.object.name) && callee.property.name === "getMemoryThread";
|
|
26
|
+
}).forEach((path) => {
|
|
27
|
+
const args = path.value.arguments;
|
|
28
|
+
if (args.length === 2) {
|
|
29
|
+
const threadIdArg = args[0];
|
|
30
|
+
const agentIdArg = args[1];
|
|
31
|
+
if (!threadIdArg || !agentIdArg) return;
|
|
32
|
+
if (threadIdArg.type === "SpreadElement" || agentIdArg.type === "SpreadElement") return;
|
|
33
|
+
const createProperty = (key, value, useShorthand) => {
|
|
34
|
+
const prop = j.property("init", j.identifier(key), value);
|
|
35
|
+
if (useShorthand) {
|
|
36
|
+
prop.shorthand = true;
|
|
37
|
+
}
|
|
38
|
+
return prop;
|
|
39
|
+
};
|
|
40
|
+
const properties = [];
|
|
41
|
+
const threadIdShorthand = threadIdArg.type === "Identifier" && threadIdArg.name === "threadId";
|
|
42
|
+
properties.push(createProperty("threadId", threadIdArg, threadIdShorthand));
|
|
43
|
+
const agentIdShorthand = agentIdArg.type === "Identifier" && agentIdArg.name === "agentId";
|
|
44
|
+
properties.push(createProperty("agentId", agentIdArg, agentIdShorthand));
|
|
45
|
+
path.value.arguments = [j.objectExpression(properties)];
|
|
46
|
+
context.hasChanges = true;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
if (context.hasChanges) {
|
|
50
|
+
context.messages.push(
|
|
51
|
+
"Updated getMemoryThread method calls to use object parameter instead of positional arguments"
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
export {
|
|
56
|
+
client_get_memory_thread_default as default
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=client-get-memory-thread.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/codemods/v1/client-get-memory-thread.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * Updates getMemoryThread method to use object parameter instead of positional arguments.\n * This provides a more consistent API across memory methods.\n *\n * Before:\n * const thread = await client.getMemoryThread(threadId, agentId);\n *\n * After:\n * const thread = await client.getMemoryThread({ threadId, agentId });\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n // Track MastraClient instances\n const clientInstances = new Set<string>();\n\n // Find MastraClient instances\n root\n .find(j.NewExpression, {\n callee: {\n type: 'Identifier',\n name: 'MastraClient',\n },\n })\n .forEach(path => {\n const parent = path.parent.value;\n if (parent.type === 'VariableDeclarator' && parent.id.type === 'Identifier') {\n clientInstances.add(parent.id.name);\n }\n });\n\n // Find client.getMemoryThread() calls\n root\n .find(j.CallExpression)\n .filter(path => {\n const { callee } = path.value;\n if (callee.type !== 'MemberExpression') return false;\n if (callee.object.type !== 'Identifier') return false;\n if (callee.property.type !== 'Identifier') return false;\n\n // Check if it's getMemoryThread called on a MastraClient instance\n return clientInstances.has(callee.object.name) && callee.property.name === 'getMemoryThread';\n })\n .forEach(path => {\n const args = path.value.arguments;\n\n // Check if it has exactly 2 arguments (threadId, agentId)\n if (args.length === 2) {\n const threadIdArg = args[0];\n const agentIdArg = args[1];\n\n if (!threadIdArg || !agentIdArg) return;\n\n // Skip if arguments are spread elements\n if (threadIdArg.type === 'SpreadElement' || agentIdArg.type === 'SpreadElement') return;\n\n // Helper to create property with proper typing\n type ExpressionKind = Exclude<typeof threadIdArg, { type: 'SpreadElement' }>;\n type PropertyNode = ReturnType<typeof j.property>;\n\n const createProperty = (key: string, value: ExpressionKind, useShorthand: boolean): PropertyNode => {\n const prop = j.property('init', j.identifier(key), value);\n if (useShorthand) {\n prop.shorthand = true;\n }\n return prop;\n };\n\n // Create object properties using jscodeshift builders\n const properties: PropertyNode[] = [];\n\n // Check if we can use shorthand for threadId\n const threadIdShorthand = threadIdArg.type === 'Identifier' && threadIdArg.name === 'threadId';\n properties.push(createProperty('threadId', threadIdArg, threadIdShorthand));\n\n // Check if we can use shorthand for agentId\n const agentIdShorthand = agentIdArg.type === 'Identifier' && agentIdArg.name === 'agentId';\n properties.push(createProperty('agentId', agentIdArg, agentIdShorthand));\n\n // Replace with single object argument\n path.value.arguments = [j.objectExpression(properties)];\n context.hasChanges = true;\n }\n });\n\n if (context.hasChanges) {\n context.messages.push(\n 'Updated getMemoryThread method calls to use object parameter instead of positional arguments',\n );\n }\n});\n"],"mappings":";;;;;AAYA,IAAO,mCAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,kBAAkB,oBAAI,IAAY;AAGxC,OACG,KAAK,EAAE,eAAe;AAAA,IACrB,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,EACF,CAAC,EACA,QAAQ,UAAQ;AACf,UAAM,SAAS,KAAK,OAAO;AAC3B,QAAI,OAAO,SAAS,wBAAwB,OAAO,GAAG,SAAS,cAAc;AAC3E,sBAAgB,IAAI,OAAO,GAAG,IAAI;AAAA,IACpC;AAAA,EACF,CAAC;AAGH,OACG,KAAK,EAAE,cAAc,EACrB,OAAO,UAAQ;AACd,UAAM,EAAE,OAAO,IAAI,KAAK;AACxB,QAAI,OAAO,SAAS,mBAAoB,QAAO;AAC/C,QAAI,OAAO,OAAO,SAAS,aAAc,QAAO;AAChD,QAAI,OAAO,SAAS,SAAS,aAAc,QAAO;AAGlD,WAAO,gBAAgB,IAAI,OAAO,OAAO,IAAI,KAAK,OAAO,SAAS,SAAS;AAAA,EAC7E,CAAC,EACA,QAAQ,UAAQ;AACf,UAAM,OAAO,KAAK,MAAM;AAGxB,QAAI,KAAK,WAAW,GAAG;AACrB,YAAM,cAAc,KAAK,CAAC;AAC1B,YAAM,aAAa,KAAK,CAAC;AAEzB,UAAI,CAAC,eAAe,CAAC,WAAY;AAGjC,UAAI,YAAY,SAAS,mBAAmB,WAAW,SAAS,gBAAiB;AAMjF,YAAM,iBAAiB,CAAC,KAAa,OAAuB,iBAAwC;AAClG,cAAM,OAAO,EAAE,SAAS,QAAQ,EAAE,WAAW,GAAG,GAAG,KAAK;AACxD,YAAI,cAAc;AAChB,eAAK,YAAY;AAAA,QACnB;AACA,eAAO;AAAA,MACT;AAGA,YAAM,aAA6B,CAAC;AAGpC,YAAM,oBAAoB,YAAY,SAAS,gBAAgB,YAAY,SAAS;AACpF,iBAAW,KAAK,eAAe,YAAY,aAAa,iBAAiB,CAAC;AAG1E,YAAM,mBAAmB,WAAW,SAAS,gBAAgB,WAAW,SAAS;AACjF,iBAAW,KAAK,eAAe,WAAW,YAAY,gBAAgB,CAAC;AAGvE,WAAK,MAAM,YAAY,CAAC,EAAE,iBAAiB,UAAU,CAAC;AACtD,cAAQ,aAAa;AAAA,IACvB;AAAA,EACF,CAAC;AAEH,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS;AAAA,MACf;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTransformer
|
|
3
|
+
} from "../chunk-JNFQ6J6B.js";
|
|
4
|
+
import {
|
|
5
|
+
trackClassInstances,
|
|
6
|
+
transformObjectProperties
|
|
7
|
+
} from "../chunk-PKCFDS7J.js";
|
|
8
|
+
|
|
9
|
+
// src/codemods/v1/client-offset-limit.ts
|
|
10
|
+
var client_offset_limit_default = createTransformer((_fileInfo, _api, _options, context) => {
|
|
11
|
+
const { j, root } = context;
|
|
12
|
+
const propertyRenames = {
|
|
13
|
+
offset: "page",
|
|
14
|
+
limit: "perPage"
|
|
15
|
+
};
|
|
16
|
+
const clientInstances = trackClassInstances(j, root, "MastraClient");
|
|
17
|
+
const clientObjects = /* @__PURE__ */ new Set();
|
|
18
|
+
if (clientInstances.size === 0) return;
|
|
19
|
+
root.find(j.CallExpression).forEach((path) => {
|
|
20
|
+
const { callee } = path.value;
|
|
21
|
+
if (callee.type !== "MemberExpression") return;
|
|
22
|
+
if (callee.object.type !== "Identifier") return;
|
|
23
|
+
const isClientInstance = clientInstances.has(callee.object.name);
|
|
24
|
+
const isClientObject = clientObjects.has(callee.object.name);
|
|
25
|
+
if (isClientInstance) {
|
|
26
|
+
const parent = path.parent.value;
|
|
27
|
+
if (parent.type === "VariableDeclarator" && parent.id.type === "Identifier") {
|
|
28
|
+
clientObjects.add(parent.id.name);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (isClientInstance || isClientObject) {
|
|
32
|
+
path.value.arguments.forEach((arg) => {
|
|
33
|
+
if (arg.type === "ObjectExpression") {
|
|
34
|
+
const count = transformObjectProperties(arg, propertyRenames);
|
|
35
|
+
if (count > 0) {
|
|
36
|
+
context.hasChanges = true;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
if (context.hasChanges) {
|
|
43
|
+
context.messages.push("Renamed pagination properties from offset/limit to page/perPage");
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
export {
|
|
47
|
+
client_offset_limit_default as default
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=client-offset-limit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/codemods/v1/client-offset-limit.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\nimport { trackClassInstances, transformObjectProperties } from '../lib/utils';\n\n/**\n * Renames pagination properties from offset/limit to page/perPage.\n * This provides a more intuitive pagination model aligned with web pagination patterns.\n *\n * Before:\n * await client.listMemoryThreads({ offset: 0, limit: 20 });\n * await client.getTraces({ pagination: { offset: 0, limit: 40 } });\n *\n * After:\n * await client.listMemoryThreads({ page: 0, perPage: 20 });\n * await client.getTraces({ pagination: { page: 0, perPage: 40 } });\n */\nexport default createTransformer((_fileInfo, _api, _options, context) => {\n const { j, root } = context;\n\n // Map of old property names to new property names\n const propertyRenames: Record<string, string> = {\n offset: 'page',\n limit: 'perPage',\n };\n\n // Track MastraClient instances and objects returned from client methods in a single pass\n const clientInstances = trackClassInstances(j, root, 'MastraClient');\n const clientObjects = new Set<string>();\n\n // Early return if no client instances found\n if (clientInstances.size === 0) return;\n\n // Single pass: Find objects returned from client method calls AND transform properties\n root.find(j.CallExpression).forEach(path => {\n const { callee } = path.value;\n if (callee.type !== 'MemberExpression') return;\n if (callee.object.type !== 'Identifier') return;\n\n // Check if it's called on a MastraClient instance or tracked client object\n const isClientInstance = clientInstances.has(callee.object.name);\n const isClientObject = clientObjects.has(callee.object.name);\n\n if (isClientInstance) {\n // Track objects returned from client method calls\n const parent = path.parent.value;\n if (parent.type === 'VariableDeclarator' && parent.id.type === 'Identifier') {\n clientObjects.add(parent.id.name);\n }\n }\n\n if (isClientInstance || isClientObject) {\n // Transform offset/limit properties in the arguments of this call\n path.value.arguments.forEach(arg => {\n if (arg.type === 'ObjectExpression') {\n const count = transformObjectProperties(arg, propertyRenames);\n if (count > 0) {\n context.hasChanges = true;\n }\n }\n });\n }\n });\n\n if (context.hasChanges) {\n context.messages.push('Renamed pagination properties from offset/limit to page/perPage');\n }\n});\n"],"mappings":";;;;;;;;;AAeA,IAAO,8BAAQ,kBAAkB,CAAC,WAAW,MAAM,UAAU,YAAY;AACvE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,kBAA0C;AAAA,IAC9C,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AAGA,QAAM,kBAAkB,oBAAoB,GAAG,MAAM,cAAc;AACnE,QAAM,gBAAgB,oBAAI,IAAY;AAGtC,MAAI,gBAAgB,SAAS,EAAG;AAGhC,OAAK,KAAK,EAAE,cAAc,EAAE,QAAQ,UAAQ;AAC1C,UAAM,EAAE,OAAO,IAAI,KAAK;AACxB,QAAI,OAAO,SAAS,mBAAoB;AACxC,QAAI,OAAO,OAAO,SAAS,aAAc;AAGzC,UAAM,mBAAmB,gBAAgB,IAAI,OAAO,OAAO,IAAI;AAC/D,UAAM,iBAAiB,cAAc,IAAI,OAAO,OAAO,IAAI;AAE3D,QAAI,kBAAkB;AAEpB,YAAM,SAAS,KAAK,OAAO;AAC3B,UAAI,OAAO,SAAS,wBAAwB,OAAO,GAAG,SAAS,cAAc;AAC3E,sBAAc,IAAI,OAAO,GAAG,IAAI;AAAA,MAClC;AAAA,IACF;AAEA,QAAI,oBAAoB,gBAAgB;AAEtC,WAAK,MAAM,UAAU,QAAQ,SAAO;AAClC,YAAI,IAAI,SAAS,oBAAoB;AACnC,gBAAM,QAAQ,0BAA0B,KAAK,eAAe;AAC5D,cAAI,QAAQ,GAAG;AACb,oBAAQ,aAAa;AAAA,UACvB;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS,KAAK,iEAAiE;AAAA,EACzF;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTransformer
|
|
3
|
+
} from "../chunk-JNFQ6J6B.js";
|
|
4
|
+
|
|
5
|
+
// src/codemods/v1/client-sdk-types.ts
|
|
6
|
+
var client_sdk_types_default = createTransformer((fileInfo, api, options, context) => {
|
|
7
|
+
const { j, root } = context;
|
|
8
|
+
const typeRenames = {
|
|
9
|
+
GetWorkflowRunsParams: "ListWorkflowRunsParams",
|
|
10
|
+
GetWorkflowRunsResponse: "ListWorkflowRunsResponse",
|
|
11
|
+
GetMemoryThreadParams: "ListMemoryThreadsParams"
|
|
12
|
+
};
|
|
13
|
+
const importedTypes = /* @__PURE__ */ new Set();
|
|
14
|
+
root.find(j.ImportDeclaration).filter((path) => {
|
|
15
|
+
const source = path.value.source.value;
|
|
16
|
+
return typeof source === "string" && source === "@mastra/client-js";
|
|
17
|
+
}).forEach((path) => {
|
|
18
|
+
path.value.specifiers?.forEach((specifier) => {
|
|
19
|
+
if (specifier.type === "ImportSpecifier" && specifier.imported.type === "Identifier") {
|
|
20
|
+
const oldName = specifier.imported.name;
|
|
21
|
+
const newName = typeRenames[oldName];
|
|
22
|
+
if (newName) {
|
|
23
|
+
const localName = typeof specifier.local?.name === "string" ? specifier.local.name : oldName;
|
|
24
|
+
importedTypes.add(localName);
|
|
25
|
+
specifier.imported.name = newName;
|
|
26
|
+
if (specifier.local && specifier.local.name === oldName) {
|
|
27
|
+
specifier.local.name = newName;
|
|
28
|
+
}
|
|
29
|
+
context.hasChanges = true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
if (importedTypes.size > 0) {
|
|
35
|
+
root.find(j.Identifier).forEach((path) => {
|
|
36
|
+
const name = path.value.name;
|
|
37
|
+
if (importedTypes.has(name)) {
|
|
38
|
+
const newName = typeRenames[name];
|
|
39
|
+
if (newName) {
|
|
40
|
+
const parent = path.parent.value;
|
|
41
|
+
if (parent.type === "TSTypeReference" || parent.type === "TSTypeAnnotation") {
|
|
42
|
+
path.value.name = newName;
|
|
43
|
+
context.hasChanges = true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (context.hasChanges) {
|
|
50
|
+
context.messages.push("Renamed Client SDK types from Get* to List* pattern");
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
export {
|
|
54
|
+
client_sdk_types_default as default
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=client-sdk-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/codemods/v1/client-sdk-types.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * Renames Client SDK types from Get* to List* pattern.\n * This aligns type names with the method naming convention.\n *\n * Before:\n * import type { GetWorkflowRunsParams, GetMemoryThreadParams } from '@mastra/client-js';\n *\n * After:\n * import type { ListWorkflowRunsParams, ListMemoryThreadsParams } from '@mastra/client-js';\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n // Map of old type names to new type names\n const typeRenames: Record<string, string> = {\n GetWorkflowRunsParams: 'ListWorkflowRunsParams',\n GetWorkflowRunsResponse: 'ListWorkflowRunsResponse',\n GetMemoryThreadParams: 'ListMemoryThreadsParams',\n };\n\n // Track which types were actually imported from @mastra/client-js\n const importedTypes = new Set<string>();\n\n // Transform import specifiers and track what was imported\n root\n .find(j.ImportDeclaration)\n .filter(path => {\n const source = path.value.source.value;\n return typeof source === 'string' && source === '@mastra/client-js';\n })\n .forEach(path => {\n path.value.specifiers?.forEach(specifier => {\n if (specifier.type === 'ImportSpecifier' && specifier.imported.type === 'Identifier') {\n const oldName = specifier.imported.name;\n const newName = typeRenames[oldName];\n\n if (newName) {\n // Track the local name that was imported (could be aliased)\n const localName = typeof specifier.local?.name === 'string' ? specifier.local.name : oldName;\n importedTypes.add(localName);\n\n specifier.imported.name = newName;\n // Also update the local name if it matches the imported name\n if (specifier.local && specifier.local.name === oldName) {\n specifier.local.name = newName;\n }\n context.hasChanges = true;\n }\n }\n });\n });\n\n // Only transform type references if they were imported from @mastra/client-js\n if (importedTypes.size > 0) {\n root.find(j.Identifier).forEach(path => {\n const name = path.value.name;\n\n // Only transform if this identifier was imported from @mastra/client-js\n if (importedTypes.has(name)) {\n const newName = typeRenames[name];\n\n if (newName) {\n // Check if this identifier is a type reference (not a variable declaration)\n const parent = path.parent.value;\n\n // Only rename if it's used as a type reference, not a variable name\n if (parent.type === 'TSTypeReference' || parent.type === 'TSTypeAnnotation') {\n path.value.name = newName;\n context.hasChanges = true;\n }\n }\n }\n });\n }\n\n if (context.hasChanges) {\n context.messages.push('Renamed Client SDK types from Get* to List* pattern');\n }\n});\n"],"mappings":";;;;;AAYA,IAAO,2BAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,cAAsC;AAAA,IAC1C,uBAAuB;AAAA,IACvB,yBAAyB;AAAA,IACzB,uBAAuB;AAAA,EACzB;AAGA,QAAM,gBAAgB,oBAAI,IAAY;AAGtC,OACG,KAAK,EAAE,iBAAiB,EACxB,OAAO,UAAQ;AACd,UAAM,SAAS,KAAK,MAAM,OAAO;AACjC,WAAO,OAAO,WAAW,YAAY,WAAW;AAAA,EAClD,CAAC,EACA,QAAQ,UAAQ;AACf,SAAK,MAAM,YAAY,QAAQ,eAAa;AAC1C,UAAI,UAAU,SAAS,qBAAqB,UAAU,SAAS,SAAS,cAAc;AACpF,cAAM,UAAU,UAAU,SAAS;AACnC,cAAM,UAAU,YAAY,OAAO;AAEnC,YAAI,SAAS;AAEX,gBAAM,YAAY,OAAO,UAAU,OAAO,SAAS,WAAW,UAAU,MAAM,OAAO;AACrF,wBAAc,IAAI,SAAS;AAE3B,oBAAU,SAAS,OAAO;AAE1B,cAAI,UAAU,SAAS,UAAU,MAAM,SAAS,SAAS;AACvD,sBAAU,MAAM,OAAO;AAAA,UACzB;AACA,kBAAQ,aAAa;AAAA,QACvB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAGH,MAAI,cAAc,OAAO,GAAG;AAC1B,SAAK,KAAK,EAAE,UAAU,EAAE,QAAQ,UAAQ;AACtC,YAAM,OAAO,KAAK,MAAM;AAGxB,UAAI,cAAc,IAAI,IAAI,GAAG;AAC3B,cAAM,UAAU,YAAY,IAAI;AAEhC,YAAI,SAAS;AAEX,gBAAM,SAAS,KAAK,OAAO;AAG3B,cAAI,OAAO,SAAS,qBAAqB,OAAO,SAAS,oBAAoB;AAC3E,iBAAK,MAAM,OAAO;AAClB,oBAAQ,aAAa;AAAA,UACvB;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AAEA,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS,KAAK,qDAAqD;AAAA,EAC7E;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTransformer
|
|
3
|
+
} from "../chunk-JNFQ6J6B.js";
|
|
4
|
+
import {
|
|
5
|
+
renameImportAndUsages
|
|
6
|
+
} from "../chunk-PKCFDS7J.js";
|
|
7
|
+
|
|
8
|
+
// src/codemods/v1/client-to-ai-sdk-format.ts
|
|
9
|
+
var client_to_ai_sdk_format_default = createTransformer((_fileInfo, _api, _options, context) => {
|
|
10
|
+
const { j, root } = context;
|
|
11
|
+
const count = renameImportAndUsages(j, root, "@mastra/ai-sdk", "toAISdkFormat", "toAISdkStream");
|
|
12
|
+
if (count > 0) {
|
|
13
|
+
context.hasChanges = true;
|
|
14
|
+
context.messages.push("Renamed toAISdkFormat to toAISdkStream");
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export {
|
|
18
|
+
client_to_ai_sdk_format_default as default
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=client-to-ai-sdk-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/codemods/v1/client-to-ai-sdk-format.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\nimport { renameImportAndUsages } from '../lib/utils';\n\n/**\n * Renames toAISdkFormat to toAISdkStream in imports and usages.\n * This aligns the function name with its actual behavior.\n *\n * Before:\n * import { toAISdkFormat } from '@mastra/ai-sdk';\n * const stream = toAISdkFormat(agentStream);\n *\n * After:\n * import { toAISdkStream } from '@mastra/ai-sdk';\n * const stream = toAISdkStream(agentStream);\n */\nexport default createTransformer((_fileInfo, _api, _options, context) => {\n const { j, root } = context;\n\n const count = renameImportAndUsages(j, root, '@mastra/ai-sdk', 'toAISdkFormat', 'toAISdkStream');\n\n if (count > 0) {\n context.hasChanges = true;\n context.messages.push('Renamed toAISdkFormat to toAISdkStream');\n }\n});\n"],"mappings":";;;;;;;;AAeA,IAAO,kCAAQ,kBAAkB,CAAC,WAAW,MAAM,UAAU,YAAY;AACvE,QAAM,EAAE,GAAG,KAAK,IAAI;AAEpB,QAAM,QAAQ,sBAAsB,GAAG,MAAM,kBAAkB,iBAAiB,eAAe;AAE/F,MAAI,QAAQ,GAAG;AACb,YAAQ,aAAa;AACrB,YAAQ,SAAS,KAAK,wCAAwC;AAAA,EAChE;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTransformer
|
|
3
|
+
} from "../chunk-JNFQ6J6B.js";
|
|
4
|
+
|
|
5
|
+
// src/codemods/v1/evals-prebuilt-imports.ts
|
|
6
|
+
var evals_prebuilt_imports_default = createTransformer((fileInfo, api, options, context) => {
|
|
7
|
+
const { j, root } = context;
|
|
8
|
+
const oldPaths = ["@mastra/evals/scorers/llm", "@mastra/evals/scorers/code"];
|
|
9
|
+
const newPath = "@mastra/evals/scorers/prebuilt";
|
|
10
|
+
root.find(j.ImportDeclaration).forEach((path) => {
|
|
11
|
+
const source = path.value.source.value;
|
|
12
|
+
if (typeof source === "string" && oldPaths.includes(source)) {
|
|
13
|
+
path.value.source.value = newPath;
|
|
14
|
+
context.hasChanges = true;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
if (context.hasChanges) {
|
|
18
|
+
context.messages.push("Updated prebuilt scorer imports from scorers/llm and scorers/code to scorers/prebuilt");
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
export {
|
|
22
|
+
evals_prebuilt_imports_default as default
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=evals-prebuilt-imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/codemods/v1/evals-prebuilt-imports.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * Updates prebuilt scorer imports to use the consolidated scorers/prebuilt path.\n * Replaces both scorers/llm and scorers/code with scorers/prebuilt.\n *\n * Before:\n * import { createHallucinationScorer } from '@mastra/evals/scorers/llm';\n * import { createContentSimilarityScorer } from '@mastra/evals/scorers/code';\n *\n * After:\n * import { createHallucinationScorer } from '@mastra/evals/scorers/prebuilt';\n * import { createContentSimilarityScorer } from '@mastra/evals/scorers/prebuilt';\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n const oldPaths = ['@mastra/evals/scorers/llm', '@mastra/evals/scorers/code'];\n const newPath = '@mastra/evals/scorers/prebuilt';\n\n // Find and update import declarations\n root.find(j.ImportDeclaration).forEach(path => {\n const source = path.value.source.value;\n\n // Check if this import is from one of the old paths\n if (typeof source === 'string' && oldPaths.includes(source)) {\n // Update the import path\n path.value.source.value = newPath;\n context.hasChanges = true;\n }\n });\n\n if (context.hasChanges) {\n context.messages.push('Updated prebuilt scorer imports from scorers/llm and scorers/code to scorers/prebuilt');\n }\n});\n"],"mappings":";;;;;AAcA,IAAO,iCAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAEpB,QAAM,WAAW,CAAC,6BAA6B,4BAA4B;AAC3E,QAAM,UAAU;AAGhB,OAAK,KAAK,EAAE,iBAAiB,EAAE,QAAQ,UAAQ;AAC7C,UAAM,SAAS,KAAK,MAAM,OAAO;AAGjC,QAAI,OAAO,WAAW,YAAY,SAAS,SAAS,MAAM,GAAG;AAE3D,WAAK,MAAM,OAAO,QAAQ;AAC1B,cAAQ,aAAa;AAAA,IACvB;AAAA,EACF,CAAC;AAED,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS,KAAK,uFAAuF;AAAA,EAC/G;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTransformer
|
|
3
|
+
} from "../chunk-JNFQ6J6B.js";
|
|
4
|
+
import {
|
|
5
|
+
renameImportAndUsages
|
|
6
|
+
} from "../chunk-PKCFDS7J.js";
|
|
7
|
+
|
|
8
|
+
// src/codemods/v1/evals-run-experiment.ts
|
|
9
|
+
var evals_run_experiment_default = createTransformer((_fileInfo, _api, _options, context) => {
|
|
10
|
+
const { j, root } = context;
|
|
11
|
+
const count = renameImportAndUsages(j, root, "@mastra/core/evals", "runExperiment", "runEvals");
|
|
12
|
+
if (count > 0) {
|
|
13
|
+
context.hasChanges = true;
|
|
14
|
+
context.messages.push("Renamed runExperiment to runEvals");
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export {
|
|
18
|
+
evals_run_experiment_default as default
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=evals-run-experiment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/codemods/v1/evals-run-experiment.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\nimport { renameImportAndUsages } from '../lib/utils';\n\n/**\n * Renames runExperiment to runEvals in imports and usages.\n * This provides clearer naming that better describes the evaluation functionality.\n *\n * Before:\n * import { runExperiment } from '@mastra/core/evals';\n * const result = await runExperiment({ target, scorers, data });\n *\n * After:\n * import { runEvals } from '@mastra/core/evals';\n * const result = await runEvals({ target, scorers, data });\n */\nexport default createTransformer((_fileInfo, _api, _options, context) => {\n const { j, root } = context;\n\n const count = renameImportAndUsages(j, root, '@mastra/core/evals', 'runExperiment', 'runEvals');\n\n if (count > 0) {\n context.hasChanges = true;\n context.messages.push('Renamed runExperiment to runEvals');\n }\n});\n"],"mappings":";;;;;;;;AAeA,IAAO,+BAAQ,kBAAkB,CAAC,WAAW,MAAM,UAAU,YAAY;AACvE,QAAM,EAAE,GAAG,KAAK,IAAI;AAEpB,QAAM,QAAQ,sBAAsB,GAAG,MAAM,sBAAsB,iBAAiB,UAAU;AAE9F,MAAI,QAAQ,GAAG;AACb,YAAQ,aAAa;AACrB,YAAQ,SAAS,KAAK,mCAAmC;AAAA,EAC3D;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTransformer
|
|
3
|
+
} from "../chunk-JNFQ6J6B.js";
|
|
4
|
+
import {
|
|
5
|
+
renameMethod,
|
|
6
|
+
trackClassInstances
|
|
7
|
+
} from "../chunk-PKCFDS7J.js";
|
|
8
|
+
|
|
9
|
+
// src/codemods/v1/evals-scorer-by-name.ts
|
|
10
|
+
var evals_scorer_by_name_default = createTransformer((_fileInfo, _api, _options, context) => {
|
|
11
|
+
const { j, root } = context;
|
|
12
|
+
const mastraInstances = trackClassInstances(j, root, "Mastra");
|
|
13
|
+
const count = renameMethod(j, root, mastraInstances, "getScorerByName", "getScorerById");
|
|
14
|
+
if (count > 0) {
|
|
15
|
+
context.hasChanges = true;
|
|
16
|
+
context.messages.push("Renamed getScorerByName to getScorerById on Mastra instances");
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
export {
|
|
20
|
+
evals_scorer_by_name_default as default
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=evals-scorer-by-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/codemods/v1/evals-scorer-by-name.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\nimport { trackClassInstances, renameMethod } from '../lib/utils';\n\n/**\n * Renames mastra.getScorerByName() to mastra.getScorerById().\n * This aligns with the broader API pattern of using 'id' for entity identification.\n *\n * Before:\n * const scorer = mastra.getScorerByName('helpfulness-scorer');\n *\n * After:\n * const scorer = mastra.getScorerById('helpfulness-scorer');\n */\nexport default createTransformer((_fileInfo, _api, _options, context) => {\n const { j, root } = context;\n\n // Track Mastra instances and rename method in a single optimized pass\n const mastraInstances = trackClassInstances(j, root, 'Mastra');\n const count = renameMethod(j, root, mastraInstances, 'getScorerByName', 'getScorerById');\n\n if (count > 0) {\n context.hasChanges = true;\n context.messages.push('Renamed getScorerByName to getScorerById on Mastra instances');\n }\n});\n"],"mappings":";;;;;;;;;AAaA,IAAO,+BAAQ,kBAAkB,CAAC,WAAW,MAAM,UAAU,YAAY;AACvE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,kBAAkB,oBAAoB,GAAG,MAAM,QAAQ;AAC7D,QAAM,QAAQ,aAAa,GAAG,MAAM,iBAAiB,mBAAmB,eAAe;AAEvF,MAAI,QAAQ,GAAG;AACb,YAAQ,aAAa;AACrB,YAAQ,SAAS,KAAK,8DAA8D;AAAA,EACtF;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTransformer
|
|
3
|
+
} from "../chunk-JNFQ6J6B.js";
|
|
4
|
+
|
|
5
|
+
// src/codemods/v1/experimental-auth.ts
|
|
6
|
+
var experimental_auth_default = createTransformer((fileInfo, api, options, context) => {
|
|
7
|
+
const { j, root } = context;
|
|
8
|
+
root.find(j.NewExpression, {
|
|
9
|
+
callee: { type: "Identifier", name: "Mastra" }
|
|
10
|
+
}).forEach((mastraPath) => {
|
|
11
|
+
const configArg = mastraPath.node.arguments[0];
|
|
12
|
+
if (!configArg || configArg.type !== "ObjectExpression") return;
|
|
13
|
+
configArg.properties?.forEach((prop) => {
|
|
14
|
+
if ((prop.type === "Property" || prop.type === "ObjectProperty") && prop.key && prop.key.type === "Identifier" && prop.key.name === "experimental_auth") {
|
|
15
|
+
prop.key.name = "auth";
|
|
16
|
+
context.hasChanges = true;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
if (context.hasChanges) {
|
|
21
|
+
context.messages.push(`Renamed experimental_auth to auth in Mastra configuration`);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
export {
|
|
25
|
+
experimental_auth_default as default
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=experimental-auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/codemods/v1/experimental-auth.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * Renames experimental_auth to auth in Mastra configuration.\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n // Find all new Mastra({ ... }) expressions\n root\n .find(j.NewExpression, {\n callee: { type: 'Identifier', name: 'Mastra' },\n })\n .forEach(mastraPath => {\n const configArg = mastraPath.node.arguments[0];\n if (!configArg || configArg.type !== 'ObjectExpression') return;\n\n // Find experimental_auth property in the Mastra config object\n configArg.properties?.forEach(prop => {\n if (\n (prop.type === 'Property' || prop.type === 'ObjectProperty') &&\n prop.key &&\n prop.key.type === 'Identifier' &&\n prop.key.name === 'experimental_auth'\n ) {\n // Rename to 'auth'\n prop.key.name = 'auth';\n context.hasChanges = true;\n }\n });\n });\n\n if (context.hasChanges) {\n context.messages.push(`Renamed experimental_auth to auth in Mastra configuration`);\n }\n});\n"],"mappings":";;;;;AAKA,IAAO,4BAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,OACG,KAAK,EAAE,eAAe;AAAA,IACrB,QAAQ,EAAE,MAAM,cAAc,MAAM,SAAS;AAAA,EAC/C,CAAC,EACA,QAAQ,gBAAc;AACrB,UAAM,YAAY,WAAW,KAAK,UAAU,CAAC;AAC7C,QAAI,CAAC,aAAa,UAAU,SAAS,mBAAoB;AAGzD,cAAU,YAAY,QAAQ,UAAQ;AACpC,WACG,KAAK,SAAS,cAAc,KAAK,SAAS,qBAC3C,KAAK,OACL,KAAK,IAAI,SAAS,gBAClB,KAAK,IAAI,SAAS,qBAClB;AAEA,aAAK,IAAI,OAAO;AAChB,gBAAQ,aAAa;AAAA,MACvB;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAEH,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS,KAAK,2DAA2D;AAAA,EACnF;AACF,CAAC;","names":[]}
|
|
@@ -1,45 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/codemods/v1/mastra-core-imports.ts
|
|
21
|
-
var mastra_core_imports_exports = {};
|
|
22
|
-
__export(mastra_core_imports_exports, {
|
|
23
|
-
default: () => mastra_core_imports_default
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(mastra_core_imports_exports);
|
|
26
|
-
|
|
27
|
-
// src/codemods/lib/create-transformer.ts
|
|
28
|
-
function createTransformer(transformFn) {
|
|
29
|
-
return function transformer(fileInfo, api, options) {
|
|
30
|
-
const j = api.jscodeshift;
|
|
31
|
-
const root = j(fileInfo.source);
|
|
32
|
-
const context = {
|
|
33
|
-
j,
|
|
34
|
-
root,
|
|
35
|
-
hasChanges: false,
|
|
36
|
-
messages: []
|
|
37
|
-
};
|
|
38
|
-
transformFn(fileInfo, api, options, context);
|
|
39
|
-
context.messages.forEach((message) => api.report(message));
|
|
40
|
-
return context.hasChanges ? root.toSource({ quote: "single" }) : null;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
createTransformer
|
|
3
|
+
} from "../chunk-JNFQ6J6B.js";
|
|
43
4
|
|
|
44
5
|
// src/codemods/v1/mastra-core-imports.ts
|
|
45
6
|
var EXPORT_TO_SUBPATH = {
|
|
@@ -68,8 +29,8 @@ var EXPORT_TO_SUBPATH = {
|
|
|
68
29
|
// Voice
|
|
69
30
|
CompositeVoice: "@mastra/core/voice",
|
|
70
31
|
// Scorers/Evals
|
|
71
|
-
|
|
72
|
-
createScorer: "@mastra/core/
|
|
32
|
+
runEvals: "@mastra/core/evals",
|
|
33
|
+
createScorer: "@mastra/core/evals",
|
|
73
34
|
// Server
|
|
74
35
|
registerApiRoute: "@mastra/core/server",
|
|
75
36
|
// Tracing
|
|
@@ -186,4 +147,7 @@ function updateOriginalImport(j, importPath, node, remainingSpecifiers, context)
|
|
|
186
147
|
function extractRemainingImportNames(remainingSpecifiers) {
|
|
187
148
|
return remainingSpecifiers.filter((s) => s.type === "ImportSpecifier").map((s) => s.imported?.name || s.local?.name).filter(Boolean).join(", ");
|
|
188
149
|
}
|
|
150
|
+
export {
|
|
151
|
+
mastra_core_imports_default as default
|
|
152
|
+
};
|
|
189
153
|
//# sourceMappingURL=mastra-core-imports.js.map
|