{"version":3,"file":"agent-voice.mjs","names":[],"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,IAAA,sBAAe,mBAAmB,UAAU,KAAK,SAAS,YAAY;CACpE,MAAM,EAAE,GAAG,SAAS;CAGpB,MAAM,+BAAe,IAAI,IAAI;EAAC;EAAS;EAAU;CAAa,CAAC;CAG/D,MAAM,iBAAiB,oBAAoB,GAAG,MAAM,OAAO;CAG3D,IAAI,eAAe,SAAS,GAAG;CAG/B,KAAK,KAAK,EAAE,cAAc,CAAC,CAAC,SAAQ,SAAQ;EAC1C,MAAM,OAAO,KAAK;EAGlB,IAAI,KAAK,OAAO,SAAS,oBACvB;EAGF,MAAM,SAAS,KAAK;EAGpB,IAAI,OAAO,OAAO,SAAS,gBAAgB,CAAC,eAAe,IAAI,OAAO,OAAO,IAAI,GAC/E;EAIF,IAAI,OAAO,SAAS,SAAS,gBAAgB,CAAC,aAAa,IAAI,OAAO,SAAS,IAAI,GACjF;EAMF,KAAK,SAFa,EAAE,iBAAiB,EAAE,iBAAiB,OAAO,QAAQ,EAAE,WAAW,OAAO,CAAC,GAAG,OAAO,QAEhF;EACtB,QAAQ,aAAa;CACvB,CAAC;CAED,IAAI,QAAQ,YACV,QAAQ,SAAS,KAAK,8DAA8D;AAExF,CAAC"}