Skip to content

Commit 5cf6a9c

Browse files
chore: temp commit
1 parent 6e51947 commit 5cf6a9c

File tree

4 files changed

+25
-27
lines changed

4 files changed

+25
-27
lines changed

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.createAgent(conn, specContents);
137+
const agent = await Agent.createAgentScript(conn, specContents);
138138
// Create output directory if it doesn't exist
139139
mkdirSync(targetOutputDir, { recursive: true });
140140
writeFileSync(agentPath, agent);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default class AgentPublishAuthoringBundle extends SfCommand<AgentPublishA
103103
const conn = targetOrg.getConnection(flags['api-version']);
104104

105105
// First compile the .agent file to get the Agent JSON
106-
const agentJson = await Agent.compileAgent(
106+
const agentJson = await Agent.compileAgentScript(
107107
conn,
108108
readFileSync(join(authoringBundleDir, `${apiName}.agent`), 'utf8')
109109
);
@@ -129,7 +129,7 @@ export default class AgentPublishAuthoringBundle extends SfCommand<AgentPublishA
129129
}
130130
return Promise.resolve();
131131
});
132-
const result = await Agent.publishAgentJson(conn, this.project!, agentJson);
132+
const result = await Agent.publishAgentJson(conn, this.project!, agentJson.compiledArtifact!);
133133
mso.stop();
134134

135135
return {

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

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
1919
import { Messages, SfError } from '@salesforce/core';
2020
import { MultiStageOutput } from '@oclif/multi-stage-output';
2121
import { Agent, findAuthoringBundle } from '@salesforce/agents';
22-
import { Duration, sleep } from '@salesforce/kit';
2322
import { colorize } from '@oclif/core/ux';
2423
import { FlaggablePrompt, promptForAgentFiles } from '../../../flags.js';
2524

@@ -99,29 +98,24 @@ export default class AgentValidateAuthoringBundle extends SfCommand<AgentValidat
9998
],
10099
});
101100

102-
try {
103-
mso.skipTo('Validating Authoring Bundle');
104-
const targetOrg = flags['target-org'];
105-
const conn = targetOrg.getConnection(flags['api-version']);
106-
// Call Agent.compileAgent() API
107-
await sleep(Duration.seconds(2));
108-
await Agent.compileAgent(conn, readFileSync(join(authoringBundleDir, `${apiName}.agent`), 'utf8'));
109-
mso.updateData({ status: 'COMPLETED' });
110-
mso.stop('completed');
111-
return {
112-
success: true,
113-
};
114-
} catch (error) {
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') {
115111
// Handle validation errors
116-
const err = SfError.wrap(error);
117112
let count = 0;
118-
const formattedError = err.message
119-
.split('\n')
120-
.map((line) => {
113+
const formattedError = result.errors
114+
.map((e) => {
121115
count += 1;
122-
const type = line.split(':')[0];
123-
const rest = line.substring(line.indexOf(':')).trim();
124-
return `- ${colorize('red', type)} ${rest}`;
116+
return `- ${colorize('red', e.errorType)} ${e.description}: ${e.lineStart}:${e.colStart} / ${e.lineEnd}:${
117+
e.colEnd
118+
}`;
125119
})
126120
.join('\n');
127121

@@ -131,7 +125,11 @@ export default class AgentValidateAuthoringBundle extends SfCommand<AgentValidat
131125
this.log(messages.getMessage('error.compilationFailed', [formattedError]));
132126
return {
133127
success: false,
134-
errors: err.message.split('\n'),
128+
errors: [formattedError],
129+
};
130+
} else {
131+
return {
132+
success: true,
135133
};
136134
}
137135
}

src/components/agent-preview-react.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import React from 'react';
2121
import { Box, Text, useInput } from 'ink';
2222
import TextInput from 'ink-text-input';
2323
import { Connection, SfError } from '@salesforce/core';
24-
import { AgentPreviewBase, AgentPreviewSendResponse, writeDebugLog, type AgentInteractionBase } from '@salesforce/agents';
24+
import { AgentPreviewBase, AgentPreviewSendResponse, writeDebugLog } from '@salesforce/agents';
2525
import { sleep } from '@salesforce/kit';
2626

2727
// Component to show a simple typing animation
@@ -76,7 +76,7 @@ const saveTranscriptsToFile = (
7676
*/
7777
export function AgentPreviewReact(props: {
7878
readonly connection: Connection;
79-
readonly agent: AgentPreviewBase | AgentInteractionBase;
79+
readonly agent: AgentPreviewBase;
8080
readonly name: string;
8181
readonly outputDir: string | undefined;
8282
}): React.ReactNode {

0 commit comments

Comments
 (0)