@mastra/codemod 0.0.0-main-test-05-11-2025-2-20251106053353 → 0.1.0-beta.1
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 +9 -1
- package/README.md +41 -24
- 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 +13 -70
- package/dist/codemods/v1/agent-generate-stream-v-next.js.map +1 -1
- package/dist/codemods/v1/agent-processor-methods.js +14 -71
- package/dist/codemods/v1/agent-processor-methods.js.map +1 -1
- package/dist/codemods/v1/agent-property-access.js +11 -50
- package/dist/codemods/v1/agent-property-access.js.map +1 -1
- package/dist/codemods/v1/agent-voice.js +10 -49
- package/dist/codemods/v1/agent-voice.js.map +1 -1
- 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 +7 -43
- package/dist/codemods/v1/experimental-auth.js.map +1 -1
- 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 +14 -66
- package/dist/codemods/v1/mcp-get-tools.js.map +1 -1
- package/dist/codemods/v1/mcp-get-toolsets.js +14 -66
- package/dist/codemods/v1/mcp-get-toolsets.js.map +1 -1
- 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 +12 -48
- package/dist/codemods/v1/voice-property-names.js.map +1 -1
- 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 +66 -46
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/dist/codemods/v1/agent-get-agents.js +0 -74
- package/dist/codemods/v1/agent-get-agents.js.map +0 -1
- package/dist/codemods/v1/evals-get-scorers.js +0 -74
- package/dist/codemods/v1/evals-get-scorers.js.map +0 -1
- package/dist/codemods/v1/mcp-get-mcp-servers.js +0 -74
- package/dist/codemods/v1/mcp-get-mcp-servers.js.map +0 -1
- package/dist/codemods/v1/workflows-get-workflows.js +0 -74
- package/dist/codemods/v1/workflows-get-workflows.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/codemods/v1/agent-abort-signal.ts"],"sourcesContent":["import type {\n ObjectProperty,\n Property,\n ObjectExpression,\n SpreadElement,\n ObjectMethod,\n SpreadProperty,\n} from 'jscodeshift';\nimport { createTransformer } from '../lib/create-transformer';\nimport { trackClassInstances } from '../lib/utils';\n\n/**\n * Moves abortSignal from modelSettings to top-level options in agent method calls.\n *\n * ```ts\n * // Before:\n * agent.stream('prompt', {\n * modelSettings: { abortSignal: signal }\n * })\n *\n * // After:\n * agent.stream('prompt', {\n * modelSettings: {},\n * abortSignal: signal\n * })\n * ```\n */\nexport default createTransformer((_fileInfo, _api, _options, context) => {\n const { j, root } = context;\n\n // Track Agent instances\n const agentInstances = trackClassInstances(j, root, 'Agent');\n\n // Early return if no instances found\n if (agentInstances.size === 0) return;\n\n // Single pass: Find and transform agent method calls\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 // Only process if called on an Agent instance\n if (!agentInstances.has(callee.object.name)) return;\n\n const args = path.value.arguments;\n\n // We're looking for calls with an options object that has modelSettings\n if (args.length < 2) return;\n\n const optionsArg = args[1];\n if (!optionsArg || optionsArg.type !== 'ObjectExpression') return;\n if (!optionsArg.properties) return;\n\n // Find the modelSettings property\n type ObjectProp = SpreadElement | Property | ObjectMethod | ObjectProperty | SpreadProperty;\n let modelSettingsIndex = -1;\n const modelSettingsProp = optionsArg.properties.find((prop, index) => {\n if (\n (prop.type === 'Property' || prop.type === 'ObjectProperty') &&\n prop.key?.type === 'Identifier' &&\n prop.key.name === 'modelSettings' &&\n prop.value?.type === 'ObjectExpression'\n ) {\n modelSettingsIndex = index;\n return true;\n }\n return false;\n }) as Property | ObjectProperty | undefined;\n\n if (!modelSettingsProp || modelSettingsProp.value?.type !== 'ObjectExpression') return;\n if (modelSettingsIndex === -1) return;\n\n const modelSettingsValue = modelSettingsProp.value as ObjectExpression;\n\n // Find abortSignal property inside modelSettings\n let abortSignalProp: Property | ObjectProperty | undefined;\n const filteredProperties = modelSettingsValue.properties?.filter(prop => {\n if (\n (prop.type === 'Property' || prop.type === 'ObjectProperty') &&\n prop.key?.type === 'Identifier' &&\n prop.key.name === 'abortSignal'\n ) {\n abortSignalProp = prop;\n return false; // Remove this property\n }\n return true; // Keep all other properties\n });\n\n if (!abortSignalProp) return;\n\n // Update modelSettings to not include abortSignal\n modelSettingsValue.properties = filteredProperties;\n\n // Rebuild the parent options properties with abortSignal right after modelSettings\n const newProperties: ObjectProp[] = [];\n optionsArg.properties.forEach((prop, index) => {\n newProperties.push(prop);\n if (index === modelSettingsIndex) {\n newProperties.push(abortSignalProp!);\n }\n });\n\n optionsArg.properties = newProperties;\n context.hasChanges = true;\n });\n\n if (context.hasChanges) {\n context.messages.push('Moved abortSignal from modelSettings to top-level options in agent method calls');\n }\n});\n"],"mappings":";;;;;;;;AA2BA,IAAO,6BAAQ,kBAAkB,CAAC,WAAW,MAAM,UAAU,YAAY;AACvE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,iBAAiB,oBAAoB,GAAG,MAAM,OAAO;AAG3D,MAAI,eAAe,SAAS,EAAG;AAG/B,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,QAAI,CAAC,eAAe,IAAI,OAAO,OAAO,IAAI,EAAG;AAE7C,UAAM,OAAO,KAAK,MAAM;AAGxB,QAAI,KAAK,SAAS,EAAG;AAErB,UAAM,aAAa,KAAK,CAAC;AACzB,QAAI,CAAC,cAAc,WAAW,SAAS,mBAAoB;AAC3D,QAAI,CAAC,WAAW,WAAY;AAI5B,QAAI,qBAAqB;AACzB,UAAM,oBAAoB,WAAW,WAAW,KAAK,CAAC,MAAM,UAAU;AACpE,WACG,KAAK,SAAS,cAAc,KAAK,SAAS,qBAC3C,KAAK,KAAK,SAAS,gBACnB,KAAK,IAAI,SAAS,mBAClB,KAAK,OAAO,SAAS,oBACrB;AACA,6BAAqB;AACrB,eAAO;AAAA,MACT;AACA,aAAO;AAAA,IACT,CAAC;AAED,QAAI,CAAC,qBAAqB,kBAAkB,OAAO,SAAS,mBAAoB;AAChF,QAAI,uBAAuB,GAAI;AAE/B,UAAM,qBAAqB,kBAAkB;AAG7C,QAAI;AACJ,UAAM,qBAAqB,mBAAmB,YAAY,OAAO,UAAQ;AACvE,WACG,KAAK,SAAS,cAAc,KAAK,SAAS,qBAC3C,KAAK,KAAK,SAAS,gBACnB,KAAK,IAAI,SAAS,eAClB;AACA,0BAAkB;AAClB,eAAO;AAAA,MACT;AACA,aAAO;AAAA,IACT,CAAC;AAED,QAAI,CAAC,gBAAiB;AAGtB,uBAAmB,aAAa;AAGhC,UAAM,gBAA8B,CAAC;AACrC,eAAW,WAAW,QAAQ,CAAC,MAAM,UAAU;AAC7C,oBAAc,KAAK,IAAI;AACvB,UAAI,UAAU,oBAAoB;AAChC,sBAAc,KAAK,eAAgB;AAAA,MACrC;AAAA,IACF,CAAC;AAED,eAAW,aAAa;AACxB,YAAQ,aAAa;AAAA,EACvB,CAAC;AAED,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS,KAAK,iFAAiF;AAAA,EACzG;AACF,CAAC;","names":[]}
|
|
@@ -1,45 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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/agent-generate-stream-v-next.ts
|
|
21
|
-
var agent_generate_stream_v_next_exports = {};
|
|
22
|
-
__export(agent_generate_stream_v_next_exports, {
|
|
23
|
-
default: () => agent_generate_stream_v_next_default
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(agent_generate_stream_v_next_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";
|
|
4
|
+
import {
|
|
5
|
+
renameMethods,
|
|
6
|
+
trackClassInstances
|
|
7
|
+
} from "../chunk-PKCFDS7J.js";
|
|
43
8
|
|
|
44
9
|
// src/codemods/v1/agent-generate-stream-v-next.ts
|
|
45
10
|
var agent_generate_stream_v_next_default = createTransformer((fileInfo, api, options, context) => {
|
|
@@ -48,36 +13,14 @@ var agent_generate_stream_v_next_default = createTransformer((fileInfo, api, opt
|
|
|
48
13
|
generateVNext: "generate",
|
|
49
14
|
streamVNext: "stream"
|
|
50
15
|
};
|
|
51
|
-
const agentVariables =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (node.init && node.init.type === "NewExpression" && node.init.callee.type === "Identifier" && node.init.callee.name === "Agent" && node.id.type === "Identifier") {
|
|
55
|
-
agentVariables.add(node.id.name);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
if (agentVariables.size === 0) return;
|
|
59
|
-
root.find(j.CallExpression).forEach((path) => {
|
|
60
|
-
const node = path.node;
|
|
61
|
-
if (node.callee.type !== "MemberExpression") {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
const callee = node.callee;
|
|
65
|
-
if (callee.object.type !== "Identifier" || !agentVariables.has(callee.object.name)) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (callee.property.type !== "Identifier") {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const oldMethodName = callee.property.name;
|
|
72
|
-
const newMethodName = methodRenames[oldMethodName];
|
|
73
|
-
if (!newMethodName) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
callee.property.name = newMethodName;
|
|
16
|
+
const agentVariables = trackClassInstances(j, root, "Agent");
|
|
17
|
+
const renamed = renameMethods(j, root, agentVariables, methodRenames);
|
|
18
|
+
if (renamed > 0) {
|
|
77
19
|
context.hasChanges = true;
|
|
78
|
-
});
|
|
79
|
-
if (context.hasChanges) {
|
|
80
20
|
context.messages.push(`Transformed Agent VNext methods: generateVNext/streamVNext \u2192 generate/stream`);
|
|
81
21
|
}
|
|
82
22
|
});
|
|
23
|
+
export {
|
|
24
|
+
agent_generate_stream_v_next_default as default
|
|
25
|
+
};
|
|
83
26
|
//# sourceMappingURL=agent-generate-stream-v-next.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/codemods/v1/agent-generate-stream-v-next.ts"
|
|
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":[]}
|
|
@@ -1,85 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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);
|
|
1
|
+
import {
|
|
2
|
+
createTransformer
|
|
3
|
+
} from "../chunk-JNFQ6J6B.js";
|
|
4
|
+
import {
|
|
5
|
+
renameMethods,
|
|
6
|
+
trackClassInstances
|
|
7
|
+
} from "../chunk-PKCFDS7J.js";
|
|
19
8
|
|
|
20
9
|
// src/codemods/v1/agent-processor-methods.ts
|
|
21
|
-
var
|
|
22
|
-
__export(agent_processor_methods_exports, {
|
|
23
|
-
default: () => agent_processor_methods_default
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(agent_processor_methods_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
|
-
}
|
|
43
|
-
|
|
44
|
-
// src/codemods/v1/agent-processor-methods.ts
|
|
45
|
-
var agent_processor_methods_default = createTransformer((fileInfo, api, options, context) => {
|
|
10
|
+
var agent_processor_methods_default = createTransformer((_fileInfo, _api, _options, context) => {
|
|
46
11
|
const { j, root } = context;
|
|
47
12
|
const methodRenames = {
|
|
48
13
|
getInputProcessors: "listInputProcessors",
|
|
49
14
|
getOutputProcessors: "listOutputProcessors"
|
|
50
15
|
};
|
|
51
|
-
const agentVariables =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (node.init && node.init.type === "NewExpression" && node.init.callee.type === "Identifier" && node.init.callee.name === "Agent" && node.id.type === "Identifier") {
|
|
55
|
-
agentVariables.add(node.id.name);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
if (agentVariables.size === 0) return;
|
|
59
|
-
root.find(j.CallExpression).forEach((path) => {
|
|
60
|
-
const node = path.node;
|
|
61
|
-
if (node.callee.type !== "MemberExpression") {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
const callee = node.callee;
|
|
65
|
-
if (callee.object.type !== "Identifier" || !agentVariables.has(callee.object.name)) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (callee.property.type !== "Identifier") {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const oldMethodName = callee.property.name;
|
|
72
|
-
const newMethodName = methodRenames[oldMethodName];
|
|
73
|
-
if (!newMethodName) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
callee.property.name = newMethodName;
|
|
16
|
+
const agentVariables = trackClassInstances(j, root, "Agent");
|
|
17
|
+
const count = renameMethods(j, root, agentVariables, methodRenames);
|
|
18
|
+
if (count > 0) {
|
|
77
19
|
context.hasChanges = true;
|
|
78
|
-
});
|
|
79
|
-
if (context.hasChanges) {
|
|
80
20
|
context.messages.push(
|
|
81
21
|
`Transformed Agent processor methods: getInputProcessors/getOutputProcessors \u2192 listInputProcessors/listOutputProcessors`
|
|
82
22
|
);
|
|
83
23
|
}
|
|
84
24
|
});
|
|
25
|
+
export {
|
|
26
|
+
agent_processor_methods_default as default
|
|
27
|
+
};
|
|
85
28
|
//# sourceMappingURL=agent-processor-methods.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/codemods/v1/agent-processor-methods.ts"
|
|
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":[]}
|
|
@@ -1,61 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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/agent-property-access.ts
|
|
21
|
-
var agent_property_access_exports = {};
|
|
22
|
-
__export(agent_property_access_exports, {
|
|
23
|
-
default: () => agent_property_access_default
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(agent_property_access_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";
|
|
4
|
+
import {
|
|
5
|
+
trackClassInstances
|
|
6
|
+
} from "../chunk-PKCFDS7J.js";
|
|
43
7
|
|
|
44
8
|
// src/codemods/v1/agent-property-access.ts
|
|
45
|
-
var agent_property_access_default = createTransformer((
|
|
9
|
+
var agent_property_access_default = createTransformer((_fileInfo, _api, _options, context) => {
|
|
46
10
|
const { j, root } = context;
|
|
47
11
|
const propertyToMethod = {
|
|
48
12
|
llm: "getLLM",
|
|
49
13
|
tools: "getTools",
|
|
50
14
|
instructions: "getInstructions"
|
|
51
15
|
};
|
|
52
|
-
const agentVariables =
|
|
53
|
-
root.find(j.VariableDeclarator).forEach((path) => {
|
|
54
|
-
const node = path.node;
|
|
55
|
-
if (node.init && node.init.type === "NewExpression" && node.init.callee.type === "Identifier" && node.init.callee.name === "Agent" && node.id.type === "Identifier") {
|
|
56
|
-
agentVariables.add(node.id.name);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
16
|
+
const agentVariables = trackClassInstances(j, root, "Agent");
|
|
59
17
|
if (agentVariables.size === 0) return;
|
|
60
18
|
root.find(j.MemberExpression).forEach((path) => {
|
|
61
19
|
const node = path.node;
|
|
@@ -78,4 +36,7 @@ var agent_property_access_default = createTransformer((fileInfo, api, options, c
|
|
|
78
36
|
context.messages.push(`Transformed Agent property access to method calls`);
|
|
79
37
|
}
|
|
80
38
|
});
|
|
39
|
+
export {
|
|
40
|
+
agent_property_access_default as default
|
|
41
|
+
};
|
|
81
42
|
//# sourceMappingURL=agent-property-access.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/codemods/v1/agent-property-access.ts"
|
|
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":[]}
|
|
@@ -1,57 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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/agent-voice.ts
|
|
21
|
-
var agent_voice_exports = {};
|
|
22
|
-
__export(agent_voice_exports, {
|
|
23
|
-
default: () => agent_voice_default
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(agent_voice_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";
|
|
4
|
+
import {
|
|
5
|
+
trackClassInstances
|
|
6
|
+
} from "../chunk-PKCFDS7J.js";
|
|
43
7
|
|
|
44
8
|
// src/codemods/v1/agent-voice.ts
|
|
45
9
|
var agent_voice_default = createTransformer((fileInfo, api, options, context) => {
|
|
46
10
|
const { j, root } = context;
|
|
47
11
|
const voiceMethods = /* @__PURE__ */ new Set(["speak", "listen", "getSpeakers"]);
|
|
48
|
-
const agentVariables =
|
|
49
|
-
root.find(j.VariableDeclarator).forEach((path) => {
|
|
50
|
-
const node = path.node;
|
|
51
|
-
if (node.init && node.init.type === "NewExpression" && node.init.callee.type === "Identifier" && node.init.callee.name === "Agent" && node.id.type === "Identifier") {
|
|
52
|
-
agentVariables.add(node.id.name);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
12
|
+
const agentVariables = trackClassInstances(j, root, "Agent");
|
|
55
13
|
if (agentVariables.size === 0) return;
|
|
56
14
|
root.find(j.CallExpression).forEach((path) => {
|
|
57
15
|
const node = path.node;
|
|
@@ -73,4 +31,7 @@ var agent_voice_default = createTransformer((fileInfo, api, options, context) =>
|
|
|
73
31
|
context.messages.push(`Transformed Agent voice methods to use agent.voice namespace`);
|
|
74
32
|
}
|
|
75
33
|
});
|
|
34
|
+
export {
|
|
35
|
+
agent_voice_default as default
|
|
36
|
+
};
|
|
76
37
|
//# sourceMappingURL=agent-voice.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/codemods/v1/agent-voice.ts"
|
|
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
|