generated from salesforcecli/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add org open agent * chore(release): 5.1.5-beta.0 [skip ci] * edit messages (#1265) * Update open.agent.md --------- Co-authored-by: svc-cli-bot <Svc_cli_bot@salesforce.com> Co-authored-by: Juliet Shackell <63259011+jshackell-sfdc@users.noreply.github.com> Co-authored-by: Mike Donnalley <mdonnalley@salesforce.com>
- Loading branch information
1 parent
848cc4a
commit 5a07969
Showing
14 changed files
with
366 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# summary | ||
|
||
Open an agent in your org's Agent Builder UI in a browser. | ||
|
||
# description | ||
|
||
Use the --name flag to open an agent using its API name in the Agent Builder UI of your org. To find the agent's API name, go to Setup in your org and navigate to the agent's details page. | ||
|
||
To generate the URL but not launch it in your browser, specify --url-only. | ||
|
||
To open Agent Builder in a specific browser, use the --browser flag. Supported browsers are "chrome", "edge", and "firefox". If you don't specify --browser, the org opens in your default browser. | ||
|
||
# examples | ||
|
||
- Open the agent with API name Coral_Cloud_Agent in your default org using your default browser: | ||
|
||
$ <%= config.bin %> <%= command.id %> --name Coral_Cloud_Agent | ||
|
||
- Open the agent in an incognito window of your default browser: | ||
|
||
$ <%= config.bin %> <%= command.id %> --private --name Coral_Cloud_Agent: | ||
|
||
- Open the agent in an org with alias MyTestOrg1 using the Firefox browser: | ||
|
||
$ <%= config.bin %> <%= command.id %> --target-org MyTestOrg1 --browser firefox --name Coral_Cloud_Agent | ||
|
||
# flags.name.summary | ||
|
||
API name, also known as developer name, of the agent you want to open in the org's Agent Builder UI. | ||
|
||
# flags.private.summary | ||
|
||
Open the org in the default browser using private (incognito) mode. | ||
|
||
# flags.browser.summary | ||
|
||
Browser where the org opens. | ||
|
||
# flags.url-only.summary | ||
|
||
Display navigation URL, but don’t launch browser. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$ref": "#/definitions/OrgOpenOutput", | ||
"definitions": { | ||
"OrgOpenOutput": { | ||
"type": "object", | ||
"properties": { | ||
"url": { | ||
"type": "string" | ||
}, | ||
"username": { | ||
"type": "string" | ||
}, | ||
"orgId": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": ["url", "username", "orgId"], | ||
"additionalProperties": false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (c) 2020, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
import { Flags } from '@salesforce/sf-plugins-core'; | ||
import { Connection, Messages } from '@salesforce/core'; | ||
import { buildFrontdoorUrl } from '../../../shared/orgOpenUtils.js'; | ||
import { OrgOpenCommandBase } from '../../../shared/orgOpenCommandBase.js'; | ||
import { type OrgOpenOutput } from '../../../shared/orgTypes.js'; | ||
|
||
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); | ||
const messages = Messages.loadMessages('@salesforce/plugin-org', 'open.agent'); | ||
|
||
export class OrgOpenAgent extends OrgOpenCommandBase<OrgOpenOutput> { | ||
public static readonly summary = messages.getMessage('summary'); | ||
public static readonly description = messages.getMessage('description'); | ||
public static readonly examples = messages.getMessages('examples'); | ||
public static readonly state = 'beta'; | ||
|
||
public static readonly flags = { | ||
...OrgOpenCommandBase.flags, | ||
'target-org': Flags.requiredOrg(), | ||
'api-version': Flags.orgApiVersion(), | ||
name: Flags.string({ | ||
char: 'n', | ||
summary: messages.getMessage('flags.name.summary'), | ||
required: true, | ||
}), | ||
private: Flags.boolean({ | ||
summary: messages.getMessage('flags.private.summary'), | ||
exclusive: ['url-only', 'browser'], | ||
}), | ||
browser: Flags.option({ | ||
char: 'b', | ||
summary: messages.getMessage('flags.browser.summary'), | ||
options: ['chrome', 'edge', 'firefox'] as const, // These are ones supported by "open" package | ||
exclusive: ['url-only', 'private'], | ||
})(), | ||
'url-only': Flags.boolean({ | ||
char: 'r', | ||
summary: messages.getMessage('flags.url-only.summary'), | ||
aliases: ['urlonly'], | ||
deprecateAliases: true, | ||
}), | ||
}; | ||
|
||
public async run(): Promise<OrgOpenOutput> { | ||
const { flags } = await this.parse(OrgOpenAgent); | ||
this.org = flags['target-org']; | ||
this.connection = this.org.getConnection(flags['api-version']); | ||
|
||
const [frontDoorUrl, retUrl] = await Promise.all([ | ||
buildFrontdoorUrl(this.org, this.connection), | ||
buildRetUrl(this.connection, flags.name), | ||
]); | ||
|
||
return this.openOrgUI(flags, frontDoorUrl, retUrl); | ||
} | ||
} | ||
|
||
// Build the URL part to the Agent Builder given a Bot API name. | ||
const buildRetUrl = async (conn: Connection, botName: string): Promise<string> => { | ||
const query = `SELECT id FROM BotDefinition WHERE DeveloperName='${botName}'`; | ||
const botId = (await conn.singleRecordQuery<{ Id: string }>(query)).Id; | ||
return `AiCopilot/copilotStudio.app#/copilot/builder?copilotId=${botId}`; | ||
}; |
Oops, something went wrong.