|
14 | 14 | * limitations under the License. |
15 | 15 | */ |
16 | 16 |
|
17 | | -import { Connection, Messages, Org, SfError } from '@salesforce/core'; |
18 | | -import { Agent, type BotMetadata } from '@salesforce/agents'; |
| 17 | +import { Messages, Org, SfError, SfProject } from '@salesforce/core'; |
| 18 | +import { Agent, type BotMetadata, ProductionAgent } from '@salesforce/agents'; |
19 | 19 | import { select } from '@inquirer/prompts'; |
20 | 20 |
|
21 | 21 | type Choice<Value> = { |
@@ -67,16 +67,15 @@ export const getAgentChoices = (agents: BotMetadata[], status: 'Active' | 'Inact |
67 | 67 | }); |
68 | 68 |
|
69 | 69 | export const getAgentForActivation = async (config: { |
70 | | - conn: Connection; |
71 | 70 | targetOrg: Org; |
72 | 71 | status: 'Active' | 'Inactive'; |
73 | 72 | apiNameFlag?: string; |
74 | | -}): Promise<Agent> => { |
75 | | - const { conn, targetOrg, status, apiNameFlag } = config; |
| 73 | +}): Promise<ProductionAgent> => { |
| 74 | + const { targetOrg, status, apiNameFlag } = config; |
76 | 75 |
|
77 | 76 | let agentsInOrg: BotMetadata[] = []; |
78 | 77 | try { |
79 | | - agentsInOrg = await Agent.listRemote(conn); |
| 78 | + agentsInOrg = await Agent.listRemote(targetOrg.getConnection()); |
80 | 79 | } catch (error) { |
81 | 80 | throw SfError.create({ |
82 | 81 | message: 'Error listing agents in org', |
@@ -105,5 +104,9 @@ export const getAgentForActivation = async (config: { |
105 | 104 | selectedAgent = agentsInOrg.find((agent) => agent.DeveloperName === agentChoice.DeveloperName); |
106 | 105 | } |
107 | 106 |
|
108 | | - return new Agent({ connection: conn, nameOrId: selectedAgent!.Id }); |
| 107 | + return Agent.init({ |
| 108 | + connection: targetOrg.getConnection(), |
| 109 | + apiNameOrId: selectedAgent!.Id, |
| 110 | + project: SfProject.getInstance(), |
| 111 | + }); |
109 | 112 | }; |
0 commit comments