@mastra/codemod 0.0.0-fix-thread-list-20251105222841 → 0.0.0-fix-issue-10434-concurrent-write-corruption-20251124213939

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.
Files changed (87) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/README.md +46 -11
  3. package/dist/codemods/chunk-JNFQ6J6B.js +21 -0
  4. package/dist/codemods/chunk-JNFQ6J6B.js.map +1 -0
  5. package/dist/codemods/chunk-LGW3NUAJ.js +32 -0
  6. package/dist/codemods/chunk-LGW3NUAJ.js.map +1 -0
  7. package/dist/codemods/chunk-PKCFDS7J.js +177 -0
  8. package/dist/codemods/chunk-PKCFDS7J.js.map +1 -0
  9. package/dist/codemods/lib/add-comment.js +6 -54
  10. package/dist/codemods/lib/add-comment.js.map +1 -1
  11. package/dist/codemods/lib/create-transformer.js +5 -43
  12. package/dist/codemods/lib/create-transformer.js.map +1 -1
  13. package/dist/codemods/lib/utils.js +23 -0
  14. package/dist/codemods/lib/utils.js.map +1 -0
  15. package/dist/codemods/v1/agent-abort-signal.js +61 -0
  16. package/dist/codemods/v1/agent-abort-signal.js.map +1 -0
  17. package/dist/codemods/v1/agent-generate-stream-v-next.js +26 -0
  18. package/dist/codemods/v1/agent-generate-stream-v-next.js.map +1 -0
  19. package/dist/codemods/v1/agent-processor-methods.js +28 -0
  20. package/dist/codemods/v1/agent-processor-methods.js.map +1 -0
  21. package/dist/codemods/v1/agent-property-access.js +42 -0
  22. package/dist/codemods/v1/agent-property-access.js.map +1 -0
  23. package/dist/codemods/v1/agent-voice.js +37 -0
  24. package/dist/codemods/v1/agent-voice.js.map +1 -0
  25. package/dist/codemods/v1/client-get-memory-thread.js +58 -0
  26. package/dist/codemods/v1/client-get-memory-thread.js.map +1 -0
  27. package/dist/codemods/v1/client-offset-limit.js +49 -0
  28. package/dist/codemods/v1/client-offset-limit.js.map +1 -0
  29. package/dist/codemods/v1/client-sdk-types.js +56 -0
  30. package/dist/codemods/v1/client-sdk-types.js.map +1 -0
  31. package/dist/codemods/v1/client-to-ai-sdk-format.js +20 -0
  32. package/dist/codemods/v1/client-to-ai-sdk-format.js.map +1 -0
  33. package/dist/codemods/v1/evals-prebuilt-imports.js +24 -0
  34. package/dist/codemods/v1/evals-prebuilt-imports.js.map +1 -0
  35. package/dist/codemods/v1/evals-run-experiment.js +20 -0
  36. package/dist/codemods/v1/evals-run-experiment.js.map +1 -0
  37. package/dist/codemods/v1/evals-scorer-by-name.js +22 -0
  38. package/dist/codemods/v1/evals-scorer-by-name.js.map +1 -0
  39. package/dist/codemods/v1/experimental-auth.js +27 -0
  40. package/dist/codemods/v1/experimental-auth.js.map +1 -0
  41. package/dist/codemods/v1/mastra-core-imports.js +11 -47
  42. package/dist/codemods/v1/mastra-core-imports.js.map +1 -1
  43. package/dist/codemods/v1/mastra-plural-apis.js +31 -0
  44. package/dist/codemods/v1/mastra-plural-apis.js.map +1 -0
  45. package/dist/codemods/v1/mcp-get-tools.js +24 -0
  46. package/dist/codemods/v1/mcp-get-tools.js.map +1 -0
  47. package/dist/codemods/v1/mcp-get-toolsets.js +24 -0
  48. package/dist/codemods/v1/mcp-get-toolsets.js.map +1 -0
  49. package/dist/codemods/v1/memory-message-v2-type.js +50 -0
  50. package/dist/codemods/v1/memory-message-v2-type.js.map +1 -0
  51. package/dist/codemods/v1/memory-query-to-recall.js +22 -0
  52. package/dist/codemods/v1/memory-query-to-recall.js.map +1 -0
  53. package/dist/codemods/v1/memory-vector-search-param.js +31 -0
  54. package/dist/codemods/v1/memory-vector-search-param.js.map +1 -0
  55. package/dist/codemods/v1/not-implemented/agent-format-parameter.js +53 -0
  56. package/dist/codemods/v1/not-implemented/agent-format-parameter.js.map +1 -0
  57. package/dist/codemods/v1/not-implemented/agent-to-step.js +54 -0
  58. package/dist/codemods/v1/not-implemented/agent-to-step.js.map +1 -0
  59. package/dist/codemods/v1/not-implemented/mastra-memory.js +50 -0
  60. package/dist/codemods/v1/not-implemented/mastra-memory.js.map +1 -0
  61. package/dist/codemods/v1/not-implemented/mastra-required-id.js +113 -0
  62. package/dist/codemods/v1/not-implemented/mastra-required-id.js.map +1 -0
  63. package/dist/codemods/v1/runtime-context.js +6 -42
  64. package/dist/codemods/v1/runtime-context.js.map +1 -1
  65. package/dist/codemods/v1/storage-get-messages-paginated.js +41 -0
  66. package/dist/codemods/v1/storage-get-messages-paginated.js.map +1 -0
  67. package/dist/codemods/v1/storage-get-threads-by-resource.js +23 -0
  68. package/dist/codemods/v1/storage-get-threads-by-resource.js.map +1 -0
  69. package/dist/codemods/v1/storage-list-messages-by-id.js +23 -0
  70. package/dist/codemods/v1/storage-list-messages-by-id.js.map +1 -0
  71. package/dist/codemods/v1/storage-list-workflow-runs.js +23 -0
  72. package/dist/codemods/v1/storage-list-workflow-runs.js.map +1 -0
  73. package/dist/codemods/v1/storage-postgres-schema-name.js +20 -0
  74. package/dist/codemods/v1/storage-postgres-schema-name.js.map +1 -0
  75. package/dist/codemods/v1/vector-pg-constructor.js +27 -0
  76. package/dist/codemods/v1/vector-pg-constructor.js.map +1 -0
  77. package/dist/codemods/v1/voice-property-names.js +42 -0
  78. package/dist/codemods/v1/voice-property-names.js.map +1 -0
  79. package/dist/codemods/v1/workflow-create-run-async.js +22 -0
  80. package/dist/codemods/v1/workflow-create-run-async.js.map +1 -0
  81. package/dist/codemods/v1/workflow-list-runs.js +22 -0
  82. package/dist/codemods/v1/workflow-list-runs.js.map +1 -0
  83. package/dist/codemods/v1/workflow-run-count.js +53 -0
  84. package/dist/codemods/v1/workflow-run-count.js.map +1 -0
  85. package/dist/index.js +114 -27
  86. package/dist/index.js.map +1 -1
  87. package/package.json +9 -5
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/codemods/v1/not-implemented/mastra-required-id.ts"],"sourcesContent":["/* eslint-disable no-warning-comments */\nimport { insertCommentOnce } from '../../lib/add-comment';\nimport { createTransformer } from '../../lib/create-transformer';\n\n/**\n * Adds FIXME comments to Mastra primitives that now require an `id` parameter.\n * This includes storages, vector stores, agents, workflows, tools, scorers, and MCP servers.\n *\n * Before:\n * const agent = new Agent({ name: 'Support Agent' });\n * const tool = createTool({ description: 'Get weather' });\n *\n * After:\n * /* FIXME(mastra): Add a unique `id` parameter. See: ... *\\/\n * const agent = new Agent({ name: 'Support Agent' });\n * /* FIXME(mastra): Add a unique `id` parameter. See: ... *\\/\n * const tool = createTool({ description: 'Get weather' });\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n const COMMENT_MESSAGE =\n 'FIXME(mastra): Add a unique `id` parameter. See: https://mastra.ai/guides/v1/migrations/upgrade-to-v1/mastra#required-id-parameter-for-all-mastra-primitives';\n\n // List of class names that require id\n const storageClasses = [\n 'LibSQLStore',\n 'PostgresStore',\n 'D1Store',\n 'MongoDBStore',\n 'DynamoDBStore',\n 'LibSQLVector',\n 'PgVector',\n 'ChromaVector',\n 'PineconeVector',\n 'QdrantVector',\n 'LanceVector',\n 'Agent',\n 'MCPServer',\n ];\n\n // List of function names that require id\n const createFunctions = ['createWorkflow', 'createTool', 'createScorer'];\n\n // Find NewExpression for classes\n root.find(j.NewExpression).forEach(path => {\n if (path.value.callee.type === 'Identifier') {\n const className = path.value.callee.name;\n\n if (storageClasses.includes(className)) {\n // Check if the config already has an id property\n const hasId = path.value.arguments.some(arg => {\n if (arg.type === 'ObjectExpression') {\n return arg.properties?.some(\n prop =>\n (prop.type === 'Property' || prop.type === 'ObjectProperty') &&\n prop.key?.type === 'Identifier' &&\n prop.key.name === 'id',\n );\n }\n return false;\n });\n\n if (!hasId) {\n // Find the parent statement to add comment\n let parent = path.parent;\n const statementTypes = new Set([\n 'VariableDeclaration',\n 'ExpressionStatement',\n 'ReturnStatement',\n 'ExportDefaultDeclaration',\n 'ExportNamedDeclaration',\n 'Program',\n ]);\n\n while (parent && !statementTypes.has(parent.value.type)) {\n parent = parent.parent;\n }\n\n if (parent && parent.value) {\n // For export declarations, add comment to the export itself\n let targetNode = parent.value;\n if (\n targetNode.type !== 'ExportDefaultDeclaration' &&\n targetNode.type !== 'ExportNamedDeclaration' &&\n parent.parent &&\n (parent.parent.value.type === 'ExportDefaultDeclaration' ||\n parent.parent.value.type === 'ExportNamedDeclaration')\n ) {\n targetNode = parent.parent.value;\n }\n\n const added = insertCommentOnce(targetNode, j, COMMENT_MESSAGE);\n if (added) {\n context.hasChanges = true;\n }\n }\n }\n }\n }\n });\n\n // Find CallExpression for create functions\n root.find(j.CallExpression).forEach(path => {\n if (path.value.callee.type === 'Identifier') {\n const functionName = path.value.callee.name;\n\n if (createFunctions.includes(functionName)) {\n // Check if the config already has an id property\n const hasId = path.value.arguments.some(arg => {\n if (arg.type === 'ObjectExpression') {\n return arg.properties?.some(\n prop =>\n (prop.type === 'Property' || prop.type === 'ObjectProperty') &&\n prop.key?.type === 'Identifier' &&\n prop.key.name === 'id',\n );\n }\n return false;\n });\n\n if (!hasId) {\n // Find the parent statement to add comment\n let parent = path.parent;\n const statementTypes = new Set([\n 'VariableDeclaration',\n 'ExpressionStatement',\n 'ReturnStatement',\n 'ExportDefaultDeclaration',\n 'ExportNamedDeclaration',\n 'Program',\n ]);\n\n while (parent && !statementTypes.has(parent.value.type)) {\n parent = parent.parent;\n }\n\n if (parent && parent.value) {\n // For export declarations, add comment to the export itself\n let targetNode = parent.value;\n if (\n targetNode.type !== 'ExportDefaultDeclaration' &&\n targetNode.type !== 'ExportNamedDeclaration' &&\n parent.parent &&\n (parent.parent.value.type === 'ExportDefaultDeclaration' ||\n parent.parent.value.type === 'ExportNamedDeclaration')\n ) {\n targetNode = parent.parent.value;\n }\n\n const added = insertCommentOnce(targetNode, j, COMMENT_MESSAGE);\n if (added) {\n context.hasChanges = true;\n }\n }\n }\n }\n }\n });\n\n if (context.hasChanges) {\n context.messages.push(`Not Implemented ${fileInfo.path}: Mastra primitives now require a unique id parameter.`);\n }\n});\n"],"mappings":";;;;;;;;AAkBA,IAAO,6BAAQ,kBAAkB,CAAC,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AAQ,SAAS,KAAK,mBAAmB,SAAS,IAAI,wDAAwD;AAAA,EAChH;AACF,CAAC;","names":[]}
@@ -1,45 +1,6 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
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/runtime-context.ts
21
- var runtime_context_exports = {};
22
- __export(runtime_context_exports, {
23
- default: () => runtime_context_default
24
- });
25
- module.exports = __toCommonJS(runtime_context_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/runtime-context.ts
45
6
  var runtime_context_default = createTransformer((fileInfo, api, options, context) => {
@@ -163,4 +124,7 @@ function shouldProcessKey(key, node) {
163
124
  if (key === "loc" || key === "comments") return false;
164
125
  return true;
165
126
  }
127
+ export {
128
+ runtime_context_default as default
129
+ };
166
130
  //# sourceMappingURL=runtime-context.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/codemods/v1/runtime-context.ts","../../../src/codemods/lib/create-transformer.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * The `RuntimeContext` class has been renamed to `RequestContext`, and all parameter names have been updated from `runtimeContext` to `requestContext` across all APIs.\n */\n\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n // Track whether RuntimeContext was imported from @mastra/core/runtime-context\n let hasRuntimeContextImport = false;\n\n // 1. Update import declarations from runtime-context to request-context\n root.find(j.ImportDeclaration).forEach(importPath => {\n const node = importPath.node;\n\n // Early return: Only process imports from @mastra/core/runtime-context\n if (node.source.value !== '@mastra/core/runtime-context') return;\n\n // Update the import path\n node.source.value = '@mastra/core/request-context';\n context.hasChanges = true;\n\n // Update RuntimeContext to RequestContext in import specifiers\n node.specifiers?.forEach(specifier => {\n if (specifier.type !== 'ImportSpecifier') return;\n\n const imported = specifier.imported;\n if (imported.type === 'Identifier' && imported.name === 'RuntimeContext') {\n hasRuntimeContextImport = true;\n imported.name = 'RequestContext';\n context.messages.push(`Updated import: RuntimeContext → RequestContext from '@mastra/core/request-context'`);\n }\n });\n });\n\n // Early return: Only proceed if RuntimeContext was imported from Mastra\n if (!hasRuntimeContextImport) return;\n\n // 2. Rename RuntimeContext type/class references\n renameIdentifiers(j, root, context, 'RuntimeContext', 'RequestContext', 'type');\n\n // 3. Rename runtimeContext variable/parameter identifiers\n renameIdentifiers(j, root, context, 'runtimeContext', 'requestContext', 'variable/parameter');\n\n // 4. Rename string literal 'runtimeContext' to 'requestContext' in Mastra middleware\n renameMiddlewareStringLiterals(j, root, context);\n});\n\n/**\n * Helper to rename all occurrences of an identifier\n */\nfunction renameIdentifiers(j: any, root: any, context: any, oldName: string, newName: string, description: string) {\n const identifiers = root.find(j.Identifier, { name: oldName });\n const count = identifiers.length;\n\n if (count === 0) return;\n\n identifiers.forEach((path: any) => {\n path.node.name = newName;\n });\n\n context.hasChanges = true;\n context.messages.push(`Renamed ${count} ${oldName} ${description} references to ${newName}`);\n}\n\n/**\n * Helper to rename 'runtimeContext' string literals in Mastra middleware handlers\n */\nfunction renameMiddlewareStringLiterals(j: any, root: any, context: any) {\n let stringLiteralCount = 0;\n\n // Find all new Mastra({ ... }) expressions\n root\n .find(j.NewExpression, {\n callee: { type: 'Identifier', name: 'Mastra' },\n })\n .forEach((mastraPath: any) => {\n const configArg = mastraPath.node.arguments[0];\n if (!configArg || configArg.type !== 'ObjectExpression') return;\n\n // Process this Mastra config to find and rename context.get() calls\n const contextParamNames = new Set<string>();\n stringLiteralCount += processNode(configArg, contextParamNames, context);\n });\n\n if (stringLiteralCount > 0) {\n context.messages.push(\n `Renamed ${stringLiteralCount} string literal 'runtimeContext' to 'requestContext' in Mastra server.middleware`,\n );\n }\n}\n\n/**\n * Recursively search for handler properties and rename context.get() calls\n */\nfunction processNode(node: any, contextParamNames: Set<string>, context: any): number {\n if (!node || typeof node !== 'object') return 0;\n\n let count = 0;\n\n // Check if this is a handler property\n if (isHandlerProperty(node)) {\n const paramName = extractFirstParamName(node.value);\n if (paramName) {\n contextParamNames.add(paramName);\n }\n }\n\n // Check if this is a context.get('runtimeContext') call\n if (isContextGetCall(node, contextParamNames)) {\n if (renameStringLiteralArg(node, context)) {\n count++;\n }\n }\n\n // Recursively process all object properties\n for (const key in node) {\n if (!shouldProcessKey(key, node)) continue;\n\n const value = node[key];\n if (Array.isArray(value)) {\n value.forEach(item => {\n count += processNode(item, contextParamNames, context);\n });\n } else if (value && typeof value === 'object') {\n count += processNode(value, contextParamNames, context);\n }\n }\n\n return count;\n}\n\n/**\n * Check if a node is a handler property (Property or ObjectProperty with key 'handler')\n */\nfunction isHandlerProperty(node: any): boolean {\n return (node.type === 'Property' || node.type === 'ObjectProperty') && node.key?.name === 'handler';\n}\n\n/**\n * Extract the first parameter name from a function expression\n */\nfunction extractFirstParamName(handlerValue: any): string | null {\n if (\n !handlerValue ||\n (handlerValue.type !== 'ArrowFunctionExpression' && handlerValue.type !== 'FunctionExpression')\n ) {\n return null;\n }\n\n if (!handlerValue.params || handlerValue.params.length === 0) {\n return null;\n }\n\n const firstParam = handlerValue.params[0];\n if (firstParam?.type === 'Identifier') {\n return firstParam.name;\n }\n\n return null;\n}\n\n/**\n * Check if a node is a context.get() call expression\n */\nfunction isContextGetCall(node: any, contextParamNames: Set<string>): boolean {\n if (node.type !== 'CallExpression') return false;\n\n const callee = node.callee;\n if (!callee || callee.type !== 'MemberExpression') return false;\n\n const object = callee.object;\n if (!object || object.type !== 'Identifier') return false;\n\n if (!contextParamNames.has(object.name)) return false;\n\n const property = callee.property;\n if (!property || property.type !== 'Identifier' || property.name !== 'get') return false;\n\n return true;\n}\n\n/**\n * Rename the first string argument from 'runtimeContext' to 'requestContext'\n */\nfunction renameStringLiteralArg(node: any, context: any): boolean {\n const firstArg = node.arguments?.[0];\n if (!firstArg) return false;\n\n const isRuntimeContextLiteral =\n (firstArg.type === 'StringLiteral' && firstArg.value === 'runtimeContext') ||\n (firstArg.type === 'Literal' && firstArg.value === 'runtimeContext');\n\n if (!isRuntimeContextLiteral) return false;\n\n // Rename the value\n firstArg.value = 'requestContext';\n\n // Update the raw value if it exists\n if (firstArg.extra?.raw) {\n const quote = firstArg.extra.raw.charAt(0);\n firstArg.extra.raw = `${quote}requestContext${quote}`;\n }\n\n context.hasChanges = true;\n return true;\n}\n\n/**\n * Check if we should process this object key during recursion\n */\nfunction shouldProcessKey(key: string, node: any): boolean {\n // Skip non-own properties\n if (!node.hasOwnProperty(key)) return false;\n\n // Skip metadata properties that don't contain code\n if (key === 'loc' || key === 'comments') return false;\n\n return true;\n}\n","// Copied from https://github.com/vercel/ai/blob/main/packages/codemod/src/codemods/lib/create-transformer.ts\n// License: Apache-2.0\n\nimport type { FileInfo, API, JSCodeshift, Collection } from 'jscodeshift';\n\ntype TransformerFunction = (fileInfo: FileInfo, api: API, options: any, context: TransformContext) => void;\n\nexport interface TransformContext {\n /**\n * The jscodeshift API object.\n */\n j: JSCodeshift;\n\n /**\n * The root collection of the AST.\n */\n root: Collection<any>;\n\n /**\n * Codemods should set this to true if they make any changes to the AST.\n */\n hasChanges: boolean;\n\n /**\n * Codemods can append messages to this array to report information to the user.\n */\n messages: string[];\n}\n\nexport function createTransformer(transformFn: TransformerFunction) {\n // Note the return type of this function is explicitly designed to conform to\n // the signature expected by jscodeshift. For more see\n // https://github.com/facebook/jscodeshift\n return function transformer(fileInfo: FileInfo, api: API, options: any) {\n const j = api.jscodeshift;\n const root = j(fileInfo.source);\n const context: TransformContext = {\n j,\n root,\n hasChanges: false,\n messages: [],\n };\n\n // Execute the transformation\n transformFn(fileInfo, api, options, context);\n\n // Report any messages\n context.messages.forEach(message => api.report(message));\n\n // Return the transformed source code if changes were made\n return context.hasChanges ? root.toSource({ quote: 'single' }) : null;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6BO,SAAS,kBAAkB,aAAkC;AAIlE,SAAO,SAAS,YAAY,UAAoB,KAAU,SAAc;AACtE,UAAM,IAAI,IAAI;AACd,UAAM,OAAO,EAAE,SAAS,MAAM;AAC9B,UAAM,UAA4B;AAAA,MAChC;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ,UAAU,CAAC;AAAA,IACb;AAGA,gBAAY,UAAU,KAAK,SAAS,OAAO;AAG3C,YAAQ,SAAS,QAAQ,aAAW,IAAI,OAAO,OAAO,CAAC;AAGvD,WAAO,QAAQ,aAAa,KAAK,SAAS,EAAE,OAAO,SAAS,CAAC,IAAI;AAAA,EACnE;AACF;;;AD9CA,IAAO,0BAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,MAAI,0BAA0B;AAG9B,OAAK,KAAK,EAAE,iBAAiB,EAAE,QAAQ,gBAAc;AACnD,UAAM,OAAO,WAAW;AAGxB,QAAI,KAAK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SAAS,iBAAiB,MAAW,mBAAyC;AAC5E,MAAI,KAAK,SAAS,iBAAkB,QAAO;AAE3C,QAAM,SAAS,KAAK;AACpB,MAAI,CAAC,UAAU,OAAO,SAAS,mBAAoB,QAAO;AAE1D,QAAM,SAAS,OAAO;AACtB,MAAI,CAAC,UAAU,OAAO,SAAS,aAAc,QAAO;AAEpD,MAAI,CAAC,kBAAkB,IAAI,OAAO,IAAI,EAAG,QAAO;AAEhD,QAAM,WAAW,OAAO;AACxB,MAAI,CAAC,YAAY,SAAS,SAAS,gBAAgB,SAAS,SAAS,MAAO,QAAO;AAEnF,SAAO;AACT;AAKA,SAAS,uBAAuB,MAAW,SAAuB;AAChE,QAAM,WAAW,KAAK,YAAY,CAAC;AACnC,MAAI,CAAC,SAAU,QAAO;AAEtB,QAAM,0BACH,SAAS,SAAS,mBAAmB,SAAS,UAAU,oBACxD,SAAS,SAAS,aAAa,SAAS,UAAU;AAErD,MAAI,CAAC,wBAAyB,QAAO;AAGrC,WAAS,QAAQ;AAGjB,MAAI,SAAS,OAAO,KAAK;AACvB,UAAM,QAAQ,SAAS,MAAM,IAAI,OAAO,CAAC;AACzC,aAAS,MAAM,MAAM,GAAG,KAAK,iBAAiB,KAAK;AAAA,EACrD;AAEA,UAAQ,aAAa;AACrB,SAAO;AACT;AAKA,SAAS,iBAAiB,KAAa,MAAoB;AAEzD,MAAI,CAAC,KAAK,eAAe,GAAG,EAAG,QAAO;AAGtC,MAAI,QAAQ,SAAS,QAAQ,WAAY,QAAO;AAEhD,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/codemods/v1/runtime-context.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * The `RuntimeContext` class has been renamed to `RequestContext`, and all parameter names have been updated from `runtimeContext` to `requestContext` across all APIs.\n */\n\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n // Track whether RuntimeContext was imported from @mastra/core/runtime-context\n let hasRuntimeContextImport = false;\n\n // 1. Update import declarations from runtime-context to request-context\n root.find(j.ImportDeclaration).forEach(importPath => {\n const node = importPath.node;\n\n // Early return: Only process imports from @mastra/core/runtime-context\n if (node.source.value !== '@mastra/core/runtime-context') return;\n\n // Update the import path\n node.source.value = '@mastra/core/request-context';\n context.hasChanges = true;\n\n // Update RuntimeContext to RequestContext in import specifiers\n node.specifiers?.forEach(specifier => {\n if (specifier.type !== 'ImportSpecifier') return;\n\n const imported = specifier.imported;\n if (imported.type === 'Identifier' && imported.name === 'RuntimeContext') {\n hasRuntimeContextImport = true;\n imported.name = 'RequestContext';\n context.messages.push(`Updated import: RuntimeContext → RequestContext from '@mastra/core/request-context'`);\n }\n });\n });\n\n // Early return: Only proceed if RuntimeContext was imported from Mastra\n if (!hasRuntimeContextImport) return;\n\n // 2. Rename RuntimeContext type/class references\n renameIdentifiers(j, root, context, 'RuntimeContext', 'RequestContext', 'type');\n\n // 3. Rename runtimeContext variable/parameter identifiers\n renameIdentifiers(j, root, context, 'runtimeContext', 'requestContext', 'variable/parameter');\n\n // 4. Rename string literal 'runtimeContext' to 'requestContext' in Mastra middleware\n renameMiddlewareStringLiterals(j, root, context);\n});\n\n/**\n * Helper to rename all occurrences of an identifier\n */\nfunction renameIdentifiers(j: any, root: any, context: any, oldName: string, newName: string, description: string) {\n const identifiers = root.find(j.Identifier, { name: oldName });\n const count = identifiers.length;\n\n if (count === 0) return;\n\n identifiers.forEach((path: any) => {\n path.node.name = newName;\n });\n\n context.hasChanges = true;\n context.messages.push(`Renamed ${count} ${oldName} ${description} references to ${newName}`);\n}\n\n/**\n * Helper to rename 'runtimeContext' string literals in Mastra middleware handlers\n */\nfunction renameMiddlewareStringLiterals(j: any, root: any, context: any) {\n let stringLiteralCount = 0;\n\n // Find all new Mastra({ ... }) expressions\n root\n .find(j.NewExpression, {\n callee: { type: 'Identifier', name: 'Mastra' },\n })\n .forEach((mastraPath: any) => {\n const configArg = mastraPath.node.arguments[0];\n if (!configArg || configArg.type !== 'ObjectExpression') return;\n\n // Process this Mastra config to find and rename context.get() calls\n const contextParamNames = new Set<string>();\n stringLiteralCount += processNode(configArg, contextParamNames, context);\n });\n\n if (stringLiteralCount > 0) {\n context.messages.push(\n `Renamed ${stringLiteralCount} string literal 'runtimeContext' to 'requestContext' in Mastra server.middleware`,\n );\n }\n}\n\n/**\n * Recursively search for handler properties and rename context.get() calls\n */\nfunction processNode(node: any, contextParamNames: Set<string>, context: any): number {\n if (!node || typeof node !== 'object') return 0;\n\n let count = 0;\n\n // Check if this is a handler property\n if (isHandlerProperty(node)) {\n const paramName = extractFirstParamName(node.value);\n if (paramName) {\n contextParamNames.add(paramName);\n }\n }\n\n // Check if this is a context.get('runtimeContext') call\n if (isContextGetCall(node, contextParamNames)) {\n if (renameStringLiteralArg(node, context)) {\n count++;\n }\n }\n\n // Recursively process all object properties\n for (const key in node) {\n if (!shouldProcessKey(key, node)) continue;\n\n const value = node[key];\n if (Array.isArray(value)) {\n value.forEach(item => {\n count += processNode(item, contextParamNames, context);\n });\n } else if (value && typeof value === 'object') {\n count += processNode(value, contextParamNames, context);\n }\n }\n\n return count;\n}\n\n/**\n * Check if a node is a handler property (Property or ObjectProperty with key 'handler')\n */\nfunction isHandlerProperty(node: any): boolean {\n return (node.type === 'Property' || node.type === 'ObjectProperty') && node.key?.name === 'handler';\n}\n\n/**\n * Extract the first parameter name from a function expression\n */\nfunction extractFirstParamName(handlerValue: any): string | null {\n if (\n !handlerValue ||\n (handlerValue.type !== 'ArrowFunctionExpression' && handlerValue.type !== 'FunctionExpression')\n ) {\n return null;\n }\n\n if (!handlerValue.params || handlerValue.params.length === 0) {\n return null;\n }\n\n const firstParam = handlerValue.params[0];\n if (firstParam?.type === 'Identifier') {\n return firstParam.name;\n }\n\n return null;\n}\n\n/**\n * Check if a node is a context.get() call expression\n */\nfunction isContextGetCall(node: any, contextParamNames: Set<string>): boolean {\n if (node.type !== 'CallExpression') return false;\n\n const callee = node.callee;\n if (!callee || callee.type !== 'MemberExpression') return false;\n\n const object = callee.object;\n if (!object || object.type !== 'Identifier') return false;\n\n if (!contextParamNames.has(object.name)) return false;\n\n const property = callee.property;\n if (!property || property.type !== 'Identifier' || property.name !== 'get') return false;\n\n return true;\n}\n\n/**\n * Rename the first string argument from 'runtimeContext' to 'requestContext'\n */\nfunction renameStringLiteralArg(node: any, context: any): boolean {\n const firstArg = node.arguments?.[0];\n if (!firstArg) return false;\n\n const isRuntimeContextLiteral =\n (firstArg.type === 'StringLiteral' && firstArg.value === 'runtimeContext') ||\n (firstArg.type === 'Literal' && firstArg.value === 'runtimeContext');\n\n if (!isRuntimeContextLiteral) return false;\n\n // Rename the value\n firstArg.value = 'requestContext';\n\n // Update the raw value if it exists\n if (firstArg.extra?.raw) {\n const quote = firstArg.extra.raw.charAt(0);\n firstArg.extra.raw = `${quote}requestContext${quote}`;\n }\n\n context.hasChanges = true;\n return true;\n}\n\n/**\n * Check if we should process this object key during recursion\n */\nfunction shouldProcessKey(key: string, node: any): boolean {\n // Skip non-own properties\n if (!node.hasOwnProperty(key)) return false;\n\n // Skip metadata properties that don't contain code\n if (key === 'loc' || key === 'comments') return false;\n\n return true;\n}\n"],"mappings":";;;;;AAMA,IAAO,0BAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,MAAI,0BAA0B;AAG9B,OAAK,KAAK,EAAE,iBAAiB,EAAE,QAAQ,gBAAc;AACnD,UAAM,OAAO,WAAW;AAGxB,QAAI,KAAK,OAAO,UAAU,+BAAgC;AAG1D,SAAK,OAAO,QAAQ;AACpB,YAAQ,aAAa;AAGrB,SAAK,YAAY,QAAQ,eAAa;AACpC,UAAI,UAAU,SAAS,kBAAmB;AAE1C,YAAM,WAAW,UAAU;AAC3B,UAAI,SAAS,SAAS,gBAAgB,SAAS,SAAS,kBAAkB;AACxE,kCAA0B;AAC1B,iBAAS,OAAO;AAChB,gBAAQ,SAAS,KAAK,0FAAqF;AAAA,MA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AAW,OAAO;AACxB,MAAI,CAAC,YAAY,SAAS,SAAS,gBAAgB,SAAS,SAAS,MAAO,QAAO;AAEnF,SAAO;AACT;AAKA,SAAS,uBAAuB,MAAW,SAAuB;AAChE,QAAM,WAAW,KAAK,YAAY,CAAC;AACnC,MAAI,CAAC,SAAU,QAAO;AAEtB,QAAM,0BACH,SAAS,SAAS,mBAAmB,SAAS,UAAU,oBACxD,SAAS,SAAS,aAAa,SAAS,UAAU;AAErD,MAAI,CAAC,wBAAyB,QAAO;AAGrC,WAAS,QAAQ;AAGjB,MAAI,SAAS,OAAO,KAAK;AACvB,UAAM,QAAQ,SAAS,MAAM,IAAI,OAAO,CAAC;AACzC,aAAS,MAAM,MAAM,GAAG,KAAK,iBAAiB,KAAK;AAAA,EACrD;AAEA,UAAQ,aAAa;AACrB,SAAO;AACT;AAKA,SAAS,iBAAiB,KAAa,MAAoB;AAEzD,MAAI,CAAC,KAAK,eAAe,GAAG,EAAG,QAAO;AAGtC,MAAI,QAAQ,SAAS,QAAQ,WAAY,QAAO;AAEhD,SAAO;AACT;","names":[]}
@@ -0,0 +1,41 @@
1
+ import {
2
+ createTransformer
3
+ } from "../chunk-JNFQ6J6B.js";
4
+ import {
5
+ trackMultipleClassInstances
6
+ } from "../chunk-PKCFDS7J.js";
7
+
8
+ // src/codemods/v1/storage-get-messages-paginated.ts
9
+ var storage_get_messages_paginated_default = createTransformer((_fileInfo, _api, _options, context) => {
10
+ const { j, root } = context;
11
+ const storeTypes = ["PostgresStore", "LibSQLStore", "PgStore", "DynamoDBStore", "MongoDBStore", "MSSQLStore"];
12
+ const storageInstances = trackMultipleClassInstances(j, root, storeTypes);
13
+ if (storageInstances.size === 0) return;
14
+ root.find(j.CallExpression).forEach((path) => {
15
+ const { callee } = path.value;
16
+ if (callee.type !== "MemberExpression") return;
17
+ if (callee.object.type !== "Identifier") return;
18
+ if (callee.property.type !== "Identifier") return;
19
+ if (!storageInstances.has(callee.object.name)) return;
20
+ if (callee.property.name !== "getMessagesPaginated") return;
21
+ callee.property.name = "listMessages";
22
+ const args = path.value.arguments;
23
+ const firstArg = args[0];
24
+ if (firstArg && firstArg.type === "ObjectExpression" && firstArg.properties) {
25
+ firstArg.properties.forEach((prop) => {
26
+ if ((prop.type === "Property" || prop.type === "ObjectProperty") && prop.key && prop.key.type === "Identifier") {
27
+ if (prop.key.name === "offset") prop.key.name = "page";
28
+ if (prop.key.name === "limit") prop.key.name = "perPage";
29
+ }
30
+ });
31
+ }
32
+ context.hasChanges = true;
33
+ });
34
+ if (context.hasChanges) {
35
+ context.messages.push("Renamed getMessagesPaginated to listMessages and offset/limit to page/perPage");
36
+ }
37
+ });
38
+ export {
39
+ storage_get_messages_paginated_default as default
40
+ };
41
+ //# sourceMappingURL=storage-get-messages-paginated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/storage-get-messages-paginated.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\nimport { trackMultipleClassInstances } from '../lib/utils';\n\n/**\n * Renames storage.getMessagesPaginated() to storage.listMessages() and updates pagination parameters.\n * Changes offset/limit to page/perPage for more intuitive pagination.\n *\n * Before:\n * await storage.getMessagesPaginated({\n * threadId: 'thread-123',\n * offset: 0,\n * limit: 20,\n * });\n *\n * After:\n * await storage.listMessages({\n * threadId: 'thread-123',\n * page: 0,\n * perPage: 20,\n * });\n */\nexport default createTransformer((_fileInfo, _api, _options, context) => {\n const { j, root } = context;\n\n const storeTypes = ['PostgresStore', 'LibSQLStore', 'PgStore', 'DynamoDBStore', 'MongoDBStore', 'MSSQLStore'];\n\n // Track all store instances in a single optimized pass\n const storageInstances = trackMultipleClassInstances(j, root, storeTypes);\n\n if (storageInstances.size === 0) return;\n\n // Single pass: rename method 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 if (callee.property.type !== 'Identifier') return;\n if (!storageInstances.has(callee.object.name)) return;\n if (callee.property.name !== 'getMessagesPaginated') return;\n\n // Rename method\n callee.property.name = 'listMessages';\n\n // Transform offset/limit to page/perPage\n const args = path.value.arguments;\n const firstArg = args[0];\n if (firstArg && firstArg.type === 'ObjectExpression' && firstArg.properties) {\n firstArg.properties.forEach((prop: any) => {\n if (\n (prop.type === 'Property' || prop.type === 'ObjectProperty') &&\n prop.key &&\n prop.key.type === 'Identifier'\n ) {\n if (prop.key.name === 'offset') prop.key.name = 'page';\n if (prop.key.name === 'limit') prop.key.name = 'perPage';\n }\n });\n }\n\n context.hasChanges = true;\n });\n\n if (context.hasChanges) {\n context.messages.push('Renamed getMessagesPaginated to listMessages and offset/limit to page/perPage');\n }\n});\n"],"mappings":";;;;;;;;AAqBA,IAAO,yCAAQ,kBAAkB,CAAC,WAAW,MAAM,UAAU,YAAY;AACvE,QAAM,EAAE,GAAG,KAAK,IAAI;AAEpB,QAAM,aAAa,CAAC,iBAAiB,eAAe,WAAW,iBAAiB,gBAAgB,YAAY;AAG5G,QAAM,mBAAmB,4BAA4B,GAAG,MAAM,UAAU;AAExE,MAAI,iBAAiB,SAAS,EAAG;AAGjC,OAAK,KAAK,EAAE,cAAc,EAAE,QAAQ,UAAQ;AAC1C,UAAM,EAAE,OAAO,IAAI,KAAK;AACxB,QAAI,OAAO,SAAS,mBAAoB;AACxC,QAAI,OAAO,OAAO,SAAS,aAAc;AACzC,QAAI,OAAO,SAAS,SAAS,aAAc;AAC3C,QAAI,CAAC,iBAAiB,IAAI,OAAO,OAAO,IAAI,EAAG;AAC/C,QAAI,OAAO,SAAS,SAAS,uBAAwB;AAGrD,WAAO,SAAS,OAAO;AAGvB,UAAM,OAAO,KAAK,MAAM;AACxB,UAAM,WAAW,KAAK,CAAC;AACvB,QAAI,YAAY,SAAS,SAAS,sBAAsB,SAAS,YAAY;AAC3E,eAAS,WAAW,QAAQ,CAAC,SAAc;AACzC,aACG,KAAK,SAAS,cAAc,KAAK,SAAS,qBAC3C,KAAK,OACL,KAAK,IAAI,SAAS,cAClB;AACA,cAAI,KAAK,IAAI,SAAS,SAAU,MAAK,IAAI,OAAO;AAChD,cAAI,KAAK,IAAI,SAAS,QAAS,MAAK,IAAI,OAAO;AAAA,QACjD;AAAA,MACF,CAAC;AAAA,IACH;AAEA,YAAQ,aAAa;AAAA,EACvB,CAAC;AAED,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS,KAAK,+EAA+E;AAAA,EACvG;AACF,CAAC;","names":[]}
@@ -0,0 +1,23 @@
1
+ import {
2
+ createTransformer
3
+ } from "../chunk-JNFQ6J6B.js";
4
+ import {
5
+ renameMethod,
6
+ trackMultipleClassInstances
7
+ } from "../chunk-PKCFDS7J.js";
8
+
9
+ // src/codemods/v1/storage-get-threads-by-resource.ts
10
+ var storage_get_threads_by_resource_default = createTransformer((_fileInfo, _api, _options, context) => {
11
+ const { j, root } = context;
12
+ const storeTypes = ["PostgresStore", "LibSQLStore", "PgStore", "DynamoDBStore", "MongoDBStore", "MSSQLStore"];
13
+ const storageInstances = trackMultipleClassInstances(j, root, storeTypes);
14
+ const count = renameMethod(j, root, storageInstances, "getThreadsByResourceId", "listThreadsByResourceId");
15
+ if (count > 0) {
16
+ context.hasChanges = true;
17
+ context.messages.push("Renamed getThreadsByResourceId to listThreadsByResourceId on storage instances");
18
+ }
19
+ });
20
+ export {
21
+ storage_get_threads_by_resource_default as default
22
+ };
23
+ //# sourceMappingURL=storage-get-threads-by-resource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/storage-get-threads-by-resource.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\nimport { trackMultipleClassInstances, renameMethod } from '../lib/utils';\n\n/**\n * Renames storage.getThreadsByResourceId() to storage.listThreadsByResourceId().\n * This aligns with the convention that list* methods return collections.\n *\n * Before:\n * const threads = await storage.getThreadsByResourceId({ resourceId: 'res-123' });\n *\n * After:\n * const threads = await storage.listThreadsByResourceId({ resourceId: 'res-123' });\n */\nexport default createTransformer((_fileInfo, _api, _options, context) => {\n const { j, root } = context;\n\n const storeTypes = ['PostgresStore', 'LibSQLStore', 'PgStore', 'DynamoDBStore', 'MongoDBStore', 'MSSQLStore'];\n\n // Track all store instances in a single optimized pass\n const storageInstances = trackMultipleClassInstances(j, root, storeTypes);\n const count = renameMethod(j, root, storageInstances, 'getThreadsByResourceId', 'listThreadsByResourceId');\n\n if (count > 0) {\n context.hasChanges = true;\n context.messages.push('Renamed getThreadsByResourceId to listThreadsByResourceId on storage instances');\n }\n});\n"],"mappings":";;;;;;;;;AAaA,IAAO,0CAAQ,kBAAkB,CAAC,WAAW,MAAM,UAAU,YAAY;AACvE,QAAM,EAAE,GAAG,KAAK,IAAI;AAEpB,QAAM,aAAa,CAAC,iBAAiB,eAAe,WAAW,iBAAiB,gBAAgB,YAAY;AAG5G,QAAM,mBAAmB,4BAA4B,GAAG,MAAM,UAAU;AACxE,QAAM,QAAQ,aAAa,GAAG,MAAM,kBAAkB,0BAA0B,yBAAyB;AAEzG,MAAI,QAAQ,GAAG;AACb,YAAQ,aAAa;AACrB,YAAQ,SAAS,KAAK,gFAAgF;AAAA,EACxG;AACF,CAAC;","names":[]}
@@ -0,0 +1,23 @@
1
+ import {
2
+ createTransformer
3
+ } from "../chunk-JNFQ6J6B.js";
4
+ import {
5
+ renameMethod,
6
+ trackMultipleClassInstances
7
+ } from "../chunk-PKCFDS7J.js";
8
+
9
+ // src/codemods/v1/storage-list-messages-by-id.ts
10
+ var storage_list_messages_by_id_default = createTransformer((_fileInfo, _api, _options, context) => {
11
+ const { j, root } = context;
12
+ const storeTypes = ["PostgresStore", "LibSQLStore", "PgStore", "DynamoDBStore", "MongoDBStore", "MSSQLStore"];
13
+ const storageInstances = trackMultipleClassInstances(j, root, storeTypes);
14
+ const count = renameMethod(j, root, storageInstances, "getMessagesById", "listMessagesById");
15
+ if (count > 0) {
16
+ context.hasChanges = true;
17
+ context.messages.push("Renamed getMessagesById to listMessagesById on storage instances");
18
+ }
19
+ });
20
+ export {
21
+ storage_list_messages_by_id_default as default
22
+ };
23
+ //# sourceMappingURL=storage-list-messages-by-id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/storage-list-messages-by-id.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\nimport { trackMultipleClassInstances, renameMethod } from '../lib/utils';\n\n/**\n * Renames storage.getMessagesById() to storage.listMessagesById().\n * This aligns with the convention that list* methods return collections.\n *\n * Before:\n * const result = await storage.getMessagesById({\n * messageIds: ['msg-1', 'msg-2'],\n * });\n *\n * After:\n * const result = await storage.listMessagesById({\n * messageIds: ['msg-1', 'msg-2'],\n * });\n */\nexport default createTransformer((_fileInfo, _api, _options, context) => {\n const { j, root } = context;\n\n const storeTypes = ['PostgresStore', 'LibSQLStore', 'PgStore', 'DynamoDBStore', 'MongoDBStore', 'MSSQLStore'];\n\n // Track all store instances in a single optimized pass\n const storageInstances = trackMultipleClassInstances(j, root, storeTypes);\n const count = renameMethod(j, root, storageInstances, 'getMessagesById', 'listMessagesById');\n\n if (count > 0) {\n context.hasChanges = true;\n context.messages.push('Renamed getMessagesById to listMessagesById on storage instances');\n }\n});\n"],"mappings":";;;;;;;;;AAiBA,IAAO,sCAAQ,kBAAkB,CAAC,WAAW,MAAM,UAAU,YAAY;AACvE,QAAM,EAAE,GAAG,KAAK,IAAI;AAEpB,QAAM,aAAa,CAAC,iBAAiB,eAAe,WAAW,iBAAiB,gBAAgB,YAAY;AAG5G,QAAM,mBAAmB,4BAA4B,GAAG,MAAM,UAAU;AACxE,QAAM,QAAQ,aAAa,GAAG,MAAM,kBAAkB,mBAAmB,kBAAkB;AAE3F,MAAI,QAAQ,GAAG;AACb,YAAQ,aAAa;AACrB,YAAQ,SAAS,KAAK,kEAAkE;AAAA,EAC1F;AACF,CAAC;","names":[]}
@@ -0,0 +1,23 @@
1
+ import {
2
+ createTransformer
3
+ } from "../chunk-JNFQ6J6B.js";
4
+ import {
5
+ renameMethod,
6
+ trackMultipleClassInstances
7
+ } from "../chunk-PKCFDS7J.js";
8
+
9
+ // src/codemods/v1/storage-list-workflow-runs.ts
10
+ var storage_list_workflow_runs_default = createTransformer((_fileInfo, _api, _options, context) => {
11
+ const { j, root } = context;
12
+ const storeTypes = ["PostgresStore", "LibSQLStore", "PgStore", "DynamoDBStore", "MongoDBStore", "MSSQLStore"];
13
+ const storageInstances = trackMultipleClassInstances(j, root, storeTypes);
14
+ const count = renameMethod(j, root, storageInstances, "getWorkflowRuns", "listWorkflowRuns");
15
+ if (count > 0) {
16
+ context.hasChanges = true;
17
+ context.messages.push("Renamed getWorkflowRuns to listWorkflowRuns on storage instances");
18
+ }
19
+ });
20
+ export {
21
+ storage_list_workflow_runs_default as default
22
+ };
23
+ //# sourceMappingURL=storage-list-workflow-runs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/storage-list-workflow-runs.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\nimport { trackMultipleClassInstances, renameMethod } from '../lib/utils';\n\n/**\n * Renames storage.getWorkflowRuns() to storage.listWorkflowRuns().\n * This aligns with the convention that list* methods return collections.\n *\n * Before:\n * const runs = await storage.getWorkflowRuns({ fromDate, toDate });\n *\n * After:\n * const runs = await storage.listWorkflowRuns({ fromDate, toDate });\n */\nexport default createTransformer((_fileInfo, _api, _options, context) => {\n const { j, root } = context;\n\n const storeTypes = ['PostgresStore', 'LibSQLStore', 'PgStore', 'DynamoDBStore', 'MongoDBStore', 'MSSQLStore'];\n\n // Track all store instances in a single optimized pass\n const storageInstances = trackMultipleClassInstances(j, root, storeTypes);\n const count = renameMethod(j, root, storageInstances, 'getWorkflowRuns', 'listWorkflowRuns');\n\n if (count > 0) {\n context.hasChanges = true;\n context.messages.push('Renamed getWorkflowRuns to listWorkflowRuns on storage instances');\n }\n});\n"],"mappings":";;;;;;;;;AAaA,IAAO,qCAAQ,kBAAkB,CAAC,WAAW,MAAM,UAAU,YAAY;AACvE,QAAM,EAAE,GAAG,KAAK,IAAI;AAEpB,QAAM,aAAa,CAAC,iBAAiB,eAAe,WAAW,iBAAiB,gBAAgB,YAAY;AAG5G,QAAM,mBAAmB,4BAA4B,GAAG,MAAM,UAAU;AACxE,QAAM,QAAQ,aAAa,GAAG,MAAM,kBAAkB,mBAAmB,kBAAkB;AAE3F,MAAI,QAAQ,GAAG;AACb,YAAQ,aAAa;AACrB,YAAQ,SAAS,KAAK,kEAAkE;AAAA,EAC1F;AACF,CAAC;","names":[]}
@@ -0,0 +1,20 @@
1
+ import {
2
+ createTransformer
3
+ } from "../chunk-JNFQ6J6B.js";
4
+ import {
5
+ transformConstructorProperties
6
+ } from "../chunk-PKCFDS7J.js";
7
+
8
+ // src/codemods/v1/storage-postgres-schema-name.ts
9
+ var storage_postgres_schema_name_default = createTransformer((_fileInfo, _api, _options, context) => {
10
+ const { j, root } = context;
11
+ const count = transformConstructorProperties(j, root, "PostgresStore", { schema: "schemaName" });
12
+ if (count > 0) {
13
+ context.hasChanges = true;
14
+ context.messages.push("Renamed schema to schemaName in PostgresStore constructor");
15
+ }
16
+ });
17
+ export {
18
+ storage_postgres_schema_name_default as default
19
+ };
20
+ //# sourceMappingURL=storage-postgres-schema-name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/storage-postgres-schema-name.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\nimport { transformConstructorProperties } from '../lib/utils';\n\n/**\n * Renames schema parameter to schemaName in PostgresStore constructor.\n * This provides clearer naming to avoid confusion with database schema concepts.\n *\n * Before:\n * const pgStore = new PostgresStore({\n * connectionString: process.env.POSTGRES_CONNECTION_STRING,\n * schema: customSchema,\n * });\n *\n * After:\n * const pgStore = new PostgresStore({\n * connectionString: process.env.POSTGRES_CONNECTION_STRING,\n * schemaName: customSchema,\n * });\n */\nexport default createTransformer((_fileInfo, _api, _options, context) => {\n const { j, root } = context;\n\n const count = transformConstructorProperties(j, root, 'PostgresStore', { schema: 'schemaName' });\n\n if (count > 0) {\n context.hasChanges = true;\n context.messages.push('Renamed schema to schemaName in PostgresStore constructor');\n }\n});\n"],"mappings":";;;;;;;;AAmBA,IAAO,uCAAQ,kBAAkB,CAAC,WAAW,MAAM,UAAU,YAAY;AACvE,QAAM,EAAE,GAAG,KAAK,IAAI;AAEpB,QAAM,QAAQ,+BAA+B,GAAG,MAAM,iBAAiB,EAAE,QAAQ,aAAa,CAAC;AAE/F,MAAI,QAAQ,GAAG;AACb,YAAQ,aAAa;AACrB,YAAQ,SAAS,KAAK,2DAA2D;AAAA,EACnF;AACF,CAAC;","names":[]}
@@ -0,0 +1,27 @@
1
+ import {
2
+ createTransformer
3
+ } from "../chunk-JNFQ6J6B.js";
4
+
5
+ // src/codemods/v1/vector-pg-constructor.ts
6
+ var vector_pg_constructor_default = createTransformer((fileInfo, api, options, context) => {
7
+ const { j, root } = context;
8
+ root.find(j.NewExpression, {
9
+ callee: { type: "Identifier", name: "PgVector" }
10
+ }).forEach((path) => {
11
+ const args = path.value.arguments;
12
+ const firstArg = args[0];
13
+ if (args.length === 1 && firstArg && firstArg.type !== "ObjectExpression") {
14
+ path.value.arguments = [
15
+ j.objectExpression([j.objectProperty(j.identifier("connectionString"), firstArg)])
16
+ ];
17
+ context.hasChanges = true;
18
+ }
19
+ });
20
+ if (context.hasChanges) {
21
+ context.messages.push("Converted PgVector constructor from positional to object parameter");
22
+ }
23
+ });
24
+ export {
25
+ vector_pg_constructor_default as default
26
+ };
27
+ //# sourceMappingURL=vector-pg-constructor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/vector-pg-constructor.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * Converts PgVector constructor from positional string argument to object parameter.\n * This provides a more consistent API across all storage adapters.\n *\n * Before:\n * const pgVector = new PgVector(process.env.POSTGRES_CONNECTION_STRING!);\n *\n * After:\n * const pgVector = new PgVector({\n * connectionString: process.env.POSTGRES_CONNECTION_STRING\n * });\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n root\n .find(j.NewExpression, {\n callee: { type: 'Identifier', name: 'PgVector' },\n })\n .forEach(path => {\n const args = path.value.arguments;\n const firstArg = args[0];\n\n if (args.length === 1 && firstArg && firstArg.type !== 'ObjectExpression') {\n path.value.arguments = [\n j.objectExpression([j.objectProperty(j.identifier('connectionString'), firstArg as any)]),\n ];\n\n context.hasChanges = true;\n }\n });\n\n if (context.hasChanges) {\n context.messages.push('Converted PgVector constructor from positional to object parameter');\n }\n});\n"],"mappings":";;;;;AAcA,IAAO,gCAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAEpB,OACG,KAAK,EAAE,eAAe;AAAA,IACrB,QAAQ,EAAE,MAAM,cAAc,MAAM,WAAW;AAAA,EACjD,CAAC,EACA,QAAQ,UAAQ;AACf,UAAM,OAAO,KAAK,MAAM;AACxB,UAAM,WAAW,KAAK,CAAC;AAEvB,QAAI,KAAK,WAAW,KAAK,YAAY,SAAS,SAAS,oBAAoB;AACzE,WAAK,MAAM,YAAY;AAAA,QACrB,EAAE,iBAAiB,CAAC,EAAE,eAAe,EAAE,WAAW,kBAAkB,GAAG,QAAe,CAAC,CAAC;AAAA,MAC1F;AAEA,cAAQ,aAAa;AAAA,IACvB;AAAA,EACF,CAAC;AAEH,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS,KAAK,oEAAoE;AAAA,EAC5F;AACF,CAAC;","names":[]}
@@ -0,0 +1,42 @@
1
+ import {
2
+ createTransformer
3
+ } from "../chunk-JNFQ6J6B.js";
4
+
5
+ // src/codemods/v1/voice-property-names.ts
6
+ var voice_property_names_default = createTransformer((_fileInfo, _api, _options, context) => {
7
+ const { j, root } = context;
8
+ const propertyRenames = {
9
+ speakProvider: "output",
10
+ listenProvider: "input",
11
+ realtimeProvider: "realtime"
12
+ };
13
+ root.find(j.NewExpression, {
14
+ callee: { type: "Identifier", name: "Agent" }
15
+ }).forEach((agentPath) => {
16
+ const configArg = agentPath.node.arguments[0];
17
+ if (!configArg || configArg.type !== "ObjectExpression" || !configArg.properties) return;
18
+ configArg.properties.forEach((prop) => {
19
+ if ((prop.type === "Property" || prop.type === "ObjectProperty") && prop.key?.type === "Identifier" && prop.key.name === "voice" && prop.value?.type === "ObjectExpression" && prop.value.properties) {
20
+ prop.value.properties.forEach((voiceProp) => {
21
+ if ((voiceProp.type === "Property" || voiceProp.type === "ObjectProperty") && voiceProp.key?.type === "Identifier") {
22
+ const oldName = voiceProp.key.name;
23
+ const newName = propertyRenames[oldName];
24
+ if (newName) {
25
+ voiceProp.key.name = newName;
26
+ context.hasChanges = true;
27
+ }
28
+ }
29
+ });
30
+ }
31
+ });
32
+ });
33
+ if (context.hasChanges) {
34
+ context.messages.push(
35
+ `Transformed voice property names: speakProvider/listenProvider/realtimeProvider \u2192 output/input/realtime`
36
+ );
37
+ }
38
+ });
39
+ export {
40
+ voice_property_names_default as default
41
+ };
42
+ //# sourceMappingURL=voice-property-names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/voice-property-names.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * Transforms voice property names in Agent configuration:\n * - speakProvider → output\n * - listenProvider → input\n * - realtimeProvider → realtime\n *\n * Only transforms properties within new Agent({ voice: { ... } })\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 speakProvider: 'output',\n listenProvider: 'input',\n realtimeProvider: 'realtime',\n };\n\n // Find all new Agent({ ... }) expressions and transform in one pass\n root\n .find(j.NewExpression, {\n callee: { type: 'Identifier', name: 'Agent' },\n })\n .forEach(agentPath => {\n const configArg = agentPath.node.arguments[0];\n if (!configArg || configArg.type !== 'ObjectExpression' || !configArg.properties) return;\n\n // Find the voice property in the Agent config object\n configArg.properties.forEach((prop: any) => {\n if (\n (prop.type === 'Property' || prop.type === 'ObjectProperty') &&\n prop.key?.type === 'Identifier' &&\n prop.key.name === 'voice' &&\n prop.value?.type === 'ObjectExpression' &&\n prop.value.properties\n ) {\n // Now rename properties within the voice object\n prop.value.properties.forEach((voiceProp: any) => {\n if (\n (voiceProp.type === 'Property' || voiceProp.type === 'ObjectProperty') &&\n voiceProp.key?.type === 'Identifier'\n ) {\n const oldName = voiceProp.key.name;\n const newName = propertyRenames[oldName];\n\n if (newName) {\n voiceProp.key.name = newName;\n context.hasChanges = true;\n }\n }\n });\n }\n });\n });\n\n if (context.hasChanges) {\n context.messages.push(\n `Transformed voice property names: speakProvider/listenProvider/realtimeProvider → output/input/realtime`,\n );\n }\n});\n"],"mappings":";;;;;AAUA,IAAO,+BAAQ,kBAAkB,CAAC,WAAW,MAAM,UAAU,YAAY;AACvE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,kBAA0C;AAAA,IAC9C,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,kBAAkB;AAAA,EACpB;AAGA,OACG,KAAK,EAAE,eAAe;AAAA,IACrB,QAAQ,EAAE,MAAM,cAAc,MAAM,QAAQ;AAAA,EAC9C,CAAC,EACA,QAAQ,eAAa;AACpB,UAAM,YAAY,UAAU,KAAK,UAAU,CAAC;AAC5C,QAAI,CAAC,aAAa,UAAU,SAAS,sBAAsB,CAAC,UAAU,WAAY;AAGlF,cAAU,WAAW,QAAQ,CAAC,SAAc;AAC1C,WACG,KAAK,SAAS,cAAc,KAAK,SAAS,qBAC3C,KAAK,KAAK,SAAS,gBACnB,KAAK,IAAI,SAAS,WAClB,KAAK,OAAO,SAAS,sBACrB,KAAK,MAAM,YACX;AAEA,aAAK,MAAM,WAAW,QAAQ,CAAC,cAAmB;AAChD,eACG,UAAU,SAAS,cAAc,UAAU,SAAS,qBACrD,UAAU,KAAK,SAAS,cACxB;AACA,kBAAM,UAAU,UAAU,IAAI;AAC9B,kBAAM,UAAU,gBAAgB,OAAO;AAEvC,gBAAI,SAAS;AACX,wBAAU,IAAI,OAAO;AACrB,sBAAQ,aAAa;AAAA,YACvB;AAAA,UACF;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAEH,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS;AAAA,MACf;AAAA,IACF;AAAA,EACF;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/workflow-create-run-async.ts
10
+ var workflow_create_run_async_default = createTransformer((_fileInfo, _api, _options, context) => {
11
+ const { j, root } = context;
12
+ const workflowInstances = trackClassInstances(j, root, "Workflow");
13
+ const count = renameMethod(j, root, workflowInstances, "createRunAsync", "createRun");
14
+ if (count > 0) {
15
+ context.hasChanges = true;
16
+ context.messages.push("Renamed createRunAsync to createRun on Workflow instances");
17
+ }
18
+ });
19
+ export {
20
+ workflow_create_run_async_default as default
21
+ };
22
+ //# sourceMappingURL=workflow-create-run-async.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/workflow-create-run-async.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\nimport { trackClassInstances, renameMethod } from '../lib/utils';\n\n/**\n * Renames workflow.createRunAsync() to workflow.createRun().\n * This simplifies the API by removing the redundant \"Async\" suffix.\n *\n * Before:\n * await workflow.createRunAsync({ input: { ... } });\n *\n * After:\n * await workflow.createRun({ input: { ... } });\n */\nexport default createTransformer((_fileInfo, _api, _options, context) => {\n const { j, root } = context;\n\n // Track Workflow instances and rename method in a single optimized pass\n const workflowInstances = trackClassInstances(j, root, 'Workflow');\n const count = renameMethod(j, root, workflowInstances, 'createRunAsync', 'createRun');\n\n if (count > 0) {\n context.hasChanges = true;\n context.messages.push('Renamed createRunAsync to createRun on Workflow instances');\n }\n});\n"],"mappings":";;;;;;;;;AAaA,IAAO,oCAAQ,kBAAkB,CAAC,WAAW,MAAM,UAAU,YAAY;AACvE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,oBAAoB,oBAAoB,GAAG,MAAM,UAAU;AACjE,QAAM,QAAQ,aAAa,GAAG,MAAM,mBAAmB,kBAAkB,WAAW;AAEpF,MAAI,QAAQ,GAAG;AACb,YAAQ,aAAa;AACrB,YAAQ,SAAS,KAAK,2DAA2D;AAAA,EACnF;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/workflow-list-runs.ts
10
+ var workflow_list_runs_default = createTransformer((_fileInfo, _api, _options, context) => {
11
+ const { j, root } = context;
12
+ const workflowInstances = trackClassInstances(j, root, "Workflow");
13
+ const count = renameMethod(j, root, workflowInstances, "getWorkflowRuns", "listWorkflowRuns");
14
+ if (count > 0) {
15
+ context.hasChanges = true;
16
+ context.messages.push("Renamed getWorkflowRuns to listWorkflowRuns on Workflow instances");
17
+ }
18
+ });
19
+ export {
20
+ workflow_list_runs_default as default
21
+ };
22
+ //# sourceMappingURL=workflow-list-runs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/workflow-list-runs.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\nimport { trackClassInstances, renameMethod } from '../lib/utils';\n\n/**\n * Renames workflow.getWorkflowRuns() to workflow.listWorkflowRuns().\n * This aligns with the convention that list* methods return collections.\n *\n * Before:\n * const runs = await workflow.getWorkflowRuns({ fromDate, toDate });\n *\n * After:\n * const runs = await workflow.listWorkflowRuns({ fromDate, toDate });\n */\nexport default createTransformer((_fileInfo, _api, _options, context) => {\n const { j, root } = context;\n\n // Track Workflow instances and rename method in a single optimized pass\n const workflowInstances = trackClassInstances(j, root, 'Workflow');\n const count = renameMethod(j, root, workflowInstances, 'getWorkflowRuns', 'listWorkflowRuns');\n\n if (count > 0) {\n context.hasChanges = true;\n context.messages.push('Renamed getWorkflowRuns to listWorkflowRuns on Workflow instances');\n }\n});\n"],"mappings":";;;;;;;;;AAaA,IAAO,6BAAQ,kBAAkB,CAAC,WAAW,MAAM,UAAU,YAAY;AACvE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,oBAAoB,oBAAoB,GAAG,MAAM,UAAU;AACjE,QAAM,QAAQ,aAAa,GAAG,MAAM,mBAAmB,mBAAmB,kBAAkB;AAE5F,MAAI,QAAQ,GAAG;AACb,YAAQ,aAAa;AACrB,YAAQ,SAAS,KAAK,mEAAmE;AAAA,EAC3F;AACF,CAAC;","names":[]}
@@ -0,0 +1,53 @@
1
+ import {
2
+ createTransformer
3
+ } from "../chunk-JNFQ6J6B.js";
4
+
5
+ // src/codemods/v1/workflow-run-count.ts
6
+ var workflow_run_count_default = createTransformer((fileInfo, api, options, context) => {
7
+ const { j, root } = context;
8
+ const oldPropertyName = "runCount";
9
+ const newPropertyName = "retryCount";
10
+ const contextParamNames = /* @__PURE__ */ new Set();
11
+ root.find(j.CallExpression, {
12
+ callee: {
13
+ type: "Identifier",
14
+ name: "createStep"
15
+ }
16
+ }).forEach((path) => {
17
+ const args = path.value.arguments;
18
+ if (args.length === 0 || args[0]?.type !== "ObjectExpression") return;
19
+ const configObj = args[0];
20
+ if (!configObj.properties) return;
21
+ configObj.properties.forEach((prop) => {
22
+ if ((prop.type === "Property" || prop.type === "ObjectProperty") && prop.key && prop.key.type === "Identifier" && prop.key.name === "execute") {
23
+ const value = prop.value;
24
+ if (value && (value.type === "ArrowFunctionExpression" || value.type === "FunctionExpression")) {
25
+ const params = value.params;
26
+ const secondParam = params && params.length >= 2 ? params[1] : null;
27
+ if (secondParam && secondParam.type === "Identifier") {
28
+ contextParamNames.add(secondParam.name);
29
+ }
30
+ }
31
+ }
32
+ });
33
+ });
34
+ const renameMemberProperty = (node) => {
35
+ if (node.object.type === "Identifier" && contextParamNames.has(node.object.name) && node.property.type === "Identifier" && node.property.name === oldPropertyName) {
36
+ node.property.name = newPropertyName;
37
+ context.hasChanges = true;
38
+ }
39
+ };
40
+ root.find(j.MemberExpression).forEach((path) => {
41
+ renameMemberProperty(path.value);
42
+ });
43
+ root.find(j.OptionalMemberExpression).forEach((path) => {
44
+ renameMemberProperty(path.value);
45
+ });
46
+ if (context.hasChanges) {
47
+ context.messages.push("Renamed context.runCount to context.retryCount in step execution functions");
48
+ }
49
+ });
50
+ export {
51
+ workflow_run_count_default as default
52
+ };
53
+ //# sourceMappingURL=workflow-run-count.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/codemods/v1/workflow-run-count.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * Renames context.runCount to context.retryCount in step execution functions.\n * This provides clearer naming that better describes retry behavior.\n *\n * Before:\n * createStep({\n * execute: async (inputData, context) => {\n * console.log(`Step run ${context.runCount} times`);\n * },\n * });\n *\n * After:\n * createStep({\n * execute: async (inputData, context) => {\n * console.log(`Step retry count: ${context.retryCount}`);\n * },\n * });\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n const oldPropertyName = 'runCount';\n const newPropertyName = 'retryCount';\n\n // Track context parameter names in createStep execute functions\n const contextParamNames = new Set<string>();\n\n // Find createStep calls and extract context parameter names\n root\n .find(j.CallExpression, {\n callee: {\n type: 'Identifier',\n name: 'createStep',\n },\n })\n .forEach(path => {\n const args = path.value.arguments;\n if (args.length === 0 || args[0]?.type !== 'ObjectExpression') return;\n\n const configObj = args[0];\n if (!configObj.properties) return;\n\n // Find the execute property\n configObj.properties.forEach(prop => {\n if (\n (prop.type === 'Property' || prop.type === 'ObjectProperty') &&\n prop.key &&\n prop.key.type === 'Identifier' &&\n prop.key.name === 'execute'\n ) {\n const value = prop.value;\n if (value && (value.type === 'ArrowFunctionExpression' || value.type === 'FunctionExpression')) {\n // Extract the second parameter name (context)\n const params = value.params;\n const secondParam = params && params.length >= 2 ? params[1] : null;\n if (secondParam && secondParam.type === 'Identifier') {\n contextParamNames.add(secondParam.name);\n }\n }\n }\n });\n });\n\n // Rename context.runCount to context.retryCount\n const renameMemberProperty = (\n node: ReturnType<typeof j.memberExpression> | ReturnType<typeof j.optionalMemberExpression>,\n ) => {\n // Check if accessing .runCount on a context parameter\n if (\n node.object.type === 'Identifier' &&\n contextParamNames.has(node.object.name) &&\n node.property.type === 'Identifier' &&\n node.property.name === oldPropertyName\n ) {\n node.property.name = newPropertyName;\n context.hasChanges = true;\n }\n };\n\n // Handle regular member expressions (context.runCount)\n root.find(j.MemberExpression).forEach(path => {\n renameMemberProperty(path.value);\n });\n\n // Handle optional member expressions (context?.runCount)\n root.find(j.OptionalMemberExpression).forEach(path => {\n renameMemberProperty(path.value);\n });\n\n if (context.hasChanges) {\n context.messages.push('Renamed context.runCount to context.retryCount in step execution functions');\n }\n});\n"],"mappings":";;;;;AAoBA,IAAO,6BAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAEpB,QAAM,kBAAkB;AACxB,QAAM,kBAAkB;AAGxB,QAAM,oBAAoB,oBAAI,IAAY;AAG1C,OACG,KAAK,EAAE,gBAAgB;AAAA,IACtB,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,EACF,CAAC,EACA,QAAQ,UAAQ;AACf,UAAM,OAAO,KAAK,MAAM;AACxB,QAAI,KAAK,WAAW,KAAK,KAAK,CAAC,GAAG,SAAS,mBAAoB;AAE/D,UAAM,YAAY,KAAK,CAAC;AACxB,QAAI,CAAC,UAAU,WAAY;AAG3B,cAAU,WAAW,QAAQ,UAAQ;AACnC,WACG,KAAK,SAAS,cAAc,KAAK,SAAS,qBAC3C,KAAK,OACL,KAAK,IAAI,SAAS,gBAClB,K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