Skip to content

Commit 94f46f3

Browse files
chore: merge with nga, resolve conflicts
2 parents 5cf6a9c + 46560d5 commit 94f46f3

File tree

13 files changed

+1283
-1099
lines changed

13 files changed

+1283
-1099
lines changed

README.md

Lines changed: 72 additions & 45 deletions
Large diffs are not rendered by default.
Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,51 @@
11
# summary
22

3-
Generate an authoring bundle from an agent specification.
3+
Generate a local authoring bundle from an existing agent spec YAML file.
44

55
# description
66

7-
Generates an authoring bundle containing Agent and its meta.xml file from an agent specification file.
7+
Authoring bundles are metadata types that represent the next-gen Salesforce agents. Their exact metadata name is AiAuthoringBundle and they consist of a standard "\*-meta.xml" metadata file and an agent file (with extension ".agent") that fully describes the next-gen agent. Use this command to generate an authoring bundle based on an agent spec YAML file, which you create with the "agent create agent-spec" command.
8+
9+
By default, authoring bundles are generated in the force-app/main/default/aiAuthoringBundles/<api-name> directory. Use the --output-dir to generate them elsewhere.
810

911
# flags.spec.summary
1012

11-
Path to the agent specification file.
13+
Path to the agent spec YAML file.
1214

1315
# flags.output-dir.summary
1416

15-
Directory where the authoring bundle files will be generated.
17+
Directory where the authoring bundle files are generated.
1618

1719
# flags.name.summary
1820

1921
Name (label) of the authoring bundle.
2022

2123
# flags.api-name.summary
2224

23-
API name of the new authoring bundle; if not specified, the API name is derived from the authoring bundle name (label); the API name must not exist in the org.
25+
API name of the new authoring bundle; if not specified, the API name is derived from the authoring bundle name (label); the API name can't exist in the org.
2426

2527
# flags.api-name.prompt
2628

2729
API name of the new authoring bundle
2830

2931
# examples
3032

31-
- Generate an authoring bundle from a specification file:
32-
<%= config.bin %> <%= command.id %> --spec-file path/to/spec.yaml --name "My Authoring Bundle"
33+
- Generate an authoring bundle from the "specs/agentSpec.yaml" agent spec YAML file and give it the label "My Authoring Bundle":
34+
35+
<%= config.bin %> <%= command.id %> --spec-file specs/agentSpec.yaml --name "My Authoring Bundle"
36+
37+
- Same as previous example, but generate the files in the other-package-dir/main/default/aiAuthoringBundles directory:
3338

34-
- Generate an authoring bundle with a custom output directory:
35-
<%= config.bin %> <%= command.id %> --spec-file path/to/spec.yaml --name "My Authoring Bundle" --output-dir path/to/output
39+
<%= config.bin %> <%= command.id %> --spec-file specs/agentSpec.yaml --name "My Authoring Bundle" --output-dir other-package-dir/main/default/aiAuthoringBundles
3640

3741
# error.no-spec-file
3842

39-
No agent specification file found at the specified path.
43+
No agent spec YAML file found at the specified path.
4044

4145
# error.invalid-spec-file
4246

43-
The specified file is not a valid agent specification file.
47+
The specified file is not a valid agent spec YAML file.
4448

4549
# error.failed-to-create-agent
4650

47-
Failed to create Agent from the agent specification.
51+
Failed to create a next-gen agent from the agent spec YAML file.

messages/agent.preview.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ When the session concludes, the command asks if you want to save the API respons
1212

1313
Find the agent's API name in its Agent Details page of your org's Agentforce Studio UI in Setup. If your agent is currently deactivated, use the "agent activate" CLI command to activate it.
1414

15-
IMPORTANT: Before you use this command, you must complete a number of configuration steps in your org and your DX project. The examples in this help assume you've completed the steps. See "Preview an Agent" in the "Agentforce Developer Guide" for complete documentation: https://developer.salesforce.com/docs/einstein/genai/guide/agent-dx-preview.html.
15+
IMPORTANT: Before you use this command, you must complete a number of configuration steps in your org and your DX project. For example, you must first create the link to a client connected app using the "org login web --client-app" CLI command to then get the value of the --client-app flag of this command. The examples in this help assume you've completed the steps. See "Preview an Agent" in the "Agentforce Developer Guide" for complete documentation: https://developer.salesforce.com/docs/einstein/genai/guide/agent-dx-preview.html.
1616

1717
# flags.api-name.summary
1818

1919
API name of the agent you want to interact with.
2020

2121
# flags.authoring-bundle.summary
2222

23-
Preview an ephemeral agent by specifying the API name of the Authoring Bundle metadata
23+
Preview a next-gen agent by specifying the API name of the authoring bundle metadata component that implements it.
2424

2525
# flags.client-app.summary
2626

27-
Name of the linked client app to use for the agent connection. You must have previously created this link with "org login web --client-app". Run "org display" to see the available linked client apps.
27+
Name of the linked client app to use for the agent connection.
2828

2929
# flags.output-dir.summary
3030

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,40 @@
11
# summary
22

3-
Publish an Agent Authoring Bundle as a new agent
3+
Publish an authoring bundle to your org, which results in a new next-gen agent.
44

55
# description
66

7-
Publishes an Agent Authoring Bundle by compiling the .agent file and creating a new agent in your org.
7+
When you publish an authoring bundle to your org, a number of things happen. First, this command validates that the agent file (with extension ".agent") successfully compiles. Then the authoring bundle metadata component is deployed to the org, and all associated metadata components, such as the Bot, BotVersion, and GenAiXXX components, are either created or updated. The org then creates a new next-gen agent based on the deployed authoring bundle and associated metadata. Finally, all the metadata associated with the new agent is retrieved back to your local DX project.
8+
9+
Authoring bundles are metadata types that represent the next-gen Salesforce agents. Their exact metadata name is AiAuthoringBundle and they consist of a standard "\*-meta.xml" metadata file and an agent file (with extension ".agent") that fully describes the next-gen agent.
10+
11+
This command requires the API name of the authoring bundle; if you don't provide it with the --api-name flag, the command prompts you for it.
812

913
# examples
1014

11-
- Publish an Agent Authoring Bundle:
12-
<%= config.bin %> <%= command.id %> --api-name path/to/bundle --agent-name "My New Agent" --target-org myorg@example.com
15+
- Publish an authoring bundle with API name MyAuthoringBundle to the org with alias "my-org", resulting in a new agent named "My Fab Agent"::
16+
17+
<%= config.bin %> <%= command.id %> --api-name MyAuthoringbundle --agent-name "My Fab Agent" --target-org my-org
1318

1419
# flags.api-name.summary
1520

16-
API name of the Agent Authoring Bundle to publish.
21+
API name of the authoring bundle you want to publish.
1722

1823
# flags.api-name.prompt
1924

2025
API name of the authoring bundle to publish
2126

2227
# flags.agent-name.summary
2328

24-
Name for the new agent to be created
29+
Name for the new agent that is created from the published authoring bundle.
2530

2631
# error.missingRequiredFlags
2732

28-
Required flag(s) missing: %s
33+
Required flag(s) missing: %s.
2934

3035
# error.invalidBundlePath
3136

32-
Invalid bundle path. Please provide a valid path to an Agent Authoring Bundle.
37+
Invalid bundle path. Provide a valid directory path to an authoring bundle.
3338

3439
# error.publishFailed
3540

@@ -42,4 +47,4 @@ Could not find a .bundle-meta.xml file with API name '%s' in the project.
4247

4348
# error.agentNotFoundAction
4449

45-
Please check that the API name is correct and that the .agent file exists in your project directory.
50+
Check that the API name is correct and that the .agent file exists in your project directory.
Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,40 @@
11
# summary
22

3-
Validate an Agent Authoring Bundle
3+
Validate a local authoring bundle to ensure it compiles successfully and can be used to create a next-gen agent.
44

55
# description
66

7-
Validates an Agent Authoring Bundle by compiling the .agent file and checking for errors.
7+
Authoring bundles are metadata types that represent the next-gen Salesforce agents. Their exact metadata name is AiAuthoringBundle and they consist of a standard "\*-meta.xml" metadata file and an agent file (with extension ".agent") that fully describes the next-gen agent. Generate a local authoring bundle with the "agent generate authoring-bundle" command.
8+
9+
This command validates that the agent file (with extension ".agent") that's part of the authoring bundle compiles without errors and can later be used to successfully create a next-gen agent.
10+
11+
This command requires the API name of the authoring bundle; if you don't provide it with the --api-name flag, the command prompts you for it.
812

913
# examples
1014

11-
- Validate an Agent Authoring Bundle:
12-
<%= config.bin %> <%= command.id %> --api-name path/to/bundle
15+
- Validate a local authoring bundle with API name MyAuthoringBundle:
16+
17+
<%= config.bin %> <%= command.id %> --api-name MyAuthoringBundle
1318

1419
# flags.api-name.summary
1520

16-
API name of the Agent Authoring Bundle to validate.
21+
API name of the authoring bundle you want to validate.
1722

1823
# flags.api-name.prompt
1924

2025
API name of the authoring bundle to validate
2126

2227
# error.missingRequiredFlags
2328

24-
Required flag(s) missing: %s
29+
Required flag(s) missing: %s.
2530

2631
# error.invalidBundlePath
2732

28-
Invalid bundle path. Please provide a valid path to an Agent Authoring Bundle.
33+
Invalid authoring bundle path. Provide a valid directory path to the authoring bundle you want to validate.
2934

3035
# error.compilationFailed
3136

32-
Agent compilation failed with the following errors:
37+
Compilation of the agent file failed with the following errors:
3338
%s
3439

3540
# error.agentNotFound
@@ -38,4 +43,4 @@ Could not find a .bundle-meta.xml file with API name '%s' in the project.
3843

3944
# error.agentNotFoundAction
4045

41-
Please check that the API name is correct and that the .agent file exists in your project directory.
46+
Check that the API name is correct and that the ".agent" file exists in your project directory.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{
22
"name": "@salesforce/plugin-agent",
33
"description": "Commands to interact with Salesforce agents",
4-
"version": "1.24.14-demo.7",
4+
"version": "1.24.14-demo.9",
55
"author": "Salesforce",
66
"bugs": "https://github.com/forcedotcom/cli/issues",
77
"dependencies": {
88
"@inquirer/core": "^10.2.2",
99
"@inquirer/prompts": "^7.8.6",
1010
"@oclif/core": "^4",
1111
"@oclif/multi-stage-output": "^0.8.23",
12-
"@salesforce/agents": "^0.18.1",
12+
"@salesforce/agents": "nga",
1313
"@salesforce/core": "^8.23.1",
1414
"@salesforce/kit": "^3.2.3",
1515
"@salesforce/sf-plugins-core": "^12.2.4",
16-
"@salesforce/source-deploy-retrieve": "^12.22.1",
16+
"@salesforce/source-deploy-retrieve": "^12.25.0",
1717
"@salesforce/types": "^1.4.0",
1818
"@types/glob": "^9.0.0",
1919
"ansis": "^3.3.2",

src/commands/agent/generate/authoring-bundle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export default class AgentGenerateAuthoringBundle extends SfCommand<AgentGenerat
134134
// Write Agent file
135135
const conn = targetOrg.getConnection(flags['api-version']);
136136
const specContents = YAML.parse(readFileSync(spec, 'utf8')) as AgentJobSpec;
137-
const agent = await Agent.createAgentScript(conn, specContents);
137+
const agent = await Agent.createAgentScript(conn, { ...specContents, ...{ name, developerName: bundleApiName } });
138138
// Create output directory if it doesn't exist
139139
mkdirSync(targetOutputDir, { recursive: true });
140140
writeFileSync(agentPath, agent);

src/commands/agent/preview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export default class AgentPreview extends SfCommand<AgentPreviewResult> {
168168

169169
const outputDir = await resolveOutputDir(flags['output-dir'], flags['apex-debug']);
170170
// Both classes share the same interface for the methods we need
171-
const agentPreview: Preview | AgentSimulate =
171+
const agentPreview =
172172
selectedAgent.source === AgentSource.ORG
173173
? new Preview(jwtConn, selectedAgent.Id)
174174
: new AgentSimulate(jwtConn, selectedAgent.path, true);

src/commands/agent/publish/authoring-bundle.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { Agent, findAuthoringBundle } from '@salesforce/agents';
2323
import { RequestStatus, type ScopedPostRetrieve } from '@salesforce/source-deploy-retrieve';
2424
import { ensureArray } from '@salesforce/kit';
2525
import { FlaggablePrompt, promptForAgentFiles } from '../../../flags.js';
26+
import { throwAgentCompilationError } from '../../../common.js';
2627

2728
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
2829
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.publish.authoring-bundle');
@@ -103,12 +104,15 @@ export default class AgentPublishAuthoringBundle extends SfCommand<AgentPublishA
103104
const conn = targetOrg.getConnection(flags['api-version']);
104105

105106
// First compile the .agent file to get the Agent JSON
106-
const agentJson = await Agent.compileAgentScript(
107+
const compileResponse = await Agent.compileAgentScript(
107108
conn,
108109
readFileSync(join(authoringBundleDir, `${apiName}.agent`), 'utf8')
109110
);
110-
mso.skipTo('Publish Agent');
111-
111+
if (compileResponse.status === 'success') {
112+
mso.skipTo('Publish Agent');
113+
} else {
114+
throwAgentCompilationError(compileResponse.errors);
115+
}
112116
// Then publish the Agent JSON to create the agent
113117
// Set up lifecycle listeners for retrieve events
114118
Lifecycle.getInstance().on('scopedPreRetrieve', () => {
@@ -129,7 +133,7 @@ export default class AgentPublishAuthoringBundle extends SfCommand<AgentPublishA
129133
}
130134
return Promise.resolve();
131135
});
132-
const result = await Agent.publishAgentJson(conn, this.project!, agentJson.compiledArtifact!);
136+
const result = await Agent.publishAgentJson(conn, this.project!, compileResponse.compiledArtifact);
133137
mso.stop();
134138

135139
return {

src/commands/agent/validate/authoring-bundle.ts

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { Messages, SfError } from '@salesforce/core';
2020
import { MultiStageOutput } from '@oclif/multi-stage-output';
2121
import { Agent, findAuthoringBundle } from '@salesforce/agents';
2222
import { colorize } from '@oclif/core/ux';
23+
import { throwAgentCompilationError } from '../../../common.js';
2324
import { FlaggablePrompt, promptForAgentFiles } from '../../../flags.js';
2425

2526
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
@@ -98,24 +99,35 @@ export default class AgentValidateAuthoringBundle extends SfCommand<AgentValidat
9899
],
99100
});
100101

101-
mso.skipTo('Validating Authoring Bundle');
102-
const targetOrg = flags['target-org'];
103-
const conn = targetOrg.getConnection(flags['api-version']);
104-
const result = await Agent.compileAgentScript(
105-
conn,
106-
readFileSync(join(authoringBundleDir, `${apiName}.agent`), 'utf8')
107-
);
108-
mso.updateData({ status: 'COMPLETED' });
109-
mso.stop('completed');
110-
if (result.status === 'failure') {
102+
try {
103+
mso.skipTo('Validating Authoring Bundle');
104+
const targetOrg = flags['target-org'];
105+
const conn = targetOrg.getConnection(flags['api-version']);
106+
const result = await Agent.compileAgentScript(
107+
conn,
108+
readFileSync(join(authoringBundleDir, `${apiName}.agent`), 'utf8')
109+
);
110+
if (result.status === 'success') {
111+
mso.updateData({ status: 'COMPLETED' });
112+
mso.stop('completed');
113+
return {
114+
success: true,
115+
};
116+
} else {
117+
throwAgentCompilationError(result.errors);
118+
}
119+
} catch (error) {
111120
// Handle validation errors
121+
const err = SfError.wrap(error);
112122
let count = 0;
113-
const formattedError = result.errors
114-
.map((e) => {
123+
const rawError = err.message ? err.message : err.name;
124+
const formattedError = rawError
125+
.split('\n')
126+
.map((line) => {
115127
count += 1;
116-
return `- ${colorize('red', e.errorType)} ${e.description}: ${e.lineStart}:${e.colStart} / ${e.lineEnd}:${
117-
e.colEnd
118-
}`;
128+
const type = line.split(':')[0];
129+
const rest = line.includes(':') ? line.substring(line.indexOf(':')).trim() : '';
130+
return `- ${colorize('red', type)}${rest}`;
119131
})
120132
.join('\n');
121133

@@ -125,11 +137,7 @@ export default class AgentValidateAuthoringBundle extends SfCommand<AgentValidat
125137
this.log(messages.getMessage('error.compilationFailed', [formattedError]));
126138
return {
127139
success: false,
128-
errors: [formattedError],
129-
};
130-
} else {
131-
return {
132-
success: true,
140+
errors: err.message.split('\n'),
133141
};
134142
}
135143
}

0 commit comments

Comments
 (0)