@salesforce/plugin-agent 1.11.0 → 1.12.0
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 +41 -143
- package/lib/commands/agent/create.d.ts +8 -5
- package/lib/commands/agent/create.js +129 -39
- package/lib/commands/agent/create.js.map +1 -1
- package/lib/commands/agent/generate/spec.d.ts +76 -26
- package/lib/commands/agent/generate/spec.js +183 -82
- package/lib/commands/agent/generate/spec.js.map +1 -1
- package/lib/flags.d.ts +1 -28
- package/lib/flags.js +3 -41
- package/lib/flags.js.map +1 -1
- package/messages/agent.create.md +33 -7
- package/messages/agent.generate.spec.md +84 -12
- package/messages/shared.md +0 -20
- package/npm-shrinkwrap.json +109 -98
- package/oclif.lock +25 -5
- package/oclif.manifest.json +49 -261
- package/package.json +4 -4
- package/schemas/agent-create.json +129 -5
- package/schemas/agent-generate-spec.json +54 -6
- package/lib/commands/agent/create-v2.d.ts +0 -26
- package/lib/commands/agent/create-v2.js +0 -208
- package/lib/commands/agent/create-v2.js.map +0 -1
- package/lib/commands/agent/generate/spec-v2.d.ts +0 -29
- package/lib/commands/agent/generate/spec-v2.js +0 -117
- package/lib/commands/agent/generate/spec-v2.js.map +0 -1
- package/messages/agent.create-v2.md +0 -63
- package/messages/agent.generate.spec-v2.md +0 -53
- package/schemas/agent-create__v2.json +0 -21
- package/schemas/agent-generate-spec__v2.json +0 -85
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
-
export type AgentCreateResult = {
|
|
3
|
-
isSuccess: boolean;
|
|
4
|
-
errorMessage?: string;
|
|
5
|
-
};
|
|
6
|
-
export default class AgentCreateV2 extends SfCommand<AgentCreateResult> {
|
|
7
|
-
static readonly summary: string;
|
|
8
|
-
static readonly description: string;
|
|
9
|
-
static readonly examples: string[];
|
|
10
|
-
static readonly requiresProject = true;
|
|
11
|
-
static state: string;
|
|
12
|
-
static readonly flags: {
|
|
13
|
-
spec: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
-
preview: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
-
'agent-api-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
-
'primary-language': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
-
'planner-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
-
"agent-name": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
-
"user-id": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
-
"enrich-logs": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
-
tone: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
-
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
|
-
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
|
-
};
|
|
25
|
-
run(): Promise<AgentCreateResult>;
|
|
26
|
-
}
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2024, salesforce.com, inc.
|
|
3
|
-
* All rights reserved.
|
|
4
|
-
* Licensed under the BSD 3-Clause license.
|
|
5
|
-
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
-
*/
|
|
7
|
-
import { resolve } from 'node:path';
|
|
8
|
-
import { readFileSync, writeFileSync } from 'node:fs';
|
|
9
|
-
import YAML from 'yaml';
|
|
10
|
-
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
11
|
-
import { Lifecycle, Messages } from '@salesforce/core';
|
|
12
|
-
import { MultiStageOutput } from '@oclif/multi-stage-output';
|
|
13
|
-
import { colorize } from '@oclif/core/ux';
|
|
14
|
-
import { Agent, AgentCreateLifecycleStagesV2 } from '@salesforce/agents';
|
|
15
|
-
import { makeFlags, promptForFlag, validateAgentType } from '../../flags.js';
|
|
16
|
-
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
17
|
-
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.create-v2');
|
|
18
|
-
const MSO_STAGES = {
|
|
19
|
-
parse: 'Parsing Agent spec',
|
|
20
|
-
preview: 'Creating Agent for preview',
|
|
21
|
-
create: 'Creating Agent in org',
|
|
22
|
-
retrieve: 'Retrieving Agent metadata',
|
|
23
|
-
};
|
|
24
|
-
const FLAGGABLE_PROMPTS = {
|
|
25
|
-
'agent-name': {
|
|
26
|
-
message: messages.getMessage('flags.agent-name.summary'),
|
|
27
|
-
validate: (d) => d.length > 0 || 'Agent Name cannot be empty',
|
|
28
|
-
required: true,
|
|
29
|
-
},
|
|
30
|
-
'user-id': {
|
|
31
|
-
message: messages.getMessage('flags.user-id.summary'),
|
|
32
|
-
validate: (d) => {
|
|
33
|
-
// Allow empty string
|
|
34
|
-
if (d.length === 0)
|
|
35
|
-
return true;
|
|
36
|
-
if (d.length === 15 || d.length === 18) {
|
|
37
|
-
if (d.startsWith('005')) {
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return 'Please enter a valid User ID (005 prefix)';
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
'enrich-logs': {
|
|
45
|
-
message: messages.getMessage('flags.enrich-logs.summary'),
|
|
46
|
-
validate: () => true,
|
|
47
|
-
options: ['true', 'false'],
|
|
48
|
-
default: 'false',
|
|
49
|
-
},
|
|
50
|
-
tone: {
|
|
51
|
-
message: messages.getMessage('flags.tone.summary'),
|
|
52
|
-
validate: () => true,
|
|
53
|
-
options: ['formal', 'casual', 'neutral'],
|
|
54
|
-
default: 'casual',
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
export default class AgentCreateV2 extends SfCommand {
|
|
58
|
-
static summary = messages.getMessage('summary');
|
|
59
|
-
static description = messages.getMessage('description');
|
|
60
|
-
static examples = messages.getMessages('examples');
|
|
61
|
-
static requiresProject = true;
|
|
62
|
-
static state = 'beta';
|
|
63
|
-
static flags = {
|
|
64
|
-
'target-org': Flags.requiredOrg(),
|
|
65
|
-
'api-version': Flags.orgApiVersion(),
|
|
66
|
-
...makeFlags(FLAGGABLE_PROMPTS),
|
|
67
|
-
spec: Flags.file({
|
|
68
|
-
// char: 'f',
|
|
69
|
-
summary: messages.getMessage('flags.spec.summary'),
|
|
70
|
-
exists: true,
|
|
71
|
-
required: true,
|
|
72
|
-
}),
|
|
73
|
-
preview: Flags.boolean({
|
|
74
|
-
summary: messages.getMessage('flags.preview.summary'),
|
|
75
|
-
}),
|
|
76
|
-
// Currently hidden; Do we even want to expose this?
|
|
77
|
-
'agent-api-name': Flags.string({
|
|
78
|
-
summary: messages.getMessage('flags.agent-api-name.summary'),
|
|
79
|
-
hidden: true,
|
|
80
|
-
}),
|
|
81
|
-
// Currently hidden because only 'en_US' is supported
|
|
82
|
-
'primary-language': Flags.string({
|
|
83
|
-
summary: messages.getMessage('flags.primary-language.summary'),
|
|
84
|
-
options: ['en_US'],
|
|
85
|
-
default: 'en_US',
|
|
86
|
-
hidden: true,
|
|
87
|
-
}),
|
|
88
|
-
// Seems a very uncommon usecase, but it's possible to do it in the server side API
|
|
89
|
-
'planner-id': Flags.string({
|
|
90
|
-
summary: messages.getMessage('flags.planner-id.summary'),
|
|
91
|
-
}),
|
|
92
|
-
};
|
|
93
|
-
// eslint-disable-next-line complexity
|
|
94
|
-
async run() {
|
|
95
|
-
const { flags } = await this.parse(AgentCreateV2);
|
|
96
|
-
// throw error if --json is used and not all required flags are provided
|
|
97
|
-
if (this.jsonEnabled()) {
|
|
98
|
-
if (!flags.preview && !flags['agent-name']) {
|
|
99
|
-
throw messages.createError('error.missingRequiredFlags', ['agent-name']);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
// Read the agent spec and validate
|
|
103
|
-
const inputSpec = YAML.parse(readFileSync(resolve(flags.spec), 'utf8'));
|
|
104
|
-
validateSpec(inputSpec);
|
|
105
|
-
// If we're saving the agent and we don't have flag values, prompt.
|
|
106
|
-
let agentName = flags['agent-name'];
|
|
107
|
-
let userId = flags['user-id'];
|
|
108
|
-
let enrichLogs = flags['enrich-logs'];
|
|
109
|
-
let tone = flags.tone;
|
|
110
|
-
if (!this.jsonEnabled() && !flags.preview) {
|
|
111
|
-
agentName ??= await promptForFlag(FLAGGABLE_PROMPTS['agent-name']);
|
|
112
|
-
userId ??= await promptForFlag(FLAGGABLE_PROMPTS['user-id']);
|
|
113
|
-
enrichLogs ??= await promptForFlag(FLAGGABLE_PROMPTS['enrich-logs']);
|
|
114
|
-
tone ??= await promptForFlag(FLAGGABLE_PROMPTS.tone);
|
|
115
|
-
}
|
|
116
|
-
let title;
|
|
117
|
-
const stages = [MSO_STAGES.parse];
|
|
118
|
-
if (flags.preview) {
|
|
119
|
-
title = 'Previewing Agent Creation';
|
|
120
|
-
stages.push(MSO_STAGES.preview);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
title = `Creating ${agentName} Agent`;
|
|
124
|
-
stages.push(MSO_STAGES.create);
|
|
125
|
-
stages.push(MSO_STAGES.retrieve);
|
|
126
|
-
}
|
|
127
|
-
const mso = new MultiStageOutput({
|
|
128
|
-
jsonEnabled: this.jsonEnabled(),
|
|
129
|
-
title,
|
|
130
|
-
stages,
|
|
131
|
-
});
|
|
132
|
-
mso.goto(MSO_STAGES.parse);
|
|
133
|
-
// @ts-expect-error not using async method in callback
|
|
134
|
-
Lifecycle.getInstance().on(AgentCreateLifecycleStagesV2.Previewing, () => mso.goto(MSO_STAGES.preview));
|
|
135
|
-
// @ts-expect-error not using async method in callback
|
|
136
|
-
Lifecycle.getInstance().on(AgentCreateLifecycleStagesV2.Creating, () => mso.goto(MSO_STAGES.create));
|
|
137
|
-
// @ts-expect-error not using async method in callback
|
|
138
|
-
Lifecycle.getInstance().on(AgentCreateLifecycleStagesV2.Retrieving, () => mso.goto(MSO_STAGES.retrieve));
|
|
139
|
-
const connection = flags['target-org'].getConnection(flags['api-version']);
|
|
140
|
-
const agent = new Agent(connection, this.project);
|
|
141
|
-
const agentConfig = {
|
|
142
|
-
agentType: inputSpec.agentType,
|
|
143
|
-
generationInfo: {
|
|
144
|
-
defaultInfo: {
|
|
145
|
-
role: inputSpec.role,
|
|
146
|
-
companyName: inputSpec.companyName,
|
|
147
|
-
companyDescription: inputSpec.companyDescription,
|
|
148
|
-
preDefinedTopics: inputSpec.topics,
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
generationSettings: {},
|
|
152
|
-
};
|
|
153
|
-
if (inputSpec?.companyWebsite) {
|
|
154
|
-
agentConfig.generationInfo.defaultInfo.companyWebsite = inputSpec?.companyWebsite;
|
|
155
|
-
}
|
|
156
|
-
if (!flags.preview) {
|
|
157
|
-
agentConfig.saveAgent = true;
|
|
158
|
-
agentConfig.agentSettings = {
|
|
159
|
-
agentName: agentName,
|
|
160
|
-
};
|
|
161
|
-
if (flags['agent-api-name']) {
|
|
162
|
-
agentConfig.agentSettings.agentApiName = flags['agent-api-name'];
|
|
163
|
-
}
|
|
164
|
-
if (flags['planner-id']) {
|
|
165
|
-
agentConfig.agentSettings.plannerId = flags['planner-id'];
|
|
166
|
-
}
|
|
167
|
-
if (flags['user-id']) {
|
|
168
|
-
agentConfig.agentSettings.userId = userId;
|
|
169
|
-
}
|
|
170
|
-
agentConfig.agentSettings.enrichLogs = Boolean(enrichLogs);
|
|
171
|
-
agentConfig.agentSettings.tone = tone;
|
|
172
|
-
}
|
|
173
|
-
const response = await agent.createV2(agentConfig);
|
|
174
|
-
mso.stop();
|
|
175
|
-
if (response.isSuccess) {
|
|
176
|
-
if (!flags.preview) {
|
|
177
|
-
this.log(colorize('green', `Successfully created ${agentName} in ${flags['target-org'].getUsername() ?? 'the target org'}.`));
|
|
178
|
-
this.log(`Use ${colorize('dim', `sf org open agent --name ${agentName}`)} to view the agent in the browser.`);
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
const previewFileName = `agentPreview_${new Date().toISOString()}.json`;
|
|
182
|
-
writeFileSync(previewFileName, JSON.stringify(response, null, 2));
|
|
183
|
-
this.log(colorize('green', `Successfully created agent for preview. See ${previewFileName}`));
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
this.log(colorize('red', `failed to create agent: ${response.errorMessage ?? ''}`));
|
|
188
|
-
}
|
|
189
|
-
return response;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
// The spec must define: agentType, role, companyName, companyDescription, and topics.
|
|
193
|
-
// Agent type must be 'customer' or 'internal'.
|
|
194
|
-
const validateSpec = (spec) => {
|
|
195
|
-
const requiredSpecValues = [
|
|
196
|
-
'agentType',
|
|
197
|
-
'role',
|
|
198
|
-
'companyName',
|
|
199
|
-
'companyDescription',
|
|
200
|
-
'topics',
|
|
201
|
-
];
|
|
202
|
-
const missingFlags = requiredSpecValues.filter((f) => !spec[f]);
|
|
203
|
-
if (missingFlags.length) {
|
|
204
|
-
throw messages.createError('error.missingRequiredFlags', [missingFlags.join(', ')]);
|
|
205
|
-
}
|
|
206
|
-
validateAgentType(spec.agentType, true);
|
|
207
|
-
};
|
|
208
|
-
//# sourceMappingURL=create-v2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-v2.js","sourceRoot":"","sources":["../../../src/commands/agent/create-v2.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAA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AAC,CAAC;gBAClE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE,+CAA+C,eAAe,EAAE,CAAC,CAAC,CAAC;YAChG,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,2BAA2B,QAAQ,CAAC,YAAY,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;QACtF,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;;AAGH,sFAAsF;AACtF,+CAA+C;AAC/C,MAAM,YAAY,GAAG,CAAC,IAA6B,EAAQ,EAAE;IAC3D,MAAM,kBAAkB,GAAkF;QACxG,WAAW;QACX,MAAM;QACN,aAAa;QACb,oBAAoB;QACpB,QAAQ;KACT,CAAC;IACF,MAAM,YAAY,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAChE,IAAI,YAAY,CAAC,MAAM,EAAE,CAAC;QACxB,MAAM,QAAQ,CAAC,WAAW,CAAC,4BAA4B,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtF,CAAC;IAED,iBAAiB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAC1C,CAAC,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
-
import { AgentJobSpecV2 } from '@salesforce/agents';
|
|
3
|
-
export type AgentCreateSpecResult = {
|
|
4
|
-
isSuccess: boolean;
|
|
5
|
-
errorMessage?: string;
|
|
6
|
-
specPath?: string;
|
|
7
|
-
} & AgentJobSpecV2;
|
|
8
|
-
export default class AgentCreateSpecV2 extends SfCommand<AgentCreateSpecResult> {
|
|
9
|
-
static readonly summary: string;
|
|
10
|
-
static readonly description: string;
|
|
11
|
-
static readonly examples: string[];
|
|
12
|
-
static state: string;
|
|
13
|
-
static readonly requiresProject = true;
|
|
14
|
-
static readonly flags: {
|
|
15
|
-
spec: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
-
'output-file': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
-
'max-topics': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
-
'prompt-template': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
-
'grounding-context': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
-
type: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
-
role: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
-
"company-name": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
|
-
"company-description": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
|
-
"company-website": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
|
-
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
|
-
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
|
-
};
|
|
28
|
-
run(): Promise<AgentCreateSpecResult>;
|
|
29
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2024, salesforce.com, inc.
|
|
3
|
-
* All rights reserved.
|
|
4
|
-
* Licensed under the BSD 3-Clause license.
|
|
5
|
-
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
-
*/
|
|
7
|
-
import { join, resolve, dirname } from 'node:path';
|
|
8
|
-
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
9
|
-
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
10
|
-
import { Messages } from '@salesforce/core';
|
|
11
|
-
import YAML from 'yaml';
|
|
12
|
-
import { Agent } from '@salesforce/agents';
|
|
13
|
-
import { FLAGGABLE_SPEC_PROMPTS, makeFlags, promptForFlag, validateAgentType, validateMaxTopics, } from '../../../flags.js';
|
|
14
|
-
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
15
|
-
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.generate.spec-v2');
|
|
16
|
-
export default class AgentCreateSpecV2 extends SfCommand {
|
|
17
|
-
static summary = messages.getMessage('summary');
|
|
18
|
-
static description = messages.getMessage('description');
|
|
19
|
-
static examples = messages.getMessages('examples');
|
|
20
|
-
static state = 'beta';
|
|
21
|
-
static requiresProject = true;
|
|
22
|
-
static flags = {
|
|
23
|
-
'target-org': Flags.requiredOrg(),
|
|
24
|
-
'api-version': Flags.orgApiVersion(),
|
|
25
|
-
...makeFlags(FLAGGABLE_SPEC_PROMPTS),
|
|
26
|
-
spec: Flags.file({
|
|
27
|
-
summary: messages.getMessage('flags.spec.summary'),
|
|
28
|
-
exists: true,
|
|
29
|
-
}),
|
|
30
|
-
'output-file': Flags.file({
|
|
31
|
-
summary: messages.getMessage('flags.output-file.summary'),
|
|
32
|
-
default: join('config', 'agentSpec.yaml'),
|
|
33
|
-
}),
|
|
34
|
-
'max-topics': Flags.integer({
|
|
35
|
-
summary: messages.getMessage('flags.max-topics.summary'),
|
|
36
|
-
min: 1,
|
|
37
|
-
}),
|
|
38
|
-
'prompt-template': Flags.string({
|
|
39
|
-
summary: messages.getMessage('flags.prompt-template.summary'),
|
|
40
|
-
}),
|
|
41
|
-
'grounding-context': Flags.string({
|
|
42
|
-
summary: messages.getMessage('flags.grounding-context.summary'),
|
|
43
|
-
dependsOn: ['prompt-template'],
|
|
44
|
-
}),
|
|
45
|
-
};
|
|
46
|
-
// eslint-disable-next-line complexity
|
|
47
|
-
async run() {
|
|
48
|
-
const { flags } = await this.parse(AgentCreateSpecV2);
|
|
49
|
-
// throw error if --json is used and not all required flags are provided
|
|
50
|
-
if (this.jsonEnabled()) {
|
|
51
|
-
const missingFlags = Object.entries(FLAGGABLE_SPEC_PROMPTS)
|
|
52
|
-
.filter(([key, prompt]) => 'required' in prompt && prompt.required && !(key in flags))
|
|
53
|
-
.map(([key]) => key);
|
|
54
|
-
if (missingFlags.length) {
|
|
55
|
-
throw messages.createError('error.missingRequiredFlags', [missingFlags.join(', ')]);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
this.log();
|
|
59
|
-
this.styledHeader('Agent Details');
|
|
60
|
-
// If spec is provided, read it first
|
|
61
|
-
let inputSpec = {};
|
|
62
|
-
if (flags.spec) {
|
|
63
|
-
inputSpec = YAML.parse(readFileSync(resolve(flags.spec), 'utf8'));
|
|
64
|
-
}
|
|
65
|
-
// Flags override inputSpec values. Prompt if neither is set.
|
|
66
|
-
const type = flags.type ?? validateAgentType(inputSpec?.agentType) ?? (await promptForFlag(FLAGGABLE_SPEC_PROMPTS.type));
|
|
67
|
-
const role = flags.role ?? inputSpec?.role ?? (await promptForFlag(FLAGGABLE_SPEC_PROMPTS.role));
|
|
68
|
-
const companyName = flags['company-name'] ?? inputSpec?.companyName ?? (await promptForFlag(FLAGGABLE_SPEC_PROMPTS['company-name']));
|
|
69
|
-
const companyDescription = flags['company-description'] ??
|
|
70
|
-
inputSpec?.companyDescription ??
|
|
71
|
-
(await promptForFlag(FLAGGABLE_SPEC_PROMPTS['company-description']));
|
|
72
|
-
const companyWebsite = flags['company-website'] ??
|
|
73
|
-
inputSpec?.companyWebsite ??
|
|
74
|
-
(await promptForFlag(FLAGGABLE_SPEC_PROMPTS['company-website']));
|
|
75
|
-
this.log();
|
|
76
|
-
this.spinner.start('Creating agent spec');
|
|
77
|
-
const connection = flags['target-org'].getConnection(flags['api-version']);
|
|
78
|
-
const agent = new Agent(connection, this.project);
|
|
79
|
-
const specConfig = {
|
|
80
|
-
agentType: type,
|
|
81
|
-
role,
|
|
82
|
-
companyName,
|
|
83
|
-
companyDescription,
|
|
84
|
-
};
|
|
85
|
-
if (companyWebsite) {
|
|
86
|
-
specConfig.companyWebsite = companyWebsite;
|
|
87
|
-
}
|
|
88
|
-
const promptTemplateName = flags['prompt-template'] ?? inputSpec?.promptTemplateName;
|
|
89
|
-
if (promptTemplateName) {
|
|
90
|
-
specConfig.promptTemplateName = promptTemplateName;
|
|
91
|
-
const groundingContext = flags['grounding-context'] ?? inputSpec?.groundingContext;
|
|
92
|
-
if (groundingContext) {
|
|
93
|
-
specConfig.groundingContext = groundingContext;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
const maxNumOfTopics = flags['max-topics'] ?? validateMaxTopics(inputSpec?.maxNumOfTopics);
|
|
97
|
-
if (maxNumOfTopics) {
|
|
98
|
-
specConfig.maxNumOfTopics = maxNumOfTopics;
|
|
99
|
-
}
|
|
100
|
-
// Should we log the specConfig being used? It's returned in the JSON and the generated spec.
|
|
101
|
-
// this.log(`${ansis.green(figures.tick)} ${ansis.bold(message)} ${ansis.cyan(valueFromFlag)}`);
|
|
102
|
-
const agentSpec = await agent.createSpecV2(specConfig);
|
|
103
|
-
const outputFilePath = writeSpecFile(flags['output-file'], agentSpec);
|
|
104
|
-
this.spinner.stop();
|
|
105
|
-
this.log(`\nSaved agent spec: ${outputFilePath}`);
|
|
106
|
-
return { ...{ isSuccess: true, specPath: outputFilePath }, ...agentSpec };
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
const writeSpecFile = (outputFile, agentSpec) => {
|
|
110
|
-
// create the directory if not already created
|
|
111
|
-
const outputFilePath = resolve(outputFile);
|
|
112
|
-
mkdirSync(dirname(outputFilePath), { recursive: true });
|
|
113
|
-
// Write a yaml file with the returned job specs
|
|
114
|
-
writeFileSync(outputFilePath, YAML.stringify(agentSpec));
|
|
115
|
-
return outputFilePath;
|
|
116
|
-
};
|
|
117
|
-
//# sourceMappingURL=spec-v2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spec-v2.js","sourceRoot":"","sources":["../../../../src/commands/agent/generate/spec-v2.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,KAAK,EAA8C,MAAM,oBAAoB,CAAC;AACvF,OAAO,EACL,sBAAsB,EACtB,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAE3B,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,0BAA0B,EAAE,wBAAwB,CAAC,CAAC;AAQ7F,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,SAAgC;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,CAAC,CAAC;IAC5D,MAAM,CAAC,KAAK,GAAG,MAAM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AC9F,gGAAgG;QAChG,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAEvD,MAAM,cAAc,GAAG,aAAa,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,SAAS,CAAC,CAAC;QAEtE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAEpB,IAAI,CAAC,GAAG,CAAC,uBAAuB,cAAc,EAAE,CAAC,CAAC;QAElD,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,EAAE,GAAG,SAAS,EAAE,CAAC;IAC5E,CAAC;;AAGH,MAAM,aAAa,GAAG,CAAC,UAAkB,EAAE,SAAyB,EAAU,EAAE;IAC9E,8CAA8C;IAC9C,MAAM,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC3C,SAAS,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAExD,gDAAgD;IAChD,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;IAEzD,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# summary
|
|
2
|
-
|
|
3
|
-
Create an agent in your org using a local agent spec file.
|
|
4
|
-
|
|
5
|
-
# description
|
|
6
|
-
|
|
7
|
-
Before you run this command, you must first generate an agent spec file by running the "agent generate spec" CLI command, which outputs a YAML file with the agent properties and list of AI-generated topics. Topics define the range of jobs the agent can handle. Then specify the generated agent spec file to this command using the --spec flag, along with the name (label) of the new agent using the --agent-name flag.
|
|
8
|
-
|
|
9
|
-
When this command finishes, your org contains the new agent, which you can then edit in the Agent Builder UI. The new agent's topics are the same as the ones listed in the agent spec file. The agent might also have some AI-generated actions. This command also retrieves all the metadata files associated with the new agent to your local Salesforce DX project.
|
|
10
|
-
|
|
11
|
-
Use the --preview flag to review what the agent looks like without actually saving it in your org. Rather, the command creates a JSON file with all the agent details in the current directory.
|
|
12
|
-
|
|
13
|
-
To open the new agent in your org's Agent Builder UI, run this command: "sf org open agent --name <api-name-of-your-agent>".
|
|
14
|
-
|
|
15
|
-
# flags.spec.summary
|
|
16
|
-
|
|
17
|
-
Path to an agent spec file.
|
|
18
|
-
|
|
19
|
-
# flags.preview.summary
|
|
20
|
-
|
|
21
|
-
Preview the agent without saving it in your org.
|
|
22
|
-
|
|
23
|
-
# flags.agent-name.summary
|
|
24
|
-
|
|
25
|
-
Name (label) of the new agent.
|
|
26
|
-
|
|
27
|
-
# flags.agent-api-name.summary
|
|
28
|
-
|
|
29
|
-
API name of the new agent; if not specified, the API name is derived from the agent name (label); the API name must not exist in the org.
|
|
30
|
-
|
|
31
|
-
# flags.user-id.summary
|
|
32
|
-
|
|
33
|
-
ID of a user in your org that is assigned to your agent; determines what your agent can access and do.
|
|
34
|
-
|
|
35
|
-
# flags.enrich-logs.summary
|
|
36
|
-
|
|
37
|
-
Adds agent conversation data to event logs so you can view all agent session activity in one place.
|
|
38
|
-
|
|
39
|
-
# flags.tone.summary
|
|
40
|
-
|
|
41
|
-
Conversational style of the agent, such as how it expresses your brand personality in its messages through word choice, punctuation, and sentence structure.
|
|
42
|
-
|
|
43
|
-
# flags.primary-language.summary
|
|
44
|
-
|
|
45
|
-
Language the agent uses in conversations.
|
|
46
|
-
|
|
47
|
-
# flags.planner-id.summary
|
|
48
|
-
|
|
49
|
-
The GenAiPlanner ID to associate with the agent.
|
|
50
|
-
|
|
51
|
-
# error.missingRequiredFlags
|
|
52
|
-
|
|
53
|
-
Missing required flags: %s
|
|
54
|
-
|
|
55
|
-
# examples
|
|
56
|
-
|
|
57
|
-
- Create an agent called "ResortManager" in an org with alias "my-org" using the specified agent spec file:
|
|
58
|
-
|
|
59
|
-
<%= config.bin %> <%= command.id %> --agent-name ResortManager --spec specs/resortManagerAgent.yaml --target-org my-org
|
|
60
|
-
|
|
61
|
-
- Preview the creation of an agent called "ResortManager" and use your default org:
|
|
62
|
-
|
|
63
|
-
<%= config.bin %> <%= command.id %> --agent-name ResortManager --spec specs/resortManagerAgent.yaml --preview
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# summary
|
|
2
|
-
|
|
3
|
-
Generate an agent spec, which is a YAML file that captures what an agent can do.
|
|
4
|
-
|
|
5
|
-
# description
|
|
6
|
-
|
|
7
|
-
Before you use Salesforce CLI to create an agent in your org, you must first generate an agent spec with this command. An agent spec is a YAML-formatted file that contains information about the agent, such as its role and company description, and then an AI-generated list of topics based on this information. Topics define the range of jobs your agent can handle.
|
|
8
|
-
|
|
9
|
-
Use flags, such as --role and --company-description, to provide details about your company and the role that the agent plays in your company. If you prefer, you can also be prompted for the information. Upon command execution, the large language model (LLM) associated with your org uses the information you provided to generate a list of topics for the agent. Because the LLM uses the company and role information to generate the topics, we recommend that you provide accurate and specific details so the LLM generates the best and most relevant topics. Once generated, you can edit the spec file; for example, you can remove topics that don't apply to your agent or change the description of a particular topic.
|
|
10
|
-
|
|
11
|
-
You can iterate the spec generation process by using the --spec flag to pass an existing agent spec file to this command, and then using the --role, --company-description, etc, flags to refine your agent properties. Iteratively improving the description of your agent allows the LLM to generate progressively better topics.
|
|
12
|
-
|
|
13
|
-
You can also specify a custom prompt template that the agent uses, and ground the prompt template to add context and personalization to the agent's prompts.
|
|
14
|
-
|
|
15
|
-
When your agent spec is ready, you then create the agent in your org by running the "agent create" CLI command and specifying the spec with the --spec flag.
|
|
16
|
-
|
|
17
|
-
# flags.output-file.summary
|
|
18
|
-
|
|
19
|
-
Path for the generated YAML agent spec file; can be an absolute or relative path.
|
|
20
|
-
|
|
21
|
-
# flags.max-topics.summary
|
|
22
|
-
|
|
23
|
-
Maximum number of topics to generate in the agent spec; default is 10.
|
|
24
|
-
|
|
25
|
-
# flags.prompt-template.summary
|
|
26
|
-
|
|
27
|
-
API name of a customized prompt template to use instead of the default prompt template.
|
|
28
|
-
|
|
29
|
-
# flags.grounding-context.summary
|
|
30
|
-
|
|
31
|
-
Context information and personalization that's added to your prompts when using a custom prompt template.
|
|
32
|
-
|
|
33
|
-
# flags.spec.summary
|
|
34
|
-
|
|
35
|
-
Agent spec file, in YAML format, to use as input to the command.
|
|
36
|
-
|
|
37
|
-
# examples
|
|
38
|
-
|
|
39
|
-
- Generate an agent spec in the default location and use flags to specify the agent properties, such as its role and your company details; use your default org:
|
|
40
|
-
|
|
41
|
-
<%= config.bin %> <%= command.id %> --type customer --role "Field customer complaints and manage employee schedules." --company-name "Coral Cloud Resorts" --company-description "Provide customers with exceptional destination activities, unforgettable experiences, and reservation services."
|
|
42
|
-
|
|
43
|
-
- Generate an agent spec by being prompted for the required agent properties and generate a maxiumum of 5 topics; write the generated file to the "specs/resortManagerSpec.yaml" file and use the org with alias "my-org":
|
|
44
|
-
|
|
45
|
-
<%= config.bin %> <%= command.id %> --max-topics 5 --output-file specs/resortManagerAgent.yaml --target-org my-org
|
|
46
|
-
|
|
47
|
-
- Specify an existing agent spec file called "specs/resortManagerAgent.yaml", and then overwrite it with a new version that contains newly AI-generated topics based on the updated role information passed in with the --role flag:
|
|
48
|
-
|
|
49
|
-
<%= config.bin %> <%= command.id %> --spec specs/resortManagerAgent.yaml --output-file specs/resortManagerAgent.yaml --role "Field customer complaints, manage employee schedules, and ensure all resort operations are running smoothly" --target-org my-org
|
|
50
|
-
|
|
51
|
-
# error.missingRequiredFlags
|
|
52
|
-
|
|
53
|
-
Missing required flags: %s
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$ref": "#/definitions/AgentCreateResult",
|
|
4
|
-
"definitions": {
|
|
5
|
-
"AgentCreateResult": {
|
|
6
|
-
"type": "object",
|
|
7
|
-
"properties": {
|
|
8
|
-
"isSuccess": {
|
|
9
|
-
"type": "boolean"
|
|
10
|
-
},
|
|
11
|
-
"errorMessage": {
|
|
12
|
-
"type": "string"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"required": [
|
|
16
|
-
"isSuccess"
|
|
17
|
-
],
|
|
18
|
-
"additionalProperties": false
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$ref": "#/definitions/AgentCreateSpecResult",
|
|
4
|
-
"definitions": {
|
|
5
|
-
"AgentCreateSpecResult": {
|
|
6
|
-
"type": "object",
|
|
7
|
-
"additionalProperties": false,
|
|
8
|
-
"properties": {
|
|
9
|
-
"topics": {
|
|
10
|
-
"$ref": "#/definitions/DraftAgentTopics"
|
|
11
|
-
},
|
|
12
|
-
"agentType": {
|
|
13
|
-
"type": "string",
|
|
14
|
-
"enum": [
|
|
15
|
-
"customer",
|
|
16
|
-
"internal"
|
|
17
|
-
],
|
|
18
|
-
"description": "Internal type is copilots; used by customers' employees. Customer type is agents; used by customers' customers."
|
|
19
|
-
},
|
|
20
|
-
"role": {
|
|
21
|
-
"type": "string"
|
|
22
|
-
},
|
|
23
|
-
"companyName": {
|
|
24
|
-
"type": "string"
|
|
25
|
-
},
|
|
26
|
-
"companyDescription": {
|
|
27
|
-
"type": "string"
|
|
28
|
-
},
|
|
29
|
-
"companyWebsite": {
|
|
30
|
-
"type": "string"
|
|
31
|
-
},
|
|
32
|
-
"maxNumOfTopics": {
|
|
33
|
-
"type": "number",
|
|
34
|
-
"description": "The maximum number of topics to create in the spec. Default is 10."
|
|
35
|
-
},
|
|
36
|
-
"promptTemplateName": {
|
|
37
|
-
"type": "string",
|
|
38
|
-
"description": "Developer name of the prompt template."
|
|
39
|
-
},
|
|
40
|
-
"groundingContext": {
|
|
41
|
-
"type": "string",
|
|
42
|
-
"description": "Context info to be used in customized prompt template"
|
|
43
|
-
},
|
|
44
|
-
"isSuccess": {
|
|
45
|
-
"type": "boolean"
|
|
46
|
-
},
|
|
47
|
-
"errorMessage": {
|
|
48
|
-
"type": "string"
|
|
49
|
-
},
|
|
50
|
-
"specPath": {
|
|
51
|
-
"type": "string"
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
"required": [
|
|
55
|
-
"agentType",
|
|
56
|
-
"companyDescription",
|
|
57
|
-
"companyName",
|
|
58
|
-
"isSuccess",
|
|
59
|
-
"role",
|
|
60
|
-
"topics"
|
|
61
|
-
]
|
|
62
|
-
},
|
|
63
|
-
"DraftAgentTopics": {
|
|
64
|
-
"type": "array",
|
|
65
|
-
"items": {
|
|
66
|
-
"type": "object",
|
|
67
|
-
"properties": {
|
|
68
|
-
"name": {
|
|
69
|
-
"type": "string"
|
|
70
|
-
},
|
|
71
|
-
"description": {
|
|
72
|
-
"type": "string"
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
"required": [
|
|
76
|
-
"name",
|
|
77
|
-
"description"
|
|
78
|
-
],
|
|
79
|
-
"additionalProperties": false
|
|
80
|
-
},
|
|
81
|
-
"minItems": 1,
|
|
82
|
-
"maxItems": 1
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|