@salesforce/plugin-agent 1.3.2
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/LICENSE.txt +12 -0
- package/README.md +223 -0
- package/lib/commands/agent/create.d.ts +17 -0
- package/lib/commands/agent/create.js +65 -0
- package/lib/commands/agent/create.js.map +1 -0
- package/lib/commands/agent/generate/spec.d.ts +41 -0
- package/lib/commands/agent/generate/spec.js +170 -0
- package/lib/commands/agent/generate/spec.js.map +1 -0
- package/lib/commands/agent/test/cancel.d.ts +18 -0
- package/lib/commands/agent/test/cancel.js +43 -0
- package/lib/commands/agent/test/cancel.js.map +1 -0
- package/lib/commands/agent/test/run.d.ts +19 -0
- package/lib/commands/agent/test/run.js +54 -0
- package/lib/commands/agent/test/run.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -0
- package/messages/agent.create.md +25 -0
- package/messages/agent.generate.spec.md +41 -0
- package/messages/agent.test.cancel.md +21 -0
- package/messages/agent.test.run.md +33 -0
- package/npm-shrinkwrap.json +13900 -0
- package/oclif.lock +7583 -0
- package/oclif.manifest.json +379 -0
- package/package.json +209 -0
- package/schemas/agent-create.json +21 -0
- package/schemas/agent-generate-spec.json +24 -0
- package/schemas/agent-test-cancel.json +28 -0
- package/schemas/agent-test-run.json +28 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Copyright (c) 2024, Salesforce.com, Inc.
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
+
|
|
6
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
7
|
+
|
|
8
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
9
|
+
|
|
10
|
+
* Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
11
|
+
|
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# plugin-agent - PREVIEW
|
|
2
|
+
|
|
3
|
+
### THIS PLUGIN IS A PREVIEW VERSION AND IS NOT MEANT FOR PRODUCTION USAGE UNTIL ANNOUNCED.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@salesforce/plugin-agent) [](https://npmjs.org/package/@salesforce/plugin-agent) [](https://raw.githubusercontent.com/salesforcecli/plugin-agent/main/LICENSE.txt)
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
sf plugins install @salesforce/plugin-agent@x.y.z
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Contributing
|
|
14
|
+
|
|
15
|
+
1. Please read our [Code of Conduct](CODE_OF_CONDUCT.md)
|
|
16
|
+
2. Create a new issue before starting your project so that we can keep track of
|
|
17
|
+
what you are trying to add/fix. That way, we can also offer suggestions or
|
|
18
|
+
let you know if there is already an effort in progress.
|
|
19
|
+
3. Fork this repository.
|
|
20
|
+
4. [Build the plugin locally](#build)
|
|
21
|
+
5. Create a _topic_ branch in your fork. Note, this step is recommended but technically not required if contributing using a fork.
|
|
22
|
+
6. Edit the code in your fork.
|
|
23
|
+
7. Write appropriate tests for your changes. Try to achieve at least 95% code coverage on any new code. No pull request will be accepted without unit tests.
|
|
24
|
+
8. Sign CLA (see [CLA](#cla) below).
|
|
25
|
+
9. Send us a pull request when you are done. We'll review your code, suggest any needed changes, and merge it in.
|
|
26
|
+
|
|
27
|
+
### CLA
|
|
28
|
+
|
|
29
|
+
External contributors will be required to sign a Contributor's License
|
|
30
|
+
Agreement. You can do so by going to https://cla.salesforce.com/sign-cla.
|
|
31
|
+
|
|
32
|
+
### Build
|
|
33
|
+
|
|
34
|
+
To build the plugin locally, make sure to have yarn installed and run the following commands:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Clone the repository
|
|
38
|
+
git clone git@github.com:salesforcecli/plugin-agent
|
|
39
|
+
|
|
40
|
+
# Install the dependencies and compile
|
|
41
|
+
yarn && yarn build
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
To use your plugin, run using the local `./bin/dev.js` or `./bin/dev.cmd` file.
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Run using local run file.
|
|
48
|
+
./bin/dev.js agent
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
There should be no differences when running via the Salesforce CLI or using the local run file. However, it can be useful to link the plugin to do some additional testing or run your commands from anywhere on your machine.
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Link your plugin to the sf cli
|
|
55
|
+
sf plugins link .
|
|
56
|
+
# To verify
|
|
57
|
+
sf plugins
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Commands
|
|
61
|
+
|
|
62
|
+
<!-- commands -->
|
|
63
|
+
|
|
64
|
+
- [`sf agent create`](#sf-agent-create)
|
|
65
|
+
- [`sf agent generate spec`](#sf-agent-generate-spec)
|
|
66
|
+
- [`sf agent test cancel`](#sf-agent-test-cancel)
|
|
67
|
+
- [`sf agent test run`](#sf-agent-test-run)
|
|
68
|
+
|
|
69
|
+
## `sf agent create`
|
|
70
|
+
|
|
71
|
+
Create an Agent from an agent spec.
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
USAGE
|
|
75
|
+
$ sf agent create -o <value> -f <value> -n <value> [--json] [--flags-dir <value>] [--api-version <value>]
|
|
76
|
+
|
|
77
|
+
FLAGS
|
|
78
|
+
-f, --job-spec=<value> (required) The path to an agent spec file.
|
|
79
|
+
-n, --name=<value> (required) The name of the agent.
|
|
80
|
+
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
|
|
81
|
+
configuration variable is already set.
|
|
82
|
+
--api-version=<value> Override the api version used for api requests made by this command
|
|
83
|
+
|
|
84
|
+
GLOBAL FLAGS
|
|
85
|
+
--flags-dir=<value> Import flag values from a directory.
|
|
86
|
+
--json Format output as json.
|
|
87
|
+
|
|
88
|
+
DESCRIPTION
|
|
89
|
+
Create an Agent from an agent spec.
|
|
90
|
+
|
|
91
|
+
Create an Agent from an agent spec. Agent metadata is created in the target org and retrieved to the local project.
|
|
92
|
+
|
|
93
|
+
EXAMPLES
|
|
94
|
+
Create an Agent:
|
|
95
|
+
|
|
96
|
+
$ sf agent create --spec ./agent-spec.json
|
|
97
|
+
|
|
98
|
+
FLAG DESCRIPTIONS
|
|
99
|
+
-f, --job-spec=<value> The path to an agent spec file.
|
|
100
|
+
|
|
101
|
+
The agent spec file defines job titles and descriptions for the agent and can be created using the `sf agent create
|
|
102
|
+
spec` command.
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
_See code: [src/commands/agent/create.ts](https://github.com/salesforcecli/plugin-agent/blob/1.3.2/src/commands/agent/create.ts)_
|
|
106
|
+
|
|
107
|
+
## `sf agent generate spec`
|
|
108
|
+
|
|
109
|
+
Create an Agent spec.
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
USAGE
|
|
113
|
+
$ sf agent generate spec -o <value> [--json] [--flags-dir <value>] [--api-version <value>] [-t
|
|
114
|
+
customer_facing|employee_facing] [--role <value>] [--company-name <value>] [--company-description <value>]
|
|
115
|
+
[--company-website <value>] [-d <value>] [-f <value>]
|
|
116
|
+
|
|
117
|
+
FLAGS
|
|
118
|
+
-d, --output-dir=<value> [default: config] The location within the project where the agent spec will be
|
|
119
|
+
written.
|
|
120
|
+
-f, --file-name=<value> [default: agentSpec.json] The name of the file to write the agent spec to.
|
|
121
|
+
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
|
|
122
|
+
configuration variable is already set.
|
|
123
|
+
-t, --type=<option> The type of agent to create.
|
|
124
|
+
<options: customer_facing|employee_facing>
|
|
125
|
+
--api-version=<value> Override the api version used for api requests made by this command
|
|
126
|
+
--company-description=<value> The description of the company, containing details to be used when generating agent
|
|
127
|
+
job descriptions.
|
|
128
|
+
--company-name=<value> The name of the company.
|
|
129
|
+
--company-website=<value> The website URL for the company.
|
|
130
|
+
--role=<value> The role of the agent.
|
|
131
|
+
|
|
132
|
+
GLOBAL FLAGS
|
|
133
|
+
--flags-dir=<value> Import flag values from a directory.
|
|
134
|
+
--json Format output as json.
|
|
135
|
+
|
|
136
|
+
DESCRIPTION
|
|
137
|
+
Create an Agent spec.
|
|
138
|
+
|
|
139
|
+
Create an Agent spec, which is a list of job titles and descriptions that the agent performs.
|
|
140
|
+
|
|
141
|
+
EXAMPLES
|
|
142
|
+
Create an Agent spec in the default location:
|
|
143
|
+
|
|
144
|
+
$ sf agent generate spec --type customer_facing --role Support --company-name "Coral Cloud" \
|
|
145
|
+
--company-description "A meaningful description"
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
_See code: [src/commands/agent/generate/spec.ts](https://github.com/salesforcecli/plugin-agent/blob/1.3.2/src/commands/agent/generate/spec.ts)_
|
|
149
|
+
|
|
150
|
+
## `sf agent test cancel`
|
|
151
|
+
|
|
152
|
+
Cancel a running test for an Agent.
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
USAGE
|
|
156
|
+
$ sf agent test cancel -o <value> -i <value> [--json] [--flags-dir <value>] [-r]
|
|
157
|
+
|
|
158
|
+
FLAGS
|
|
159
|
+
-i, --job-id=<value> (required) The AiEvaluation ID.
|
|
160
|
+
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
|
|
161
|
+
configuration variable is already set.
|
|
162
|
+
-r, --use-most-recent Use the job ID of the most recent test evaluation.
|
|
163
|
+
|
|
164
|
+
GLOBAL FLAGS
|
|
165
|
+
--flags-dir=<value> Import flag values from a directory.
|
|
166
|
+
--json Format output as json.
|
|
167
|
+
|
|
168
|
+
DESCRIPTION
|
|
169
|
+
Cancel a running test for an Agent.
|
|
170
|
+
|
|
171
|
+
Cancel a running test for an Agent, providing the AiEvaluation ID.
|
|
172
|
+
|
|
173
|
+
EXAMPLES
|
|
174
|
+
Cancel a test for an Agent:
|
|
175
|
+
|
|
176
|
+
$ sf agent test cancel --id AiEvalId
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
_See code: [src/commands/agent/test/cancel.ts](https://github.com/salesforcecli/plugin-agent/blob/1.3.2/src/commands/agent/test/cancel.ts)_
|
|
180
|
+
|
|
181
|
+
## `sf agent test run`
|
|
182
|
+
|
|
183
|
+
Start a test for an Agent.
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
USAGE
|
|
187
|
+
$ sf agent test run -o <value> -i <value> [--json] [--flags-dir <value>] [-w <value>] [-d <value>]
|
|
188
|
+
|
|
189
|
+
FLAGS
|
|
190
|
+
-d, --output-dir=<value> Directory in which to store test run files.
|
|
191
|
+
-i, --id=<value> (required) The AiEvalDefinitionVersion ID.
|
|
192
|
+
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
|
|
193
|
+
configuration variable is already set.
|
|
194
|
+
-w, --wait=<value> Number of minutes to wait for the command to complete and display results to the terminal
|
|
195
|
+
window.
|
|
196
|
+
|
|
197
|
+
GLOBAL FLAGS
|
|
198
|
+
--flags-dir=<value> Import flag values from a directory.
|
|
199
|
+
--json Format output as json.
|
|
200
|
+
|
|
201
|
+
DESCRIPTION
|
|
202
|
+
Start a test for an Agent.
|
|
203
|
+
|
|
204
|
+
Start a test for an Agent, providing the AiEvalDefinitionVersion ID. Returns the job ID.
|
|
205
|
+
|
|
206
|
+
EXAMPLES
|
|
207
|
+
Start a test for an Agent:
|
|
208
|
+
|
|
209
|
+
$ sf agent test run --id AiEvalDefVerId
|
|
210
|
+
|
|
211
|
+
FLAG DESCRIPTIONS
|
|
212
|
+
-i, --id=<value> The AiEvalDefinitionVersion ID.
|
|
213
|
+
|
|
214
|
+
The AiEvalDefinitionVersion ID.
|
|
215
|
+
|
|
216
|
+
-w, --wait=<value> Number of minutes to wait for the command to complete and display results to the terminal window.
|
|
217
|
+
|
|
218
|
+
If the command continues to run after the wait period, the CLI returns control of the terminal window to you.
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
_See code: [src/commands/agent/test/run.ts](https://github.com/salesforcecli/plugin-agent/blob/1.3.2/src/commands/agent/test/run.ts)_
|
|
222
|
+
|
|
223
|
+
<!-- commandsstop -->
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
export type AgentCreateResult = {
|
|
3
|
+
isSuccess: boolean;
|
|
4
|
+
errorMessage?: string;
|
|
5
|
+
};
|
|
6
|
+
export default class AgentCreate extends SfCommand<AgentCreateResult> {
|
|
7
|
+
static readonly summary: string;
|
|
8
|
+
static readonly description: string;
|
|
9
|
+
static readonly examples: string[];
|
|
10
|
+
static readonly flags: {
|
|
11
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
'job-spec': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
};
|
|
16
|
+
run(): Promise<AgentCreateResult>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
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 { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
8
|
+
import { Messages } from '@salesforce/core';
|
|
9
|
+
import { Duration, sleep } from '@salesforce/kit';
|
|
10
|
+
import { MultiStageOutput } from '@oclif/multi-stage-output';
|
|
11
|
+
import { colorize } from '@oclif/core/ux';
|
|
12
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
13
|
+
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.create');
|
|
14
|
+
// There is no API for this yet. It's being planned/built by the Agent Creator team.
|
|
15
|
+
// However, we could possibly use:
|
|
16
|
+
// /services/data/{api-version}/connect/attach-agent-topics
|
|
17
|
+
export default class AgentCreate extends SfCommand {
|
|
18
|
+
static summary = messages.getMessage('summary');
|
|
19
|
+
static description = messages.getMessage('description');
|
|
20
|
+
static examples = messages.getMessages('examples');
|
|
21
|
+
static flags = {
|
|
22
|
+
'target-org': Flags.requiredOrg(),
|
|
23
|
+
'api-version': Flags.orgApiVersion(),
|
|
24
|
+
'job-spec': Flags.file({
|
|
25
|
+
char: 'f',
|
|
26
|
+
required: true,
|
|
27
|
+
summary: messages.getMessage('flags.job-spec.summary'),
|
|
28
|
+
description: messages.getMessage('flags.job-spec.description'),
|
|
29
|
+
}),
|
|
30
|
+
name: Flags.string({
|
|
31
|
+
char: 'n',
|
|
32
|
+
required: true,
|
|
33
|
+
summary: messages.getMessage('flags.name.summary'),
|
|
34
|
+
}),
|
|
35
|
+
};
|
|
36
|
+
async run() {
|
|
37
|
+
const { flags } = await this.parse(AgentCreate);
|
|
38
|
+
const jsonParsingStage = `Parsing ${flags['job-spec']}`;
|
|
39
|
+
const mso = new MultiStageOutput({
|
|
40
|
+
jsonEnabled: this.jsonEnabled(),
|
|
41
|
+
title: `Creating ${flags.name} Agent`,
|
|
42
|
+
stages: [
|
|
43
|
+
jsonParsingStage,
|
|
44
|
+
'Generating GenAiPlanner metadata',
|
|
45
|
+
'Creating agent in org',
|
|
46
|
+
'Retrieving agent metadata',
|
|
47
|
+
],
|
|
48
|
+
});
|
|
49
|
+
mso.goto(jsonParsingStage);
|
|
50
|
+
await sleep(Duration.milliseconds(200));
|
|
51
|
+
mso.goto('Generating GenAiPlanner metadata');
|
|
52
|
+
await sleep(Duration.milliseconds(200));
|
|
53
|
+
mso.goto('Creating agent in org');
|
|
54
|
+
// POST to /services/data/{api-version}/connect/attach-agent-topics
|
|
55
|
+
// To simulate time spent on the server generating the spec.
|
|
56
|
+
await sleep(Duration.seconds(5));
|
|
57
|
+
mso.goto('Retrieving agent metadata');
|
|
58
|
+
await sleep(Duration.seconds(3));
|
|
59
|
+
mso.stop();
|
|
60
|
+
this.log(colorize('green', `Successfully created ${flags.name} in ${flags['target-org'].getUsername() ?? 'the target org'}.`));
|
|
61
|
+
this.log(`Use ${colorize('dim', `sf org open agent --name ${flags.name}`)} to view the agent in the browser.`);
|
|
62
|
+
return { isSuccess: true };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/agent/create.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;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C,KAAK,EAAE,4BAA4B,KAAK,CAAC,IAAI,EAAE,CAAC,oCAAoC,CAAC,CAAC;QAE/G,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { Interfaces } from '@oclif/core';
|
|
3
|
+
export type AgentCreateSpecResult = {
|
|
4
|
+
isSuccess: boolean;
|
|
5
|
+
errorMessage?: string;
|
|
6
|
+
jobSpec?: string;
|
|
7
|
+
};
|
|
8
|
+
type FlaggablePrompt = {
|
|
9
|
+
message: string;
|
|
10
|
+
options?: readonly string[] | string[];
|
|
11
|
+
validate: (d: string) => boolean | string;
|
|
12
|
+
char?: Interfaces.AlphabetLowercase | Interfaces.AlphabetUppercase;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export default class AgentCreateSpec extends SfCommand<AgentCreateSpecResult> {
|
|
16
|
+
static readonly summary: string;
|
|
17
|
+
static readonly description: string;
|
|
18
|
+
static readonly examples: string[];
|
|
19
|
+
static readonly requiresProject = true;
|
|
20
|
+
static readonly flags: {
|
|
21
|
+
'output-dir': Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
|
|
22
|
+
'file-name': Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
|
|
23
|
+
type: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
24
|
+
role: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
25
|
+
"company-name": Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
26
|
+
"company-description": Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
27
|
+
"company-website": Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
28
|
+
'target-org': Interfaces.OptionFlag<import("@salesforce/core").Org, Interfaces.CustomOptions>;
|
|
29
|
+
'api-version': Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
30
|
+
};
|
|
31
|
+
run(): Promise<AgentCreateSpecResult>;
|
|
32
|
+
/**
|
|
33
|
+
* Get a flag value or prompt the user for a value.
|
|
34
|
+
*
|
|
35
|
+
* Resolution order:
|
|
36
|
+
* - Flag value provided by the user
|
|
37
|
+
* - Prompt the user for a value
|
|
38
|
+
*/
|
|
39
|
+
getFlagOrPrompt(valueFromFlag: string | undefined, flagDef: FlaggablePrompt): Promise<string>;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,170 @@
|
|
|
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 } from 'node:path';
|
|
8
|
+
import { writeFileSync } from 'node:fs';
|
|
9
|
+
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
10
|
+
import { Messages } from '@salesforce/core';
|
|
11
|
+
import ansis from 'ansis';
|
|
12
|
+
import select from '@inquirer/select';
|
|
13
|
+
import inquirerInput from '@inquirer/input';
|
|
14
|
+
import figures from '@inquirer/figures';
|
|
15
|
+
import { Agent } from '@salesforce/agents';
|
|
16
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
17
|
+
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.generate.spec');
|
|
18
|
+
const FLAGGABLE_PROMPTS = {
|
|
19
|
+
type: {
|
|
20
|
+
message: messages.getMessage('flags.type.summary'),
|
|
21
|
+
validate: (d) => d.length > 0 || 'Type cannot be empty',
|
|
22
|
+
char: 't',
|
|
23
|
+
options: ['customer_facing', 'employee_facing'],
|
|
24
|
+
required: true,
|
|
25
|
+
},
|
|
26
|
+
role: {
|
|
27
|
+
message: messages.getMessage('flags.role.summary'),
|
|
28
|
+
validate: (d) => d.length > 0 || 'Role cannot be empty',
|
|
29
|
+
required: true,
|
|
30
|
+
},
|
|
31
|
+
'company-name': {
|
|
32
|
+
message: messages.getMessage('flags.company-name.summary'),
|
|
33
|
+
validate: (d) => d.length > 0 || 'Company name cannot be empty',
|
|
34
|
+
required: true,
|
|
35
|
+
},
|
|
36
|
+
'company-description': {
|
|
37
|
+
message: messages.getMessage('flags.company-description.summary'),
|
|
38
|
+
validate: (d) => d.length > 0 || 'Company description cannot be empty',
|
|
39
|
+
required: true,
|
|
40
|
+
},
|
|
41
|
+
'company-website': {
|
|
42
|
+
message: messages.getMessage('flags.company-website.summary'),
|
|
43
|
+
validate: (d) => {
|
|
44
|
+
// Allow empty string
|
|
45
|
+
if (d.length === 0)
|
|
46
|
+
return true;
|
|
47
|
+
try {
|
|
48
|
+
new URL(d);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
return 'Please enter a valid URL';
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
};
|
|
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
|
+
export default class AgentCreateSpec extends SfCommand {
|
|
79
|
+
static summary = messages.getMessage('summary');
|
|
80
|
+
static description = messages.getMessage('description');
|
|
81
|
+
static examples = messages.getMessages('examples');
|
|
82
|
+
static requiresProject = true;
|
|
83
|
+
static flags = {
|
|
84
|
+
'target-org': Flags.requiredOrg(),
|
|
85
|
+
'api-version': Flags.orgApiVersion(),
|
|
86
|
+
...makeFlags(FLAGGABLE_PROMPTS),
|
|
87
|
+
'output-dir': Flags.directory({
|
|
88
|
+
char: 'd',
|
|
89
|
+
exists: true,
|
|
90
|
+
summary: messages.getMessage('flags.output-dir.summary'),
|
|
91
|
+
default: 'config',
|
|
92
|
+
}),
|
|
93
|
+
'file-name': Flags.string({
|
|
94
|
+
char: 'f',
|
|
95
|
+
summary: messages.getMessage('flags.file-name.summary'),
|
|
96
|
+
default: 'agentSpec.json',
|
|
97
|
+
}),
|
|
98
|
+
};
|
|
99
|
+
async run() {
|
|
100
|
+
const { flags } = await this.parse(AgentCreateSpec);
|
|
101
|
+
// throw error if --json is used and not all required flags are provided
|
|
102
|
+
if (this.jsonEnabled()) {
|
|
103
|
+
const missingFlags = Object.entries(FLAGGABLE_PROMPTS)
|
|
104
|
+
.filter(([key, prompt]) => 'required' in prompt && prompt.required && !(key in flags))
|
|
105
|
+
.map(([key]) => key);
|
|
106
|
+
if (missingFlags.length) {
|
|
107
|
+
throw new Error(`Missing required flags: ${missingFlags.join(', ')}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
this.log();
|
|
111
|
+
this.styledHeader('Agent Details');
|
|
112
|
+
const type = (await this.getFlagOrPrompt(flags.type, FLAGGABLE_PROMPTS.type));
|
|
113
|
+
const role = await this.getFlagOrPrompt(flags.role, FLAGGABLE_PROMPTS.role);
|
|
114
|
+
const companyName = await this.getFlagOrPrompt(flags['company-name'], FLAGGABLE_PROMPTS['company-name']);
|
|
115
|
+
const companyDescription = await this.getFlagOrPrompt(flags['company-description'], FLAGGABLE_PROMPTS['company-description']);
|
|
116
|
+
const companyWebsite = await this.getFlagOrPrompt(flags['company-website'], FLAGGABLE_PROMPTS['company-website']);
|
|
117
|
+
this.log();
|
|
118
|
+
this.spinner.start('Creating agent spec');
|
|
119
|
+
const connection = flags['target-org'].getConnection(flags['api-version']);
|
|
120
|
+
const agent = new Agent(connection, this.project);
|
|
121
|
+
const agentSpec = await agent.createSpec({
|
|
122
|
+
name: flags['file-name'].split('.json')[0],
|
|
123
|
+
type,
|
|
124
|
+
role,
|
|
125
|
+
companyName,
|
|
126
|
+
companyDescription,
|
|
127
|
+
companyWebsite,
|
|
128
|
+
});
|
|
129
|
+
// Write a file with the returned job specs
|
|
130
|
+
const filePath = join(flags['output-dir'], flags['file-name']);
|
|
131
|
+
writeFileSync(filePath, JSON.stringify(agentSpec, null, 4));
|
|
132
|
+
this.spinner.stop();
|
|
133
|
+
this.log(`\nSaved agent spec: ${filePath}`);
|
|
134
|
+
return {
|
|
135
|
+
isSuccess: true,
|
|
136
|
+
jobSpec: filePath,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Get a flag value or prompt the user for a value.
|
|
141
|
+
*
|
|
142
|
+
* Resolution order:
|
|
143
|
+
* - Flag value provided by the user
|
|
144
|
+
* - Prompt the user for a value
|
|
145
|
+
*/
|
|
146
|
+
async getFlagOrPrompt(valueFromFlag, flagDef) {
|
|
147
|
+
const message = flagDef.message.replace(/\.$/, '');
|
|
148
|
+
if (valueFromFlag) {
|
|
149
|
+
this.log(`${ansis.green(figures.tick)} ${ansis.bold(message)} ${ansis.cyan(valueFromFlag)}`);
|
|
150
|
+
return valueFromFlag;
|
|
151
|
+
}
|
|
152
|
+
if (flagDef.options) {
|
|
153
|
+
return select({
|
|
154
|
+
choices: flagDef.options.map((o) => ({ name: o, value: o })),
|
|
155
|
+
message,
|
|
156
|
+
theme: {
|
|
157
|
+
prefix: { idle: ansis.blueBright('?') },
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return inquirerInput({
|
|
162
|
+
message,
|
|
163
|
+
validate: flagDef.validate,
|
|
164
|
+
theme: {
|
|
165
|
+
prefix: { idle: ansis.blueBright('?') },
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=spec.js.map
|
|
@@ -0,0 +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;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAa,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAW,MAAM,oBAAoB,CAAC;AAEpD,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,0BAA0B,EAAE,qBAAqB,CAAC,CAAC;AAuB1F,MAAM,iBAAiB,GAAG;IACxB,IAAI,EAAE;QACJ,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,oBAAoB,CAAC;QAClD,QAAQ,EAAE,CAAC,CAAS,EAAoB,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,sBAAsB;QACjF,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;QAC/C,QAAQ,EAAE,IAAI;KACf;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,QAA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,KAAK,EAAE,EAAE,CAAC,CAAC;QAEnD,IAAI,aAAa,EAAE,CAAC;YAClB,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;YAE7F,OAAO,aAAa,CAAC;QACvB,CAAC;QAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,MAAM,CAAC;gBACZ,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;gBAC5D,OAAO;gBACP,KAAK,EAAE;oBACL,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;iBACxC;aACF,CAAC,CAAC;QACL,CAAC;QAED,OAAO,aAAa,CAAC;YACnB,OAAO;YACP,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,KAAK,EAAE;gBACL,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;aACxC;SACF,CAAC,CAAC;IACL,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
export type AgentTestCancelResult = {
|
|
3
|
+
jobId: string;
|
|
4
|
+
success: boolean;
|
|
5
|
+
errorCode?: string;
|
|
6
|
+
message?: string;
|
|
7
|
+
};
|
|
8
|
+
export default class AgentTestCancel extends SfCommand<AgentTestCancelResult> {
|
|
9
|
+
static readonly summary: string;
|
|
10
|
+
static readonly description: string;
|
|
11
|
+
static readonly examples: string[];
|
|
12
|
+
static readonly flags: {
|
|
13
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
'job-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'use-most-recent': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
};
|
|
17
|
+
run(): Promise<AgentTestCancelResult>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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 { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
8
|
+
import { Messages } from '@salesforce/core';
|
|
9
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
10
|
+
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.test.cancel');
|
|
11
|
+
export default class AgentTestCancel extends SfCommand {
|
|
12
|
+
static summary = messages.getMessage('summary');
|
|
13
|
+
static description = messages.getMessage('description');
|
|
14
|
+
static examples = messages.getMessages('examples');
|
|
15
|
+
static flags = {
|
|
16
|
+
'target-org': Flags.requiredOrg(),
|
|
17
|
+
'job-id': Flags.string({
|
|
18
|
+
char: 'i',
|
|
19
|
+
required: true,
|
|
20
|
+
summary: messages.getMessage('flags.id.summary'),
|
|
21
|
+
}),
|
|
22
|
+
'use-most-recent': Flags.boolean({
|
|
23
|
+
char: 'r',
|
|
24
|
+
summary: messages.getMessage('flags.use-most-recent.summary'),
|
|
25
|
+
exactlyOne: ['use-most-recent', 'job-id'],
|
|
26
|
+
}),
|
|
27
|
+
//
|
|
28
|
+
// Future flags:
|
|
29
|
+
// ??? api-version ???
|
|
30
|
+
};
|
|
31
|
+
async run() {
|
|
32
|
+
const { flags } = await this.parse(AgentTestCancel);
|
|
33
|
+
this.log(`Canceling tests for AiEvaluation Job: ${flags['job-id']}`);
|
|
34
|
+
// Call SF Eval Connect API passing AiEvaluation.Id
|
|
35
|
+
// POST to /einstein/ai-evaluations/{aiEvaluationId}/stop
|
|
36
|
+
// Returns: AiEvaluation.Id
|
|
37
|
+
return {
|
|
38
|
+
success: true,
|
|
39
|
+
jobId: '4KBSM000000003F4AQ', // AiEvaluation.Id
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=cancel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../../src/commands/agent/test/cancel.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,0BAA0B,EAAE,mBAAmB,CAAC,CAAC;AASxF,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,SAAgC;IACpE,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;IAE5D,MAAM,CAAU,KAAK,GAAG;QAC7B,YAAY,EAAE,KAAK,CAAC,WAAW,EAAE;QACjC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC;YACrB,IAAI,EAAE,GAAG;YACT,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,kBAAkB,CAAC;SACjD,CAAC;QACF,iBAAiB,EAAE,KAAK,CAAC,OAAO,CAAC;YAC/B,IAAI,EAAE,GAAG;YACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,+BAA+B,CAAC;YAC7D,UAAU,EAAE,CAAC,iBAAiB,EAAE,QAAQ,CAAC;SAC1C,CAAC;QACF,EAAE;QACF,gBAAgB;QAChB,wBAAwB;KACzB,CAAC;IAEK,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAEpD,IAAI,CAAC,GAAG,CAAC,yCAAyC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAErE,mDAAmD;QACnD,yDAAyD;QAEzD,2BAA2B;QAE3B,OAAO;YACL,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,oBAAoB,EAAE,kBAAkB;SAChD,CAAC;IACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
export type AgentTestRunResult = {
|
|
3
|
+
jobId: string;
|
|
4
|
+
success: boolean;
|
|
5
|
+
errorCode?: string;
|
|
6
|
+
message?: string;
|
|
7
|
+
};
|
|
8
|
+
export default class AgentTestRun extends SfCommand<AgentTestRunResult> {
|
|
9
|
+
static readonly summary: string;
|
|
10
|
+
static readonly description: string;
|
|
11
|
+
static readonly examples: string[];
|
|
12
|
+
static readonly flags: {
|
|
13
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
id: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
wait: import("@oclif/core/interfaces").OptionFlag<import("@salesforce/kit").Duration, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
'output-dir': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
};
|
|
18
|
+
run(): Promise<AgentTestRunResult>;
|
|
19
|
+
}
|