@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,16 +1,67 @@
|
|
|
1
1
|
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
-
import {
|
|
2
|
+
import { AgentJobSpecV2 } from '@salesforce/agents';
|
|
3
3
|
export type AgentCreateSpecResult = {
|
|
4
4
|
isSuccess: boolean;
|
|
5
5
|
errorMessage?: string;
|
|
6
|
-
|
|
6
|
+
specPath?: string;
|
|
7
|
+
} & AgentJobSpecV2;
|
|
8
|
+
export type AgentSpecFileContents = AgentJobSpecV2 & {
|
|
9
|
+
agentUser?: string;
|
|
10
|
+
enrichLogs?: boolean;
|
|
11
|
+
tone?: 'casual' | 'formal' | 'neutral';
|
|
12
|
+
primaryLanguage?: 'en_US';
|
|
7
13
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
export declare const FLAGGABLE_PROMPTS: {
|
|
15
|
+
type: {
|
|
16
|
+
message: string;
|
|
17
|
+
validate: (d: string) => boolean | string;
|
|
18
|
+
char: "t";
|
|
19
|
+
options: string[];
|
|
20
|
+
required: true;
|
|
21
|
+
};
|
|
22
|
+
role: {
|
|
23
|
+
message: string;
|
|
24
|
+
validate: (d: string) => boolean | string;
|
|
25
|
+
required: true;
|
|
26
|
+
};
|
|
27
|
+
'company-name': {
|
|
28
|
+
message: string;
|
|
29
|
+
validate: (d: string) => boolean | string;
|
|
30
|
+
required: true;
|
|
31
|
+
};
|
|
32
|
+
'company-description': {
|
|
33
|
+
message: string;
|
|
34
|
+
validate: (d: string) => boolean | string;
|
|
35
|
+
required: true;
|
|
36
|
+
};
|
|
37
|
+
'company-website': {
|
|
38
|
+
message: string;
|
|
39
|
+
validate: (d: string) => boolean | string;
|
|
40
|
+
};
|
|
41
|
+
'max-topics': {
|
|
42
|
+
message: string;
|
|
43
|
+
promptMessage: string;
|
|
44
|
+
validate: () => boolean | string;
|
|
45
|
+
};
|
|
46
|
+
'agent-user': {
|
|
47
|
+
message: string;
|
|
48
|
+
promptMessage: string;
|
|
49
|
+
validate: () => boolean | string;
|
|
50
|
+
};
|
|
51
|
+
'enrich-logs': {
|
|
52
|
+
message: string;
|
|
53
|
+
promptMessage: string;
|
|
54
|
+
validate: () => boolean | string;
|
|
55
|
+
options: string[];
|
|
56
|
+
default: string;
|
|
57
|
+
};
|
|
58
|
+
tone: {
|
|
59
|
+
message: string;
|
|
60
|
+
promptMessage: string;
|
|
61
|
+
validate: () => boolean | string;
|
|
62
|
+
options: string[];
|
|
63
|
+
default: string;
|
|
64
|
+
};
|
|
14
65
|
};
|
|
15
66
|
export default class AgentCreateSpec extends SfCommand<AgentCreateSpecResult> {
|
|
16
67
|
static readonly summary: string;
|
|
@@ -19,24 +70,23 @@ export default class AgentCreateSpec extends SfCommand<AgentCreateSpecResult> {
|
|
|
19
70
|
static state: string;
|
|
20
71
|
static readonly requiresProject = true;
|
|
21
72
|
static readonly flags: {
|
|
22
|
-
|
|
23
|
-
'file
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
73
|
+
spec: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
74
|
+
'output-file': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
75
|
+
'full-interview': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
76
|
+
'prompt-template': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
77
|
+
'grounding-context': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
78
|
+
'no-prompt': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
79
|
+
type: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
80
|
+
role: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
81
|
+
"company-name": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
82
|
+
"company-description": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
83
|
+
"company-website": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
84
|
+
"max-topics": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
85
|
+
"agent-user": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
86
|
+
"enrich-logs": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
87
|
+
tone: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
88
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
89
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
31
90
|
};
|
|
32
91
|
run(): Promise<AgentCreateSpecResult>;
|
|
33
|
-
/**
|
|
34
|
-
* Get a flag value or prompt the user for a value.
|
|
35
|
-
*
|
|
36
|
-
* Resolution order:
|
|
37
|
-
* - Flag value provided by the user
|
|
38
|
-
* - Prompt the user for a value
|
|
39
|
-
*/
|
|
40
|
-
getFlagOrPrompt(valueFromFlag: string | undefined, flagDef: FlaggablePrompt): Promise<string>;
|
|
41
92
|
}
|
|
42
|
-
export {};
|
|
@@ -4,18 +4,16 @@
|
|
|
4
4
|
* Licensed under the BSD 3-Clause license.
|
|
5
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
6
|
*/
|
|
7
|
-
import { join } from 'node:path';
|
|
8
|
-
import { writeFileSync } from 'node:fs';
|
|
9
|
-
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
7
|
+
import { join, resolve, dirname } from 'node:path';
|
|
8
|
+
import { mkdirSync, readFileSync, writeFileSync, existsSync } from 'node:fs';
|
|
9
|
+
import { SfCommand, Flags, prompts } from '@salesforce/sf-plugins-core';
|
|
10
10
|
import { Messages } from '@salesforce/core';
|
|
11
|
-
import
|
|
12
|
-
import { select, input as inquirerInput } from '@inquirer/prompts';
|
|
13
|
-
import figures from '@inquirer/figures';
|
|
11
|
+
import YAML from 'yaml';
|
|
14
12
|
import { Agent } from '@salesforce/agents';
|
|
15
|
-
import {
|
|
13
|
+
import { makeFlags, promptForFlag, validateAgentType, validateMaxTopics } from '../../../flags.js';
|
|
16
14
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
17
15
|
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.generate.spec');
|
|
18
|
-
const FLAGGABLE_PROMPTS = {
|
|
16
|
+
export const FLAGGABLE_PROMPTS = {
|
|
19
17
|
type: {
|
|
20
18
|
message: messages.getMessage('flags.type.summary'),
|
|
21
19
|
validate: (d) => d.length > 0 || 'Type cannot be empty',
|
|
@@ -45,7 +43,10 @@ const FLAGGABLE_PROMPTS = {
|
|
|
45
43
|
if (d.length === 0)
|
|
46
44
|
return true;
|
|
47
45
|
try {
|
|
48
|
-
new
|
|
46
|
+
const regExp = new RegExp('^(http|https)://', 'i');
|
|
47
|
+
const companySite = regExp.test(d) ? d : `https://${d}`;
|
|
48
|
+
new URL(companySite);
|
|
49
|
+
d = companySite;
|
|
49
50
|
return true;
|
|
50
51
|
}
|
|
51
52
|
catch (e) {
|
|
@@ -53,28 +54,39 @@ const FLAGGABLE_PROMPTS = {
|
|
|
53
54
|
}
|
|
54
55
|
},
|
|
55
56
|
},
|
|
57
|
+
'max-topics': {
|
|
58
|
+
message: messages.getMessage('flags.max-topics.summary'),
|
|
59
|
+
promptMessage: messages.getMessage('flags.max-topics.prompt'),
|
|
60
|
+
validate: () => true,
|
|
61
|
+
// min: 1,
|
|
62
|
+
// max: 30,
|
|
63
|
+
},
|
|
64
|
+
'agent-user': {
|
|
65
|
+
message: messages.getMessage('flags.agent-user.summary'),
|
|
66
|
+
promptMessage: messages.getMessage('flags.agent-user.prompt'),
|
|
67
|
+
validate: () => true,
|
|
68
|
+
},
|
|
69
|
+
'enrich-logs': {
|
|
70
|
+
message: messages.getMessage('flags.enrich-logs.summary'),
|
|
71
|
+
promptMessage: messages.getMessage('flags.enrich-logs.prompt'),
|
|
72
|
+
validate: () => true,
|
|
73
|
+
options: ['true', 'false'],
|
|
74
|
+
default: 'false',
|
|
75
|
+
},
|
|
76
|
+
tone: {
|
|
77
|
+
message: messages.getMessage('flags.tone.summary'),
|
|
78
|
+
promptMessage: messages.getMessage('flags.tone.prompt'),
|
|
79
|
+
validate: () => true,
|
|
80
|
+
options: ['formal', 'casual', 'neutral'],
|
|
81
|
+
default: 'casual',
|
|
82
|
+
},
|
|
83
|
+
// 'primary-language': {
|
|
84
|
+
// message: messages.getMessage('flags.primary-language.summary'),
|
|
85
|
+
// validate: (): boolean | string => true,
|
|
86
|
+
// options: ['en_US'],
|
|
87
|
+
// default: 'en_US',
|
|
88
|
+
// },
|
|
56
89
|
};
|
|
57
|
-
function validateInput(input, validate) {
|
|
58
|
-
const result = validate(input);
|
|
59
|
-
if (typeof result === 'string')
|
|
60
|
-
throw new Error(result);
|
|
61
|
-
return input;
|
|
62
|
-
}
|
|
63
|
-
function makeFlags(flaggablePrompts) {
|
|
64
|
-
return Object.fromEntries(Object.entries(flaggablePrompts).map(([key, value]) => [
|
|
65
|
-
key,
|
|
66
|
-
Flags.string({
|
|
67
|
-
summary: value.message,
|
|
68
|
-
options: value.options,
|
|
69
|
-
char: value.char,
|
|
70
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
71
|
-
async parse(input) {
|
|
72
|
-
return validateInput(input, value.validate);
|
|
73
|
-
},
|
|
74
|
-
// NOTE: we purposely omit the required property here because we want to allow the flag to be missing in interactive mode
|
|
75
|
-
}),
|
|
76
|
-
]));
|
|
77
|
-
}
|
|
78
90
|
export default class AgentCreateSpec extends SfCommand {
|
|
79
91
|
static summary = messages.getMessage('summary');
|
|
80
92
|
static description = messages.getMessage('description');
|
|
@@ -85,83 +97,172 @@ export default class AgentCreateSpec extends SfCommand {
|
|
|
85
97
|
'target-org': Flags.requiredOrg(),
|
|
86
98
|
'api-version': Flags.orgApiVersion(),
|
|
87
99
|
...makeFlags(FLAGGABLE_PROMPTS),
|
|
88
|
-
|
|
89
|
-
|
|
100
|
+
// a spec file can be used as input. Allows iterative spec development.
|
|
101
|
+
spec: Flags.file({
|
|
102
|
+
summary: messages.getMessage('flags.spec.summary'),
|
|
90
103
|
exists: true,
|
|
91
|
-
summary: messages.getMessage('flags.output-dir.summary'),
|
|
92
|
-
default: 'config',
|
|
93
104
|
}),
|
|
94
|
-
'file
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
105
|
+
'output-file': Flags.file({
|
|
106
|
+
summary: messages.getMessage('flags.output-file.summary'),
|
|
107
|
+
default: join('config', 'agentSpec.yaml'),
|
|
108
|
+
}),
|
|
109
|
+
'full-interview': Flags.boolean({
|
|
110
|
+
summary: messages.getMessage('flags.full-interview.summary'),
|
|
111
|
+
}),
|
|
112
|
+
'prompt-template': Flags.string({
|
|
113
|
+
summary: messages.getMessage('flags.prompt-template.summary'),
|
|
114
|
+
}),
|
|
115
|
+
'grounding-context': Flags.string({
|
|
116
|
+
summary: messages.getMessage('flags.grounding-context.summary'),
|
|
117
|
+
dependsOn: ['prompt-template'],
|
|
118
|
+
}),
|
|
119
|
+
'no-prompt': Flags.boolean({
|
|
120
|
+
summary: messages.getMessage('flags.no-prompt.summary'),
|
|
98
121
|
}),
|
|
99
122
|
};
|
|
123
|
+
// eslint-disable-next-line complexity
|
|
100
124
|
async run() {
|
|
101
125
|
const { flags } = await this.parse(AgentCreateSpec);
|
|
126
|
+
let outputFile;
|
|
127
|
+
try {
|
|
128
|
+
outputFile = await resolveOutputFile(flags['output-file'], flags['no-prompt']);
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
this.log(messages.getMessage('commandCanceled'));
|
|
132
|
+
// @ts-expect-error expected due to command cancelation.
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
102
135
|
// throw error if --json is used and not all required flags are provided
|
|
103
136
|
if (this.jsonEnabled()) {
|
|
104
137
|
const missingFlags = Object.entries(FLAGGABLE_PROMPTS)
|
|
105
138
|
.filter(([key, prompt]) => 'required' in prompt && prompt.required && !(key in flags))
|
|
106
139
|
.map(([key]) => key);
|
|
107
140
|
if (missingFlags.length) {
|
|
108
|
-
throw
|
|
141
|
+
throw messages.createError('error.missingRequiredFlags', [missingFlags.join(', ')]);
|
|
109
142
|
}
|
|
110
143
|
}
|
|
111
144
|
this.log();
|
|
112
145
|
this.styledHeader('Agent Details');
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
146
|
+
// If spec is provided, read it first
|
|
147
|
+
let inputSpec = {};
|
|
148
|
+
if (flags.spec) {
|
|
149
|
+
inputSpec = YAML.parse(readFileSync(resolve(flags.spec), 'utf8'));
|
|
150
|
+
}
|
|
151
|
+
// Flags override inputSpec values. Prompt if neither is set.
|
|
152
|
+
const type = flags.type ?? validateAgentType(inputSpec?.agentType) ?? (await promptForFlag(FLAGGABLE_PROMPTS.type));
|
|
153
|
+
const companyName = flags['company-name'] ?? inputSpec?.companyName ?? (await promptForFlag(FLAGGABLE_PROMPTS['company-name']));
|
|
154
|
+
const companyDescription = flags['company-description'] ??
|
|
155
|
+
inputSpec?.companyDescription ??
|
|
156
|
+
(await promptForFlag(FLAGGABLE_PROMPTS['company-description']));
|
|
157
|
+
const role = flags.role ?? inputSpec?.role ?? (await promptForFlag(FLAGGABLE_PROMPTS.role));
|
|
158
|
+
// full interview prompts
|
|
159
|
+
const companyWebsite = flags['company-website'] ??
|
|
160
|
+
inputSpec?.companyWebsite ??
|
|
161
|
+
(flags['full-interview'] ? await promptForFlag(FLAGGABLE_PROMPTS['company-website']) : undefined);
|
|
162
|
+
const maxNumOfTopics = flags['max-topics'] ??
|
|
163
|
+
validateMaxTopics(inputSpec?.maxNumOfTopics) ??
|
|
164
|
+
(flags['full-interview'] ? await promptForFlag(FLAGGABLE_PROMPTS['max-topics']) : 10);
|
|
165
|
+
const agentUser = flags['agent-user'] ??
|
|
166
|
+
inputSpec?.agentUser ??
|
|
167
|
+
(flags['full-interview'] ? await promptForFlag(FLAGGABLE_PROMPTS['agent-user']) : undefined);
|
|
168
|
+
let enrichLogs = flags['enrich-logs'] ??
|
|
169
|
+
inputSpec?.enrichLogs ??
|
|
170
|
+
(flags['full-interview'] ? await promptForFlag(FLAGGABLE_PROMPTS['enrich-logs']) : undefined);
|
|
171
|
+
enrichLogs = Boolean(enrichLogs === 'true' || enrichLogs === true);
|
|
172
|
+
const tone = flags.tone ??
|
|
173
|
+
inputSpec?.tone ??
|
|
174
|
+
(flags['full-interview'] ? await promptForFlag(FLAGGABLE_PROMPTS.tone) : undefined);
|
|
175
|
+
// const primaryLanguage =
|
|
176
|
+
// flags['primary-language'] ??
|
|
177
|
+
// inputSpec?.primaryLanguage ??
|
|
178
|
+
// (flags['full-interview'] ? await promptForFlag(FLAGGABLE_PROMPTS['primary-language']) : undefined);
|
|
118
179
|
this.log();
|
|
119
180
|
this.spinner.start('Creating agent spec');
|
|
120
181
|
const connection = flags['target-org'].getConnection(flags['api-version']);
|
|
121
182
|
const agent = new Agent(connection, this.project);
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
type,
|
|
125
|
-
role,
|
|
183
|
+
const specConfig = {
|
|
184
|
+
agentType: type,
|
|
126
185
|
companyName,
|
|
127
186
|
companyDescription,
|
|
128
|
-
|
|
129
|
-
});
|
|
130
|
-
// Write a file with the returned job specs
|
|
131
|
-
const filePath = join(flags['output-dir'], flags['file-name']);
|
|
132
|
-
writeFileSync(filePath, JSON.stringify({ type, role, companyName, companyDescription, companyWebsite, jobSpec: agentSpec }, null, 4));
|
|
133
|
-
this.spinner.stop();
|
|
134
|
-
this.log(`\nSaved agent spec: ${filePath}`);
|
|
135
|
-
return {
|
|
136
|
-
isSuccess: true,
|
|
137
|
-
jobSpec: filePath,
|
|
187
|
+
role,
|
|
138
188
|
};
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
* Get a flag value or prompt the user for a value.
|
|
142
|
-
*
|
|
143
|
-
* Resolution order:
|
|
144
|
-
* - Flag value provided by the user
|
|
145
|
-
* - Prompt the user for a value
|
|
146
|
-
*/
|
|
147
|
-
async getFlagOrPrompt(valueFromFlag, flagDef) {
|
|
148
|
-
const message = flagDef.message.replace(/\.$/, '');
|
|
149
|
-
if (valueFromFlag) {
|
|
150
|
-
this.log(`${ansis.green(figures.tick)} ${ansis.bold(message)} ${ansis.cyan(valueFromFlag)}`);
|
|
151
|
-
return valueFromFlag;
|
|
189
|
+
if (companyWebsite) {
|
|
190
|
+
specConfig.companyWebsite = companyWebsite;
|
|
152
191
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
192
|
+
const promptTemplateName = flags['prompt-template'] ?? inputSpec?.promptTemplateName;
|
|
193
|
+
if (promptTemplateName) {
|
|
194
|
+
specConfig.promptTemplateName = promptTemplateName;
|
|
195
|
+
const groundingContext = flags['grounding-context'] ?? inputSpec?.groundingContext;
|
|
196
|
+
if (groundingContext) {
|
|
197
|
+
specConfig.groundingContext = groundingContext;
|
|
198
|
+
}
|
|
159
199
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
});
|
|
200
|
+
if (maxNumOfTopics) {
|
|
201
|
+
specConfig.maxNumOfTopics = Number(maxNumOfTopics);
|
|
202
|
+
}
|
|
203
|
+
// Should we log the specConfig being used? It's returned in the JSON and the generated spec.
|
|
204
|
+
// this.log(`${ansis.green(figures.tick)} ${ansis.bold(message)} ${ansis.cyan(valueFromFlag)}`);
|
|
205
|
+
const specResponse = await agent.createSpecV2(specConfig);
|
|
206
|
+
// @ts-expect-error Need better typing
|
|
207
|
+
const specFileContents = buildSpecFile(specResponse, { agentUser, enrichLogs, tone });
|
|
208
|
+
const outputFilePath = writeSpecFile(outputFile, specFileContents);
|
|
209
|
+
this.spinner.stop();
|
|
210
|
+
this.log(`\nSaved agent spec: ${outputFilePath}`);
|
|
211
|
+
return { ...{ isSuccess: true, specPath: outputFilePath }, ...specResponse, ...specFileContents };
|
|
165
212
|
}
|
|
166
213
|
}
|
|
214
|
+
// Builds spec file contents from the spec response and any additional flags
|
|
215
|
+
// in a specific order.
|
|
216
|
+
const buildSpecFile = (specResponse, extraProps) => {
|
|
217
|
+
const propertyOrder = [
|
|
218
|
+
'agentType',
|
|
219
|
+
'companyName',
|
|
220
|
+
'companyDescription',
|
|
221
|
+
'companyWebsite',
|
|
222
|
+
'role',
|
|
223
|
+
'maxNumOfTopics',
|
|
224
|
+
'agentUser',
|
|
225
|
+
'enrichLogs',
|
|
226
|
+
'tone',
|
|
227
|
+
// 'primaryLanguage',
|
|
228
|
+
'promptTemplateName',
|
|
229
|
+
'groundingContext',
|
|
230
|
+
'topics',
|
|
231
|
+
];
|
|
232
|
+
const specFileContents = {};
|
|
233
|
+
propertyOrder.map((prop) => {
|
|
234
|
+
// @ts-expect-error need better typing of the array.
|
|
235
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
236
|
+
const val = specResponse[prop] ?? extraProps[prop];
|
|
237
|
+
if (val != null || (typeof val === 'string' && val.length > 0)) {
|
|
238
|
+
// @ts-expect-error need better typing of the array.
|
|
239
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
240
|
+
specFileContents[prop] = val;
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
return specFileContents;
|
|
244
|
+
};
|
|
245
|
+
const writeSpecFile = (outputFile, agentSpec) => {
|
|
246
|
+
// create the directory if not already created
|
|
247
|
+
const outputFilePath = resolve(outputFile);
|
|
248
|
+
mkdirSync(dirname(outputFilePath), { recursive: true });
|
|
249
|
+
// Write a yaml file with the returned job specs
|
|
250
|
+
writeFileSync(outputFilePath, YAML.stringify(agentSpec));
|
|
251
|
+
return outputFilePath;
|
|
252
|
+
};
|
|
253
|
+
const resolveOutputFile = async (outputFile, noPrompt = false) => {
|
|
254
|
+
let resolvedOutputFile = resolve(outputFile);
|
|
255
|
+
if (!noPrompt) {
|
|
256
|
+
if (existsSync(resolvedOutputFile)) {
|
|
257
|
+
const message = messages.getMessage('confirmSpecOverwrite', [resolvedOutputFile]);
|
|
258
|
+
if (!(await prompts.confirm({ message }))) {
|
|
259
|
+
throw Error('NoOverwrite');
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (!resolvedOutputFile.endsWith('.yaml')) {
|
|
264
|
+
resolvedOutputFile = `${resolvedOutputFile}.yaml`;
|
|
265
|
+
}
|
|
266
|
+
return resolvedOutputFile;
|
|
267
|
+
};
|
|
167
268
|
//# sourceMappingURL=spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../../../src/commands/agent/generate/spec.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../../../src/commands/agent/generate/spec.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,UAAU,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,KAAK,EAA8C,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAmB,SAAS,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEpH,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC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EAAE,CAAC;QACd,IAAI,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC;YACnC,MAAM,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,sBAAsB,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC;YAClF,IAAI,CAAC,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC;gBAC1C,MAAM,KAAK,CAAC,aAAa,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;IACH,CAAC;IACD,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC1C,kBAAkB,GAAG,GAAG,kBAAkB,OAAO,CAAC;IACpD,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC,CAAC"}
|
package/lib/flags.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export type FlaggablePrompt = {
|
|
|
6
6
|
char?: Interfaces.AlphabetLowercase | Interfaces.AlphabetUppercase;
|
|
7
7
|
required?: boolean;
|
|
8
8
|
default?: string | boolean;
|
|
9
|
+
promptMessage?: string;
|
|
9
10
|
};
|
|
10
11
|
type FlagsOfPrompts<T extends Record<string, FlaggablePrompt>> = Record<keyof T, Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>>;
|
|
11
12
|
export declare const resultFormatFlag: Interfaces.FlagDefinition<"json" | "human" | "junit" | "tap", Interfaces.CustomOptions, {
|
|
@@ -16,34 +17,6 @@ export declare const testOutputDirFlag: Interfaces.FlagDefinition<string, Interf
|
|
|
16
17
|
multiple: false;
|
|
17
18
|
requiredOrDefaulted: false;
|
|
18
19
|
}>;
|
|
19
|
-
export declare const FLAGGABLE_SPEC_PROMPTS: {
|
|
20
|
-
type: {
|
|
21
|
-
message: string;
|
|
22
|
-
validate: (d: string) => boolean | string;
|
|
23
|
-
char: "t";
|
|
24
|
-
options: string[];
|
|
25
|
-
required: true;
|
|
26
|
-
};
|
|
27
|
-
role: {
|
|
28
|
-
message: string;
|
|
29
|
-
validate: (d: string) => boolean | string;
|
|
30
|
-
required: true;
|
|
31
|
-
};
|
|
32
|
-
'company-name': {
|
|
33
|
-
message: string;
|
|
34
|
-
validate: (d: string) => boolean | string;
|
|
35
|
-
required: true;
|
|
36
|
-
};
|
|
37
|
-
'company-description': {
|
|
38
|
-
message: string;
|
|
39
|
-
validate: (d: string) => boolean | string;
|
|
40
|
-
required: true;
|
|
41
|
-
};
|
|
42
|
-
'company-website': {
|
|
43
|
-
message: string;
|
|
44
|
-
validate: (d: string) => boolean | string;
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
20
|
export declare function makeFlags<T extends Record<string, FlaggablePrompt>>(flaggablePrompts: T): FlagsOfPrompts<T>;
|
|
48
21
|
export declare const promptForFlag: (flagDef: FlaggablePrompt) => Promise<string>;
|
|
49
22
|
export declare const validateAgentType: (agentType?: string, required?: boolean) => string | undefined;
|
package/lib/flags.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { Flags } from '@salesforce/sf-plugins-core';
|
|
8
8
|
import { Messages } from '@salesforce/core';
|
|
9
|
+
import { camelCaseToTitleCase } from '@salesforce/kit';
|
|
9
10
|
import { select, input as inquirerInput } from '@inquirer/prompts';
|
|
10
11
|
import { theme } from './inquirer-theme.js';
|
|
11
12
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
@@ -20,45 +21,6 @@ export const testOutputDirFlag = Flags.custom({
|
|
|
20
21
|
description: messages.getMessage('flags.output-dir.description'),
|
|
21
22
|
summary: messages.getMessage('flags.output-dir.summary'),
|
|
22
23
|
});
|
|
23
|
-
export const FLAGGABLE_SPEC_PROMPTS = {
|
|
24
|
-
type: {
|
|
25
|
-
message: messages.getMessage('flags.type.summary'),
|
|
26
|
-
validate: (d) => d.length > 0 || 'Type cannot be empty',
|
|
27
|
-
char: 't',
|
|
28
|
-
options: ['customer', 'internal'],
|
|
29
|
-
required: true,
|
|
30
|
-
},
|
|
31
|
-
role: {
|
|
32
|
-
message: messages.getMessage('flags.role.summary'),
|
|
33
|
-
validate: (d) => d.length > 0 || 'Role cannot be empty',
|
|
34
|
-
required: true,
|
|
35
|
-
},
|
|
36
|
-
'company-name': {
|
|
37
|
-
message: messages.getMessage('flags.company-name.summary'),
|
|
38
|
-
validate: (d) => d.length > 0 || 'Company name cannot be empty',
|
|
39
|
-
required: true,
|
|
40
|
-
},
|
|
41
|
-
'company-description': {
|
|
42
|
-
message: messages.getMessage('flags.company-description.summary'),
|
|
43
|
-
validate: (d) => d.length > 0 || 'Company description cannot be empty',
|
|
44
|
-
required: true,
|
|
45
|
-
},
|
|
46
|
-
'company-website': {
|
|
47
|
-
message: messages.getMessage('flags.company-website.summary'),
|
|
48
|
-
validate: (d) => {
|
|
49
|
-
// Allow empty string
|
|
50
|
-
if (d.length === 0)
|
|
51
|
-
return true;
|
|
52
|
-
try {
|
|
53
|
-
new URL(d);
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
catch (e) {
|
|
57
|
-
return 'Please enter a valid URL';
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
24
|
function validateInput(input, validate) {
|
|
63
25
|
const result = validate(input);
|
|
64
26
|
if (typeof result === 'string')
|
|
@@ -81,10 +43,10 @@ export function makeFlags(flaggablePrompts) {
|
|
|
81
43
|
]));
|
|
82
44
|
}
|
|
83
45
|
export const promptForFlag = async (flagDef) => {
|
|
84
|
-
const message = flagDef.message.replace(/\.$/, '');
|
|
46
|
+
const message = flagDef.promptMessage ?? flagDef.message.replace(/\.$/, '');
|
|
85
47
|
if (flagDef.options) {
|
|
86
48
|
return select({
|
|
87
|
-
choices: flagDef.options.map((o) => ({ name: o, value: o })),
|
|
49
|
+
choices: flagDef.options.map((o) => ({ name: camelCaseToTitleCase(o), value: o })),
|
|
88
50
|
message,
|
|
89
51
|
theme,
|
|
90
52
|
});
|
package/lib/flags.js.map
CHAN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