@salesforce/plugin-agent 1.32.14 → 1.32.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -39
- package/lib/commands/agent/activate.d.ts +2 -0
- package/lib/commands/agent/activate.js +33 -4
- package/lib/commands/agent/activate.js.map +1 -1
- package/lib/commands/agent/deactivate.d.ts +2 -0
- package/lib/commands/agent/deactivate.js +33 -4
- package/lib/commands/agent/deactivate.js.map +1 -1
- package/lib/commands/agent/preview/end.d.ts +2 -0
- package/lib/commands/agent/preview/end.js +49 -12
- package/lib/commands/agent/preview/end.js.map +1 -1
- package/lib/commands/agent/preview/send.d.ts +2 -0
- package/lib/commands/agent/preview/send.js +47 -9
- package/lib/commands/agent/preview/send.js.map +1 -1
- package/lib/commands/agent/preview/sessions.d.ts +1 -0
- package/lib/commands/agent/preview/sessions.js +4 -1
- package/lib/commands/agent/preview/sessions.js.map +1 -1
- package/lib/commands/agent/preview/start.d.ts +3 -0
- package/lib/commands/agent/preview/start.js +72 -10
- package/lib/commands/agent/preview/start.js.map +1 -1
- package/lib/commands/agent/test/create.d.ts +2 -0
- package/lib/commands/agent/test/create.js +34 -6
- package/lib/commands/agent/test/create.js.map +1 -1
- package/lib/commands/agent/test/list.d.ts +2 -0
- package/lib/commands/agent/test/list.js +15 -3
- package/lib/commands/agent/test/list.js.map +1 -1
- package/lib/commands/agent/test/results.d.ts +2 -0
- package/lib/commands/agent/test/results.js +23 -3
- package/lib/commands/agent/test/results.js.map +1 -1
- package/lib/commands/agent/test/resume.d.ts +6 -0
- package/lib/commands/agent/test/resume.js +55 -7
- package/lib/commands/agent/test/resume.js.map +1 -1
- package/lib/commands/agent/test/run-eval.d.ts +2 -0
- package/lib/commands/agent/test/run-eval.js +38 -7
- package/lib/commands/agent/test/run-eval.js.map +1 -1
- package/lib/commands/agent/test/run.d.ts +2 -0
- package/lib/commands/agent/test/run.js +32 -8
- package/lib/commands/agent/test/run.js.map +1 -1
- package/lib/commands/agent/validate/authoring-bundle.d.ts +2 -0
- package/lib/commands/agent/validate/authoring-bundle.js +9 -2
- package/lib/commands/agent/validate/authoring-bundle.js.map +1 -1
- package/lib/previewSessionStore.js +0 -6
- package/lib/previewSessionStore.js.map +1 -1
- package/messages/agent.activate.md +8 -0
- package/messages/agent.deactivate.md +8 -0
- package/messages/agent.preview.end.md +18 -6
- package/messages/agent.preview.send.md +16 -4
- package/messages/agent.preview.start.md +31 -10
- package/oclif.manifest.json +372 -7
- package/package.json +3 -3
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
|
|
17
|
-
import { Messages, SfError } from '@salesforce/core';
|
|
16
|
+
import { Flags, SfCommand, toHelpSection } from '@salesforce/sf-plugins-core';
|
|
17
|
+
import { Messages, SfError, Lifecycle, EnvironmentVariable } from '@salesforce/core';
|
|
18
18
|
import { Agent } from '@salesforce/agents';
|
|
19
19
|
import { getCachedSessionIds, validatePreviewSession } from '../../../previewSessionStore.js';
|
|
20
20
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
@@ -24,6 +24,13 @@ export default class AgentPreviewSend extends SfCommand {
|
|
|
24
24
|
static description = messages.getMessage('description');
|
|
25
25
|
static examples = messages.getMessages('examples');
|
|
26
26
|
static requiresProject = true;
|
|
27
|
+
static envVariablesSection = toHelpSection('ENVIRONMENT VARIABLES', EnvironmentVariable.SF_TARGET_ORG);
|
|
28
|
+
static errorCodes = toHelpSection('ERROR CODES', {
|
|
29
|
+
'Succeeded (0)': 'Message sent successfully and agent response received.',
|
|
30
|
+
'NotFound (2)': 'Agent not found, or no preview session exists for this agent.',
|
|
31
|
+
'PreviewSendFailed (4)': 'Failed to send message or receive response from the preview session.',
|
|
32
|
+
'SessionAmbiguous (5)': 'Multiple preview sessions found; specify --session-id to choose one.',
|
|
33
|
+
});
|
|
27
34
|
static flags = {
|
|
28
35
|
'target-org': Flags.requiredOrg(),
|
|
29
36
|
'api-version': Flags.orgApiVersion(),
|
|
@@ -49,23 +56,54 @@ export default class AgentPreviewSend extends SfCommand {
|
|
|
49
56
|
async run() {
|
|
50
57
|
const { flags } = await this.parse(AgentPreviewSend);
|
|
51
58
|
const conn = flags['target-org'].getConnection(flags['api-version']);
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
const agentIdentifier = flags['authoring-bundle'] ?? flags['api-name'];
|
|
60
|
+
// Initialize agent with error tracking
|
|
61
|
+
let agent;
|
|
62
|
+
try {
|
|
63
|
+
agent = flags['authoring-bundle']
|
|
64
|
+
? await Agent.init({ connection: conn, project: this.project, aabName: flags['authoring-bundle'] })
|
|
65
|
+
: await Agent.init({ connection: conn, project: this.project, apiNameOrId: flags['api-name'] });
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
const wrapped = SfError.wrap(error);
|
|
69
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_send_agent_not_found' });
|
|
70
|
+
throw new SfError(messages.getMessage('error.agentNotFound', [agentIdentifier]), 'AgentNotFound', [], 2, wrapped);
|
|
71
|
+
}
|
|
72
|
+
// Get or validate session ID
|
|
55
73
|
let sessionId = flags['session-id'];
|
|
56
74
|
if (sessionId === undefined) {
|
|
57
75
|
const cached = await getCachedSessionIds(this.project, agent);
|
|
58
76
|
if (cached.length === 0) {
|
|
59
|
-
|
|
77
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_send_no_session' });
|
|
78
|
+
throw new SfError(messages.getMessage('error.noSession'), 'PreviewSessionNotFound', [], 2);
|
|
60
79
|
}
|
|
61
80
|
if (cached.length > 1) {
|
|
62
|
-
|
|
81
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_send_multiple_sessions' });
|
|
82
|
+
throw new SfError(messages.getMessage('error.multipleSessions', [cached.join(', ')]), 'PreviewSessionAmbiguous', [], 5);
|
|
63
83
|
}
|
|
64
84
|
sessionId = cached[0];
|
|
65
85
|
}
|
|
66
86
|
agent.setSessionId(sessionId);
|
|
67
|
-
|
|
68
|
-
|
|
87
|
+
// Validate session
|
|
88
|
+
try {
|
|
89
|
+
await validatePreviewSession(agent);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
const wrapped = SfError.wrap(error);
|
|
93
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_send_session_invalid' });
|
|
94
|
+
throw new SfError(messages.getMessage('error.sessionInvalid', [sessionId]), 'PreviewSessionInvalid', [], 2, wrapped);
|
|
95
|
+
}
|
|
96
|
+
// Send message with error tracking
|
|
97
|
+
let response;
|
|
98
|
+
try {
|
|
99
|
+
response = await agent.preview.send(flags.utterance);
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
const wrapped = SfError.wrap(error);
|
|
103
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_send_failed' });
|
|
104
|
+
throw new SfError(messages.getMessage('error.sendFailed', [wrapped.message]), 'PreviewSendFailed', [wrapped.message], 4, wrapped);
|
|
105
|
+
}
|
|
106
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_send_success' });
|
|
69
107
|
this.log(response.messages[0].message);
|
|
70
108
|
return { messages: response.messages ?? [] };
|
|
71
109
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send.js","sourceRoot":"","sources":["../../../../src/commands/agent/preview/send.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"send.js","sourceRoot":"","sources":["../../../../src/commands/agent/preview/send.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,a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,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACvC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAC;IAC/C,CAAC"}
|
|
@@ -9,5 +9,6 @@ export default class AgentPreviewSessions extends SfCommand<AgentPreviewSessions
|
|
|
9
9
|
static readonly description: string;
|
|
10
10
|
static readonly examples: string[];
|
|
11
11
|
static readonly requiresProject = true;
|
|
12
|
+
static readonly errorCodes: import("@oclif/core").HelpSection;
|
|
12
13
|
run(): Promise<AgentPreviewSessionsResult>;
|
|
13
14
|
}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
16
|
+
import { SfCommand, toHelpSection } from '@salesforce/sf-plugins-core';
|
|
17
17
|
import { Messages } from '@salesforce/core';
|
|
18
18
|
import { listCachedSessions } from '../../../previewSessionStore.js';
|
|
19
19
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
@@ -23,6 +23,9 @@ export default class AgentPreviewSessions extends SfCommand {
|
|
|
23
23
|
static description = messages.getMessage('description');
|
|
24
24
|
static examples = messages.getMessages('examples');
|
|
25
25
|
static requiresProject = true;
|
|
26
|
+
static errorCodes = toHelpSection('ERROR CODES', {
|
|
27
|
+
'Succeeded (0)': 'Sessions listed successfully (or empty list if no active sessions).',
|
|
28
|
+
});
|
|
26
29
|
async run() {
|
|
27
30
|
const entries = await listCachedSessions(this.project);
|
|
28
31
|
const rows = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../../../src/commands/agent/preview/sessions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAA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,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtB,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC;YAC9C,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,iBAAiB,GAAG,QAAQ,CAAC,UAAU,CAAC,0BAA0B,CAAC,CAAC;QAC1E,MAAM,eAAe,GAAG,QAAQ,CAAC,UAAU,CAAC,8BAA8B,CAAC,CAAC;QAC5E,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACjC,KAAK,EAAE,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,OAAO;YACjC,SAAS,EAAE,CAAC,CAAC,SAAS;SACvB,CAAC,CAAC,CAAC;QACJ,IAAI,CAAC,KAAK,CAAC;YACT,IAAI,EAAE,SAAS;YACf,OAAO,EAAE;gBACP,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE;gBACzC,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,EAAE;aAC5C;SACF,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC"}
|
|
@@ -7,12 +7,15 @@ export default class AgentPreviewStart extends SfCommand<AgentPreviewStartResult
|
|
|
7
7
|
static readonly description: string;
|
|
8
8
|
static readonly examples: string[];
|
|
9
9
|
static readonly requiresProject = true;
|
|
10
|
+
static readonly envVariablesSection: import("@oclif/core").HelpSection;
|
|
11
|
+
static readonly errorCodes: import("@oclif/core").HelpSection;
|
|
10
12
|
static readonly flags: {
|
|
11
13
|
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
14
|
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
15
|
'api-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
16
|
'authoring-bundle': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
17
|
'use-live-actions': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
|
+
'simulate-actions': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
19
|
};
|
|
17
20
|
run(): Promise<AgentPreviewStartResult>;
|
|
18
21
|
}
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
|
|
17
|
-
import { Lifecycle, Messages } from '@salesforce/core';
|
|
16
|
+
import { Flags, SfCommand, toHelpSection } from '@salesforce/sf-plugins-core';
|
|
17
|
+
import { EnvironmentVariable, Lifecycle, Messages, SfError } from '@salesforce/core';
|
|
18
18
|
import { Agent, ProductionAgent, ScriptAgent } from '@salesforce/agents';
|
|
19
19
|
import { createCache } from '../../../previewSessionStore.js';
|
|
20
|
+
import { COMPILATION_API_EXIT_CODES } from '../../../common.js';
|
|
20
21
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
21
22
|
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.preview.start');
|
|
22
23
|
export default class AgentPreviewStart extends SfCommand {
|
|
@@ -24,6 +25,14 @@ export default class AgentPreviewStart extends SfCommand {
|
|
|
24
25
|
static description = messages.getMessage('description');
|
|
25
26
|
static examples = messages.getMessages('examples');
|
|
26
27
|
static requiresProject = true;
|
|
28
|
+
static envVariablesSection = toHelpSection('ENVIRONMENT VARIABLES', EnvironmentVariable.SF_TARGET_ORG);
|
|
29
|
+
static errorCodes = toHelpSection('ERROR CODES', {
|
|
30
|
+
'Succeeded (0)': 'Preview session started successfully.',
|
|
31
|
+
'Failed (1)': 'Agent Script compilation failed (syntax errors in the script).',
|
|
32
|
+
'NotFound (2)': 'Agent not found, or compilation API returned HTTP 404 (endpoint may not be available in your org or region).',
|
|
33
|
+
'ServerError (3)': 'Compilation API returned HTTP 500 (server error during compilation).',
|
|
34
|
+
'PreviewStartFailed (4)': 'Preview session failed to start due to API or network errors.',
|
|
35
|
+
});
|
|
27
36
|
static flags = {
|
|
28
37
|
'target-org': Flags.requiredOrg(),
|
|
29
38
|
'api-version': Flags.orgApiVersion(),
|
|
@@ -38,25 +47,78 @@ export default class AgentPreviewStart extends SfCommand {
|
|
|
38
47
|
}),
|
|
39
48
|
'use-live-actions': Flags.boolean({
|
|
40
49
|
summary: messages.getMessage('flags.use-live-actions.summary'),
|
|
41
|
-
|
|
50
|
+
exclusive: ['simulate-actions'],
|
|
51
|
+
}),
|
|
52
|
+
'simulate-actions': Flags.boolean({
|
|
53
|
+
summary: messages.getMessage('flags.simulate-actions.summary'),
|
|
54
|
+
exclusive: ['use-live-actions'],
|
|
42
55
|
}),
|
|
43
56
|
};
|
|
44
57
|
async run() {
|
|
45
58
|
const { flags } = await this.parse(AgentPreviewStart);
|
|
59
|
+
// Validate: authoring-bundle requires exactly one mode flag
|
|
60
|
+
// (mutual exclusion of mode flags handled by 'exclusive' in flag definitions)
|
|
61
|
+
if (flags['authoring-bundle'] && !flags['use-live-actions'] && !flags['simulate-actions']) {
|
|
62
|
+
throw new SfError('When using --authoring-bundle, you must specify either --use-live-actions or --simulate-actions.', 'MissingModeFlag');
|
|
63
|
+
}
|
|
46
64
|
const conn = flags['target-org'].getConnection(flags['api-version']);
|
|
47
65
|
const useLiveActions = flags['use-live-actions'];
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
66
|
+
const simulateActions = flags['simulate-actions'];
|
|
67
|
+
const agentIdentifier = flags['authoring-bundle'] ?? flags['api-name'];
|
|
68
|
+
// Track telemetry for agent initialization
|
|
69
|
+
let agent;
|
|
70
|
+
try {
|
|
71
|
+
agent = flags['authoring-bundle']
|
|
72
|
+
? await Agent.init({ connection: conn, project: this.project, aabName: flags['authoring-bundle'] })
|
|
73
|
+
: await Agent.init({ connection: conn, project: this.project, apiNameOrId: flags['api-name'] });
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
const wrapped = SfError.wrap(error);
|
|
77
|
+
// Check for agent not found errors
|
|
78
|
+
if (wrapped.message.toLowerCase().includes('not found') || wrapped.code === 'ENOENT') {
|
|
79
|
+
const notFoundError = new SfError(messages.getMessage('error.agentNotFound', [agentIdentifier]), 'AgentNotFound', [], 2);
|
|
80
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_start_agent_not_found' });
|
|
81
|
+
throw notFoundError;
|
|
82
|
+
}
|
|
83
|
+
// Check for compilation API errors (404/500 handled by @salesforce/agents)
|
|
84
|
+
if (wrapped.exitCode === COMPILATION_API_EXIT_CODES.NOT_FOUND) {
|
|
85
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_start_compilation_not_found' });
|
|
86
|
+
throw wrapped;
|
|
87
|
+
}
|
|
88
|
+
if (wrapped.exitCode === COMPILATION_API_EXIT_CODES.SERVER_ERROR) {
|
|
89
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_start_compilation_server_error' });
|
|
90
|
+
throw wrapped;
|
|
91
|
+
}
|
|
92
|
+
// Check for compilation failure (exit code 1)
|
|
93
|
+
if (wrapped.exitCode === 1 && wrapped.name === 'CompileAgentScriptError') {
|
|
94
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_start_compilation_failed' });
|
|
95
|
+
throw wrapped;
|
|
96
|
+
}
|
|
97
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_start_agent_init_failed' });
|
|
98
|
+
throw wrapped;
|
|
99
|
+
}
|
|
100
|
+
// Set mode for authoring bundles based on which flag was specified
|
|
101
|
+
// (mutual exclusion enforced by flag definitions - can't have both)
|
|
51
102
|
if (agent instanceof ScriptAgent) {
|
|
52
|
-
agent.preview.setMockMode(
|
|
103
|
+
agent.preview.setMockMode(simulateActions ? 'Mock' : 'Live Test');
|
|
104
|
+
}
|
|
105
|
+
// Warn if mode flags are used with published agents (they have no effect)
|
|
106
|
+
if (agent instanceof ProductionAgent && (useLiveActions || simulateActions)) {
|
|
107
|
+
void Lifecycle.getInstance().emitWarning('Published agents always use real actions; --use-live-actions and --simulate-actions have no effect for published agents.');
|
|
108
|
+
}
|
|
109
|
+
// Track telemetry for preview start
|
|
110
|
+
let session;
|
|
111
|
+
try {
|
|
112
|
+
session = await agent.preview.start();
|
|
53
113
|
}
|
|
54
|
-
|
|
55
|
-
|
|
114
|
+
catch (error) {
|
|
115
|
+
const wrapped = SfError.wrap(error);
|
|
116
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_start_failed' });
|
|
117
|
+
throw new SfError(messages.getMessage('error.previewStartFailed', [wrapped.message]), 'PreviewStartFailed', [wrapped.message], 4, wrapped);
|
|
56
118
|
}
|
|
57
|
-
const session = await agent.preview.start();
|
|
58
119
|
const displayName = flags['authoring-bundle'] ?? flags['api-name'];
|
|
59
120
|
await createCache(agent, { displayName });
|
|
121
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_start_success' });
|
|
60
122
|
const result = { sessionId: session.sessionId };
|
|
61
123
|
this.log(messages.getMessage('output.sessionId', [session.sessionId]));
|
|
62
124
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../../../src/commands/agent/preview/start.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../../../src/commands/agent/preview/start.ts"],"names":[],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,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpC,MAAM,SAAS,CAAC,WAAW,EAAE,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,4BAA4B,EAAE,CAAC,CAAC;YACzF,MAAM,IAAI,OAAO,CACf,QAAQ,CAAC,UAAU,CAAC,0BAA0B,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAClE,oBAAoB,EACpB,CAAC,OAAO,CAAC,OAAO,CAAC,EACjB,CAAC,EACD,OAAO,CACR,CAAC;QACJ,CAAC;QAED,MAAM,WAAW,GAAG,KAAK,CAAC,kBAAkB,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;QACnE,MAAM,WAAW,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;QAE1C,MAAM,SAAS,CAAC,WAAW,EAAE,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,6BAA6B,EAAE,CAAC,CAAC;QAC1F,MAAM,MAAM,GAA4B,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;QACzE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,kBAAkB,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QACvE,OAAO,MAAM,CAAC;IAChB,CAAC"}
|
|
@@ -9,6 +9,8 @@ export default class AgentTestCreate extends SfCommand<AgentTestCreateResult> {
|
|
|
9
9
|
static readonly summary: string;
|
|
10
10
|
static readonly description: string;
|
|
11
11
|
static readonly examples: string[];
|
|
12
|
+
static readonly envVariablesSection: import("@oclif/core").HelpSection;
|
|
13
|
+
static readonly errorCodes: import("@oclif/core").HelpSection;
|
|
12
14
|
static readonly flags: {
|
|
13
15
|
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
16
|
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { join, resolve } from 'node:path';
|
|
17
17
|
import { existsSync } from 'node:fs';
|
|
18
|
-
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
19
|
-
import { Lifecycle, Messages } from '@salesforce/core';
|
|
18
|
+
import { SfCommand, Flags, toHelpSection } from '@salesforce/sf-plugins-core';
|
|
19
|
+
import { Lifecycle, Messages, SfError, EnvironmentVariable } from '@salesforce/core';
|
|
20
20
|
import { AgentTest, AgentTestCreateLifecycleStages } from '@salesforce/agents';
|
|
21
21
|
import { MultiStageOutput } from '@oclif/multi-stage-output';
|
|
22
22
|
import { makeFlags, promptForFlag, promptForYamlFile } from '../../../flags.js';
|
|
@@ -74,6 +74,13 @@ export default class AgentTestCreate extends SfCommand {
|
|
|
74
74
|
static summary = messages.getMessage('summary');
|
|
75
75
|
static description = messages.getMessage('description');
|
|
76
76
|
static examples = messages.getMessages('examples');
|
|
77
|
+
static envVariablesSection = toHelpSection('ENVIRONMENT VARIABLES', EnvironmentVariable.SF_TARGET_ORG);
|
|
78
|
+
static errorCodes = toHelpSection('ERROR CODES', {
|
|
79
|
+
'Succeeded (0)': 'Test created and deployed successfully.',
|
|
80
|
+
'Failed (1)': 'Test validation errors or metadata format issues.',
|
|
81
|
+
'NotFound (2)': 'Test spec file not found or org connection failed.',
|
|
82
|
+
'DeploymentFailed (4)': 'Deployment failed due to API or network errors.',
|
|
83
|
+
});
|
|
77
84
|
static flags = {
|
|
78
85
|
...makeFlags(FLAGGABLE_PROMPTS),
|
|
79
86
|
'target-org': Flags.requiredOrg(),
|
|
@@ -135,10 +142,31 @@ export default class AgentTestCreate extends SfCommand {
|
|
|
135
142
|
}
|
|
136
143
|
return Promise.resolve();
|
|
137
144
|
});
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
145
|
+
let path;
|
|
146
|
+
let contents;
|
|
147
|
+
try {
|
|
148
|
+
const result = await AgentTest.create(connection, apiName, spec, {
|
|
149
|
+
outputDir: join('force-app', 'main', 'default', 'aiEvaluationDefinitions'),
|
|
150
|
+
preview: flags.preview,
|
|
151
|
+
});
|
|
152
|
+
path = result.path;
|
|
153
|
+
contents = result.contents;
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
const wrapped = SfError.wrap(error);
|
|
157
|
+
// Check for file not found errors
|
|
158
|
+
if (wrapped.message.toLowerCase().includes('not found') ||
|
|
159
|
+
wrapped.message.toLowerCase().includes('enoent') ||
|
|
160
|
+
wrapped.code === 'ENOENT') {
|
|
161
|
+
throw new SfError(`Test spec file not found: ${spec}`, 'SpecFileNotFound', [], 2, wrapped);
|
|
162
|
+
}
|
|
163
|
+
// Check for deployment failures (API/network)
|
|
164
|
+
if (wrapped.message.toLowerCase().includes('deploy') || wrapped.message.toLowerCase().includes('api')) {
|
|
165
|
+
throw new SfError(`Deployment failed: ${wrapped.message}`, 'DeploymentFailed', [wrapped.message], 4, wrapped);
|
|
166
|
+
}
|
|
167
|
+
// Other errors (validation, format issues) use exit 1
|
|
168
|
+
throw wrapped;
|
|
169
|
+
}
|
|
142
170
|
if (flags.preview) {
|
|
143
171
|
this.mso?.skipTo(AgentTestCreateLifecycleStages.Done);
|
|
144
172
|
this.mso?.stop();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/commands/agent/test/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/commands/agent/test/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;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UAAU,CAAC,cAAc,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,WAAW,EAAE,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CACjH,CAAC;QACJ,CAAC;QAED,OAAO;YACL,IAAI;YACJ,QAAQ;SACT,CAAC;IACJ,CAAC;IAES,KAAK,CAAC,KAAiC;QAC/C,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC"}
|
|
@@ -5,6 +5,8 @@ export default class AgentTestList extends SfCommand<AgentTestListResult> {
|
|
|
5
5
|
static readonly summary: string;
|
|
6
6
|
static readonly description: string;
|
|
7
7
|
static readonly examples: string[];
|
|
8
|
+
static readonly envVariablesSection: import("@oclif/core").HelpSection;
|
|
9
|
+
static readonly errorCodes: import("@oclif/core").HelpSection;
|
|
8
10
|
static readonly flags: {
|
|
9
11
|
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
12
|
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -14,21 +14,33 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { AgentTest } from '@salesforce/agents';
|
|
17
|
-
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
18
|
-
import { Messages } from '@salesforce/core';
|
|
17
|
+
import { SfCommand, Flags, toHelpSection } from '@salesforce/sf-plugins-core';
|
|
18
|
+
import { Messages, EnvironmentVariable, SfError } from '@salesforce/core';
|
|
19
19
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
20
20
|
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.test.list');
|
|
21
21
|
export default class AgentTestList extends SfCommand {
|
|
22
22
|
static summary = messages.getMessage('summary');
|
|
23
23
|
static description = messages.getMessage('description');
|
|
24
24
|
static examples = messages.getMessages('examples');
|
|
25
|
+
static envVariablesSection = toHelpSection('ENVIRONMENT VARIABLES', EnvironmentVariable.SF_TARGET_ORG);
|
|
26
|
+
static errorCodes = toHelpSection('ERROR CODES', {
|
|
27
|
+
'Succeeded (0)': 'Agent tests listed successfully.',
|
|
28
|
+
'Failed (4)': 'Failed to retrieve agent tests due to API or network errors.',
|
|
29
|
+
});
|
|
25
30
|
static flags = {
|
|
26
31
|
'target-org': Flags.requiredOrg(),
|
|
27
32
|
'api-version': Flags.orgApiVersion(),
|
|
28
33
|
};
|
|
29
34
|
async run() {
|
|
30
35
|
const { flags } = await this.parse(AgentTestList);
|
|
31
|
-
|
|
36
|
+
let results;
|
|
37
|
+
try {
|
|
38
|
+
results = await AgentTest.list(flags['target-org'].getConnection(flags['api-version']));
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
const wrapped = SfError.wrap(error);
|
|
42
|
+
throw new SfError(`Failed to retrieve agent tests: ${wrapped.message}`, 'ListRetrievalFailed', [wrapped.message], 4, wrapped);
|
|
43
|
+
}
|
|
32
44
|
this.table({
|
|
33
45
|
data: results,
|
|
34
46
|
columns: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../../src/commands/agent/test/list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAA4B,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../../src/commands/agent/test/list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAA4B,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,MA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,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpC,MAAM,IAAI,OAAO,CACf,mCAAmC,OAAO,CAAC,OAAO,EAAE,EACpD,qBAAqB,EACrB,CAAC,OAAO,CAAC,OAAO,CAAC,EACjB,CAAC,EACD,OAAO,CACR,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,KAAK,CAAC;YACT,IAAI,EAAE,OAAO;YACb,OAAO,EAAE;gBACP,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE;gBACrC,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE;gBACzB,EAAE,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,cAAc,EAAE;aAC7C;YACD,IAAI,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE;SAC1B,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACjB,CAAC"}
|
|
@@ -5,6 +5,8 @@ export default class AgentTestResults extends SfCommand<AgentTestResultsResult>
|
|
|
5
5
|
static readonly summary: string;
|
|
6
6
|
static readonly description: string;
|
|
7
7
|
static readonly examples: string[];
|
|
8
|
+
static readonly envVariablesSection: import("@oclif/core").HelpSection;
|
|
9
|
+
static readonly errorCodes: import("@oclif/core").HelpSection;
|
|
8
10
|
static readonly flags: {
|
|
9
11
|
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
12
|
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
17
|
-
import { Messages } from '@salesforce/core';
|
|
16
|
+
import { SfCommand, Flags, toHelpSection } from '@salesforce/sf-plugins-core';
|
|
17
|
+
import { EnvironmentVariable, Messages, SfError } from '@salesforce/core';
|
|
18
18
|
import { AgentTester } from '@salesforce/agents';
|
|
19
19
|
import { resultFormatFlag, testOutputDirFlag, verboseFlag } from '../../../flags.js';
|
|
20
20
|
import { handleTestResults } from '../../../handleTestResults.js';
|
|
@@ -24,6 +24,12 @@ export default class AgentTestResults extends SfCommand {
|
|
|
24
24
|
static summary = messages.getMessage('summary');
|
|
25
25
|
static description = messages.getMessage('description');
|
|
26
26
|
static examples = messages.getMessages('examples');
|
|
27
|
+
static envVariablesSection = toHelpSection('ENVIRONMENT VARIABLES', EnvironmentVariable.SF_TARGET_ORG);
|
|
28
|
+
static errorCodes = toHelpSection('ERROR CODES', {
|
|
29
|
+
'Succeeded (0)': 'Results retrieved successfully. Test results (passed/failed) are in the output.',
|
|
30
|
+
'NotFound (2)': 'Job ID not found or invalid.',
|
|
31
|
+
'Failed (4)': 'Failed to retrieve results due to API or network errors.',
|
|
32
|
+
});
|
|
27
33
|
static flags = {
|
|
28
34
|
'target-org': Flags.requiredOrg(),
|
|
29
35
|
'api-version': Flags.orgApiVersion(),
|
|
@@ -39,7 +45,21 @@ export default class AgentTestResults extends SfCommand {
|
|
|
39
45
|
async run() {
|
|
40
46
|
const { flags } = await this.parse(AgentTestResults);
|
|
41
47
|
const agentTester = new AgentTester(flags['target-org'].getConnection(flags['api-version']));
|
|
42
|
-
|
|
48
|
+
let response;
|
|
49
|
+
try {
|
|
50
|
+
response = await agentTester.results(flags['job-id']);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
const wrapped = SfError.wrap(error);
|
|
54
|
+
// Check for job not found errors
|
|
55
|
+
if (wrapped.message.toLowerCase().includes('not found') ||
|
|
56
|
+
wrapped.message.toLowerCase().includes('invalid') ||
|
|
57
|
+
wrapped.code === 'ENOENT') {
|
|
58
|
+
throw new SfError(`Job ID '${flags['job-id']}' not found or invalid.`, 'JobNotFound', [], 2, wrapped);
|
|
59
|
+
}
|
|
60
|
+
// API/network failures
|
|
61
|
+
throw new SfError(`Failed to retrieve results: ${wrapped.message}`, 'ResultsRetrievalFailed', [wrapped.message], 4, wrapped);
|
|
62
|
+
}
|
|
43
63
|
await handleTestResults({
|
|
44
64
|
id: flags['job-id'],
|
|
45
65
|
format: flags['result-format'],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"results.js","sourceRoot":"","sources":["../../../../src/commands/agent/test/results.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"results.js","sourceRoot":"","sources":["../../../../src/commands/agent/test/results.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,WAAW,EAA4B,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,0BAA0B,EAAE,oBAAoB,CAAC,CAAC;AAIzF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,SAAiC;IACtE,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACjE,MAAM,CAAU,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU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WAAW,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC;gBACjD,OAAO,CAAC,IAAI,KAAK,QAAQ,EACzB,CAAC;gBACD,MAAM,IAAI,OAAO,CAAC,WAAW,KAAK,CAAC,QAAQ,CAAC,yBAAyB,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;YACxG,CAAC;YAED,uBAAuB;YACvB,MAAM,IAAI,OAAO,CACf,+BAA+B,OAAO,CAAC,OAAO,EAAE,EAChD,wBAAwB,EACxB,CAAC,OAAO,CAAC,OAAO,CAAC,EACjB,CAAC,EACD,OAAO,CACR,CAAC;QACJ,CAAC;QAED,MAAM,iBAAiB,CAAC;YACtB,EAAE,EAAE,KAAK,CAAC,QAAQ,CAAC;YACnB,MAAM,EAAE,KAAK,CAAC,eAAe,CAAC;YAC9B,OAAO,EAAE,QAAQ;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;YAC/B,SAAS,EAAE,KAAK,CAAC,YAAY,CAAC;YAC9B,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC;IAClB,CAAC"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { SfError } from '@salesforce/core';
|
|
3
|
+
import { CLIError } from '@oclif/core/errors';
|
|
2
4
|
import { AgentTestRunResult } from '../../../flags.js';
|
|
3
5
|
export default class AgentTestResume extends SfCommand<AgentTestRunResult> {
|
|
4
6
|
static readonly summary: string;
|
|
5
7
|
static readonly description: string;
|
|
6
8
|
static readonly examples: string[];
|
|
9
|
+
static readonly envVariablesSection: import("@oclif/core").HelpSection;
|
|
10
|
+
static readonly errorCodes: import("@oclif/core").HelpSection;
|
|
7
11
|
static readonly flags: {
|
|
8
12
|
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
13
|
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -14,5 +18,7 @@ export default class AgentTestResume extends SfCommand<AgentTestRunResult> {
|
|
|
14
18
|
'output-dir': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
19
|
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
20
|
};
|
|
21
|
+
private mso;
|
|
17
22
|
run(): Promise<AgentTestRunResult>;
|
|
23
|
+
protected catch(error: Error | SfError | CLIError): Promise<never>;
|
|
18
24
|
}
|