@salesforce/plugin-agent 1.32.14 → 1.32.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -39
- package/lib/commands/agent/activate.d.ts +2 -0
- package/lib/commands/agent/activate.js +33 -4
- package/lib/commands/agent/activate.js.map +1 -1
- package/lib/commands/agent/deactivate.d.ts +2 -0
- package/lib/commands/agent/deactivate.js +33 -4
- package/lib/commands/agent/deactivate.js.map +1 -1
- package/lib/commands/agent/preview/end.d.ts +2 -0
- package/lib/commands/agent/preview/end.js +49 -12
- package/lib/commands/agent/preview/end.js.map +1 -1
- package/lib/commands/agent/preview/send.d.ts +2 -0
- package/lib/commands/agent/preview/send.js +47 -9
- package/lib/commands/agent/preview/send.js.map +1 -1
- package/lib/commands/agent/preview/sessions.d.ts +1 -0
- package/lib/commands/agent/preview/sessions.js +4 -1
- package/lib/commands/agent/preview/sessions.js.map +1 -1
- package/lib/commands/agent/preview/start.d.ts +3 -0
- package/lib/commands/agent/preview/start.js +72 -10
- package/lib/commands/agent/preview/start.js.map +1 -1
- package/lib/commands/agent/test/create.d.ts +2 -0
- package/lib/commands/agent/test/create.js +34 -6
- package/lib/commands/agent/test/create.js.map +1 -1
- package/lib/commands/agent/test/list.d.ts +2 -0
- package/lib/commands/agent/test/list.js +15 -3
- package/lib/commands/agent/test/list.js.map +1 -1
- package/lib/commands/agent/test/results.d.ts +2 -0
- package/lib/commands/agent/test/results.js +23 -3
- package/lib/commands/agent/test/results.js.map +1 -1
- package/lib/commands/agent/test/resume.d.ts +6 -0
- package/lib/commands/agent/test/resume.js +55 -7
- package/lib/commands/agent/test/resume.js.map +1 -1
- package/lib/commands/agent/test/run-eval.d.ts +2 -0
- package/lib/commands/agent/test/run-eval.js +38 -7
- package/lib/commands/agent/test/run-eval.js.map +1 -1
- package/lib/commands/agent/test/run.d.ts +2 -0
- package/lib/commands/agent/test/run.js +32 -8
- package/lib/commands/agent/test/run.js.map +1 -1
- package/lib/commands/agent/validate/authoring-bundle.d.ts +2 -0
- package/lib/commands/agent/validate/authoring-bundle.js +9 -2
- package/lib/commands/agent/validate/authoring-bundle.js.map +1 -1
- package/lib/previewSessionStore.js +0 -6
- package/lib/previewSessionStore.js.map +1 -1
- package/messages/agent.activate.md +8 -0
- package/messages/agent.deactivate.md +8 -0
- package/messages/agent.preview.end.md +18 -6
- package/messages/agent.preview.send.md +16 -4
- package/messages/agent.preview.start.md +31 -10
- package/oclif.manifest.json +372 -7
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -126,7 +126,7 @@ EXAMPLES
|
|
|
126
126
|
$ sf agent activate --api-name Resort_Manager --version 2 --target-org my-org
|
|
127
127
|
```
|
|
128
128
|
|
|
129
|
-
_See code: [src/commands/agent/activate.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.
|
|
129
|
+
_See code: [src/commands/agent/activate.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.16/src/commands/agent/activate.ts)_
|
|
130
130
|
|
|
131
131
|
## `sf agent create`
|
|
132
132
|
|
|
@@ -193,7 +193,7 @@ EXAMPLES
|
|
|
193
193
|
$ sf agent create --name "Resort Manager" --spec specs/resortManagerAgent.yaml --preview
|
|
194
194
|
```
|
|
195
195
|
|
|
196
|
-
_See code: [src/commands/agent/create.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.
|
|
196
|
+
_See code: [src/commands/agent/create.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.16/src/commands/agent/create.ts)_
|
|
197
197
|
|
|
198
198
|
## `sf agent deactivate`
|
|
199
199
|
|
|
@@ -234,7 +234,7 @@ EXAMPLES
|
|
|
234
234
|
$ sf agent deactivate --api-name Resort_Manager --target-org my-org
|
|
235
235
|
```
|
|
236
236
|
|
|
237
|
-
_See code: [src/commands/agent/deactivate.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.
|
|
237
|
+
_See code: [src/commands/agent/deactivate.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.16/src/commands/agent/deactivate.ts)_
|
|
238
238
|
|
|
239
239
|
## `sf agent generate agent-spec`
|
|
240
240
|
|
|
@@ -341,7 +341,7 @@ EXAMPLES
|
|
|
341
341
|
$ sf agent generate agent-spec --tone formal --agent-user resortmanager@myorg.com
|
|
342
342
|
```
|
|
343
343
|
|
|
344
|
-
_See code: [src/commands/agent/generate/agent-spec.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.
|
|
344
|
+
_See code: [src/commands/agent/generate/agent-spec.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.16/src/commands/agent/generate/agent-spec.ts)_
|
|
345
345
|
|
|
346
346
|
## `sf agent generate authoring-bundle`
|
|
347
347
|
|
|
@@ -418,7 +418,7 @@ EXAMPLES
|
|
|
418
418
|
other-package-dir/main/default --target-org my-dev-org
|
|
419
419
|
```
|
|
420
420
|
|
|
421
|
-
_See code: [src/commands/agent/generate/authoring-bundle.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.
|
|
421
|
+
_See code: [src/commands/agent/generate/authoring-bundle.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.16/src/commands/agent/generate/authoring-bundle.ts)_
|
|
422
422
|
|
|
423
423
|
## `sf agent generate template`
|
|
424
424
|
|
|
@@ -480,7 +480,7 @@ EXAMPLES
|
|
|
480
480
|
my-package --source-org my-scratch-org
|
|
481
481
|
```
|
|
482
482
|
|
|
483
|
-
_See code: [src/commands/agent/generate/template.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.
|
|
483
|
+
_See code: [src/commands/agent/generate/template.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.16/src/commands/agent/generate/template.ts)_
|
|
484
484
|
|
|
485
485
|
## `sf agent generate test-spec`
|
|
486
486
|
|
|
@@ -545,7 +545,7 @@ EXAMPLES
|
|
|
545
545
|
force-app//main/default/aiEvaluationDefinitions/Resort_Manager_Tests.aiEvaluationDefinition-meta.xml
|
|
546
546
|
```
|
|
547
547
|
|
|
548
|
-
_See code: [src/commands/agent/generate/test-spec.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.
|
|
548
|
+
_See code: [src/commands/agent/generate/test-spec.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.16/src/commands/agent/generate/test-spec.ts)_
|
|
549
549
|
|
|
550
550
|
## `sf agent preview`
|
|
551
551
|
|
|
@@ -618,7 +618,7 @@ EXAMPLES
|
|
|
618
618
|
$ sf agent preview --use-live-actions --apex-debug --output-dir transcripts/my-preview
|
|
619
619
|
```
|
|
620
620
|
|
|
621
|
-
_See code: [src/commands/agent/preview.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.
|
|
621
|
+
_See code: [src/commands/agent/preview.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.16/src/commands/agent/preview.ts)_
|
|
622
622
|
|
|
623
623
|
## `sf agent preview end`
|
|
624
624
|
|
|
@@ -650,11 +650,11 @@ DESCRIPTION
|
|
|
650
650
|
use this command to end it. This command also displays the local directory where the session trace files are stored.
|
|
651
651
|
|
|
652
652
|
The original "agent preview start" command outputs a session ID which you then use with the --session-id flag of this
|
|
653
|
-
command to end the session.
|
|
653
|
+
command to end the session. You don't have to specify the --session-id flag if an agent has only one active preview
|
|
654
654
|
session. You must also use either the --authoring-bundle or --api-name flag to specify the API name of the authoring
|
|
655
|
-
bundle or the published agent, respecitvely.
|
|
655
|
+
bundle or the published agent, respecitvely. To find either API name, navigate to your package directory in your DX
|
|
656
656
|
project. The API name of an authoring bundle is the same as its directory name under the "aiAuthoringBundles" metadata
|
|
657
|
-
directory.
|
|
657
|
+
directory. Similarly, the published agent's API name is the same as its directory name under the "Bots" metadata
|
|
658
658
|
directory.
|
|
659
659
|
|
|
660
660
|
EXAMPLES
|
|
@@ -673,7 +673,7 @@ EXAMPLES
|
|
|
673
673
|
$ sf agent preview end --authoring-bundle My_Local_Agent
|
|
674
674
|
```
|
|
675
675
|
|
|
676
|
-
_See code: [src/commands/agent/preview/end.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.
|
|
676
|
+
_See code: [src/commands/agent/preview/end.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.16/src/commands/agent/preview/end.ts)_
|
|
677
677
|
|
|
678
678
|
## `sf agent preview send`
|
|
679
679
|
|
|
@@ -706,11 +706,11 @@ DESCRIPTION
|
|
|
706
706
|
use this command to send the agent a message (utterance). This command then displays the agent's response.
|
|
707
707
|
|
|
708
708
|
The original "agent preview start" command outputs a session ID which you then use with the --session-id flag of this
|
|
709
|
-
command to send a message.
|
|
709
|
+
command to send a message. You don't have to specify the --session-id flag if an agent has only one active preview
|
|
710
710
|
session. You must also use either the --authoring-bundle or --api-name flag to specify the API name of the authoring
|
|
711
|
-
bundle or the published agent, respecitvely.
|
|
711
|
+
bundle or the published agent, respecitvely. To find either API name, navigate to your package directory in your DX
|
|
712
712
|
project. The API name of an authoring bundle is the same as its directory name under the "aiAuthoringBundles" metadata
|
|
713
|
-
directory.
|
|
713
|
+
directory. Similarly, the published agent's API name is the same as its directory name under the "Bots" metadata
|
|
714
714
|
directory.
|
|
715
715
|
|
|
716
716
|
EXAMPLES
|
|
@@ -731,7 +731,7 @@ EXAMPLES
|
|
|
731
731
|
$ sf agent preview send --utterance "what can you help me with?" --authoring-bundle My_Local_Agent
|
|
732
732
|
```
|
|
733
733
|
|
|
734
|
-
_See code: [src/commands/agent/preview/send.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.
|
|
734
|
+
_See code: [src/commands/agent/preview/send.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.16/src/commands/agent/preview/send.ts)_
|
|
735
735
|
|
|
736
736
|
## `sf agent preview sessions`
|
|
737
737
|
|
|
@@ -764,7 +764,7 @@ EXAMPLES
|
|
|
764
764
|
$ sf agent preview sessions
|
|
765
765
|
```
|
|
766
766
|
|
|
767
|
-
_See code: [src/commands/agent/preview/sessions.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.
|
|
767
|
+
_See code: [src/commands/agent/preview/sessions.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.16/src/commands/agent/preview/sessions.ts)_
|
|
768
768
|
|
|
769
769
|
## `sf agent preview start`
|
|
770
770
|
|
|
@@ -773,7 +773,7 @@ Start a programmatic agent preview session.
|
|
|
773
773
|
```
|
|
774
774
|
USAGE
|
|
775
775
|
$ sf agent preview start -o <value> [--json] [--flags-dir <value>] [--api-version <value>] [-n <value>]
|
|
776
|
-
[--authoring-bundle <value>] [--use-live-actions]
|
|
776
|
+
[--authoring-bundle <value>] [--use-live-actions | --simulate-actions]
|
|
777
777
|
|
|
778
778
|
FLAGS
|
|
779
779
|
-n, --api-name=<value> API name of the activated published agent you want to preview.
|
|
@@ -782,8 +782,10 @@ FLAGS
|
|
|
782
782
|
--api-version=<value> Override the api version used for api requests made by this command
|
|
783
783
|
--authoring-bundle=<value> API name of the authoring bundle metadata component that contains the agent's Agent
|
|
784
784
|
Script file.
|
|
785
|
-
--
|
|
786
|
-
|
|
785
|
+
--simulate-actions Use AI to simulate action execution instead of calling real actions. Required with
|
|
786
|
+
--authoring-bundle.
|
|
787
|
+
--use-live-actions Execute real actions in the org (Apex classes, flows, etc.). Required with
|
|
788
|
+
--authoring-bundle.
|
|
787
789
|
|
|
788
790
|
GLOBAL FLAGS
|
|
789
791
|
--flags-dir=<value> Import flag values from a directory.
|
|
@@ -793,35 +795,41 @@ DESCRIPTION
|
|
|
793
795
|
Start a programmatic agent preview session.
|
|
794
796
|
|
|
795
797
|
This command outputs a session ID that you then use with the "agent preview send" command to send an utterance to the
|
|
796
|
-
agent.
|
|
797
|
-
|
|
798
|
+
agent. Use the "agent preview sessions" command to list all active sessions and the "agent preview end" command to end
|
|
799
|
+
a specific session.
|
|
798
800
|
|
|
799
801
|
Identify the agent you want to start previewing with either the --authoring-bundle flag to specify a local authoring
|
|
800
|
-
bundle's API name or --api-name to specify an activated published agent's API name.
|
|
802
|
+
bundle's API name or --api-name to specify an activated published agent's API name. To find either API name, navigate
|
|
801
803
|
to your package directory in your DX project. The API name of an authoring bundle is the same as its directory name
|
|
802
|
-
under the "aiAuthoringBundles" metadata directory.
|
|
804
|
+
under the "aiAuthoringBundles" metadata directory. Similarly, the published agent's API name is the same as its
|
|
803
805
|
directory name under the "Bots" metadata directory.
|
|
804
806
|
|
|
805
|
-
When starting a preview session
|
|
806
|
-
|
|
807
|
-
|
|
807
|
+
When starting a preview session with --authoring-bundle, you must explicitly specify the execution mode using one of
|
|
808
|
+
these flags:
|
|
809
|
+
|
|
810
|
+
- --use-live-actions: Executes real Apex classes, flows, and other actions in the org. This surfaces compile and
|
|
811
|
+
validation errors during preview.
|
|
812
|
+
- --simulate-actions: Uses AI to simulate action execution without calling real implementations.
|
|
813
|
+
|
|
814
|
+
Published agents (--api-name) always use live actions. The mode flags are optional and have no effect for published
|
|
815
|
+
agents.
|
|
808
816
|
|
|
809
817
|
EXAMPLES
|
|
810
|
-
Start a programmatic agent preview session by specifying an authoring bundle;
|
|
811
|
-
|
|
818
|
+
Start a programmatic agent preview session by specifying an authoring bundle; use simulated actions. Use the org
|
|
819
|
+
with alias "my-dev-org":
|
|
812
820
|
|
|
813
|
-
$ sf agent preview start --authoring-bundle My_Agent_Bundle --target-org my-dev-org
|
|
821
|
+
$ sf agent preview start --authoring-bundle My_Agent_Bundle --target-org my-dev-org --simulate-actions
|
|
814
822
|
|
|
815
823
|
Similar to previous example but use live actions and the default org:
|
|
816
824
|
|
|
817
825
|
$ sf agent preview start --authoring-bundle My_Agent_Bundle --use-live-actions
|
|
818
826
|
|
|
819
|
-
Start a preview session with an activated published agent:
|
|
827
|
+
Start a preview session with an activated published agent (always uses live actions):
|
|
820
828
|
|
|
821
829
|
$ sf agent preview start --api-name My_Published_Agent
|
|
822
830
|
```
|
|
823
831
|
|
|
824
|
-
_See code: [src/commands/agent/preview/start.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.
|
|
832
|
+
_See code: [src/commands/agent/preview/start.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.16/src/commands/agent/preview/start.ts)_
|
|
825
833
|
|
|
826
834
|
## `sf agent publish authoring-bundle`
|
|
827
835
|
|
|
@@ -870,7 +878,7 @@ EXAMPLES
|
|
|
870
878
|
$ sf agent publish authoring-bundle --api-name MyAuthoringbundle --target-org my-dev-org
|
|
871
879
|
```
|
|
872
880
|
|
|
873
|
-
_See code: [src/commands/agent/publish/authoring-bundle.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.
|
|
881
|
+
_See code: [src/commands/agent/publish/authoring-bundle.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.16/src/commands/agent/publish/authoring-bundle.ts)_
|
|
874
882
|
|
|
875
883
|
## `sf agent test create`
|
|
876
884
|
|
|
@@ -925,7 +933,7 @@ EXAMPLES
|
|
|
925
933
|
$ sf agent test create --spec specs/Resort_Manager-testSpec.yaml --api-name Resort_Manager_Test --preview
|
|
926
934
|
```
|
|
927
935
|
|
|
928
|
-
_See code: [src/commands/agent/test/create.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.
|
|
936
|
+
_See code: [src/commands/agent/test/create.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.16/src/commands/agent/test/create.ts)_
|
|
929
937
|
|
|
930
938
|
## `sf agent test list`
|
|
931
939
|
|
|
@@ -960,7 +968,7 @@ EXAMPLES
|
|
|
960
968
|
$ sf agent test list --target-org my-org
|
|
961
969
|
```
|
|
962
970
|
|
|
963
|
-
_See code: [src/commands/agent/test/list.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.
|
|
971
|
+
_See code: [src/commands/agent/test/list.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.16/src/commands/agent/test/list.ts)_
|
|
964
972
|
|
|
965
973
|
## `sf agent test results`
|
|
966
974
|
|
|
@@ -1026,7 +1034,7 @@ FLAG DESCRIPTIONS
|
|
|
1026
1034
|
expression when using custom evaluations.
|
|
1027
1035
|
```
|
|
1028
1036
|
|
|
1029
|
-
_See code: [src/commands/agent/test/results.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.
|
|
1037
|
+
_See code: [src/commands/agent/test/results.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.16/src/commands/agent/test/results.ts)_
|
|
1030
1038
|
|
|
1031
1039
|
## `sf agent test resume`
|
|
1032
1040
|
|
|
@@ -1099,7 +1107,7 @@ FLAG DESCRIPTIONS
|
|
|
1099
1107
|
expression when using custom evaluations.
|
|
1100
1108
|
```
|
|
1101
1109
|
|
|
1102
|
-
_See code: [src/commands/agent/test/resume.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.
|
|
1110
|
+
_See code: [src/commands/agent/test/resume.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.16/src/commands/agent/test/resume.ts)_
|
|
1103
1111
|
|
|
1104
1112
|
## `sf agent test run`
|
|
1105
1113
|
|
|
@@ -1173,7 +1181,7 @@ FLAG DESCRIPTIONS
|
|
|
1173
1181
|
expression when using custom evaluations.
|
|
1174
1182
|
```
|
|
1175
1183
|
|
|
1176
|
-
_See code: [src/commands/agent/test/run.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.
|
|
1184
|
+
_See code: [src/commands/agent/test/run.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.16/src/commands/agent/test/run.ts)_
|
|
1177
1185
|
|
|
1178
1186
|
## `sf agent validate authoring-bundle`
|
|
1179
1187
|
|
|
@@ -1220,6 +1228,6 @@ EXAMPLES
|
|
|
1220
1228
|
$ sf agent validate authoring-bundle --api-name MyAuthoringBundle --target-org my-dev-org
|
|
1221
1229
|
```
|
|
1222
1230
|
|
|
1223
|
-
_See code: [src/commands/agent/validate/authoring-bundle.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.
|
|
1231
|
+
_See code: [src/commands/agent/validate/authoring-bundle.ts](https://github.com/salesforcecli/plugin-agent/blob/1.32.16/src/commands/agent/validate/authoring-bundle.ts)_
|
|
1224
1232
|
|
|
1225
1233
|
<!-- commandsstop -->
|
|
@@ -8,6 +8,8 @@ export default class AgentActivate extends SfCommand<AgentActivateResult> {
|
|
|
8
8
|
static readonly description: string;
|
|
9
9
|
static readonly examples: string[];
|
|
10
10
|
static readonly enableJsonFlag = true;
|
|
11
|
+
static readonly envVariablesSection: import("@oclif/core").HelpSection;
|
|
12
|
+
static readonly errorCodes: import("@oclif/core").HelpSection;
|
|
11
13
|
static readonly flags: {
|
|
12
14
|
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
15
|
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
17
|
-
import { Messages } from '@salesforce/core';
|
|
16
|
+
import { SfCommand, Flags, toHelpSection } from '@salesforce/sf-plugins-core';
|
|
17
|
+
import { Messages, SfError, Lifecycle, EnvironmentVariable } from '@salesforce/core';
|
|
18
18
|
import { getAgentForActivation, getVersionForActivation } from '../../agentActivation.js';
|
|
19
19
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
20
20
|
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.activate');
|
|
@@ -23,6 +23,12 @@ export default class AgentActivate extends SfCommand {
|
|
|
23
23
|
static description = messages.getMessage('description');
|
|
24
24
|
static examples = messages.getMessages('examples');
|
|
25
25
|
static enableJsonFlag = true;
|
|
26
|
+
static envVariablesSection = toHelpSection('ENVIRONMENT VARIABLES', EnvironmentVariable.SF_TARGET_ORG);
|
|
27
|
+
static errorCodes = toHelpSection('ERROR CODES', {
|
|
28
|
+
'Succeeded (0)': 'Agent activated successfully.',
|
|
29
|
+
'NotFound (2)': 'Agent not found in the org.',
|
|
30
|
+
'ActivationFailed (4)': 'Failed to activate the agent due to API or network errors.',
|
|
31
|
+
});
|
|
26
32
|
static flags = {
|
|
27
33
|
'target-org': Flags.requiredOrg(),
|
|
28
34
|
'api-version': Flags.orgApiVersion(),
|
|
@@ -39,15 +45,38 @@ export default class AgentActivate extends SfCommand {
|
|
|
39
45
|
if (!apiNameFlag && this.jsonEnabled()) {
|
|
40
46
|
throw messages.createError('error.missingRequiredFlags', ['api-name']);
|
|
41
47
|
}
|
|
42
|
-
|
|
48
|
+
// Get agent with error tracking
|
|
49
|
+
let agent;
|
|
50
|
+
try {
|
|
51
|
+
agent = await getAgentForActivation({ targetOrg, status: 'Active', apiNameFlag });
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
const wrapped = SfError.wrap(error);
|
|
55
|
+
if (wrapped.message.toLowerCase().includes('not found') || wrapped.message.toLowerCase().includes('no agent')) {
|
|
56
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_activate_agent_not_found' });
|
|
57
|
+
throw new SfError(messages.getMessage('error.agentNotFound', [apiNameFlag ?? 'unknown']), 'AgentNotFound', [], 2, wrapped);
|
|
58
|
+
}
|
|
59
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_activate_get_agent_failed' });
|
|
60
|
+
throw wrapped;
|
|
61
|
+
}
|
|
43
62
|
const { version, warning } = await getVersionForActivation({
|
|
44
63
|
agent,
|
|
45
64
|
status: 'Active',
|
|
46
65
|
versionFlag: flags.version,
|
|
47
66
|
jsonEnabled: this.jsonEnabled(),
|
|
48
67
|
});
|
|
49
|
-
|
|
68
|
+
// Activate with error tracking
|
|
69
|
+
let result;
|
|
70
|
+
try {
|
|
71
|
+
result = await agent.activate(version);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
const wrapped = SfError.wrap(error);
|
|
75
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_activate_failed' });
|
|
76
|
+
throw new SfError(messages.getMessage('error.activationFailed', [wrapped.message]), 'ActivationFailed', [wrapped.message], 4, wrapped);
|
|
77
|
+
}
|
|
50
78
|
const metadata = await agent.getBotMetadata();
|
|
79
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_activate_success' });
|
|
51
80
|
this.log(`${metadata.DeveloperName} v${result.VersionNumber} activated.`);
|
|
52
81
|
if (warning) {
|
|
53
82
|
this.warn(warning);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activate.js","sourceRoot":"","sources":["../../../src/commands/agent/activate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"activate.js","sourceRoot":"","sources":["../../../src/commands/agent/activate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAI1F,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,0BAA0B,EAAE,gBAAgB,CAAC,CAAC;AAErF,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,SAA8B;IAChE,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,CAAU,cAAc,GAAG,IAAI,CAAC;IAEtC,MAAM,CAAU,mBAAmB,GAAG,aAAa,C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,CAAC,OAAO,CAAC,EACjB,CAAC,EACD,OAAO,CACR,CAAC;QACJ,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,cAAc,EAAE,CAAC;QAC9C,MAAM,SAAS,CAAC,WAAW,EAAE,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,wBAAwB,EAAE,CAAC,CAAC;QAErF,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,aAAa,KAAK,MAAM,CAAC,aAAa,aAAa,CAAC,CAAC;QAC1E,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC;IAC1D,CAAC"}
|
|
@@ -5,6 +5,8 @@ export default class AgentDeactivate extends SfCommand<AgentActivateResult> {
|
|
|
5
5
|
static readonly description: string;
|
|
6
6
|
static readonly examples: string[];
|
|
7
7
|
static enableJsonFlag: boolean;
|
|
8
|
+
static readonly envVariablesSection: import("@oclif/core").HelpSection;
|
|
9
|
+
static readonly errorCodes: import("@oclif/core").HelpSection;
|
|
8
10
|
static readonly flags: {
|
|
9
11
|
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
12
|
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
17
|
-
import { Messages } from '@salesforce/core';
|
|
16
|
+
import { SfCommand, Flags, toHelpSection } from '@salesforce/sf-plugins-core';
|
|
17
|
+
import { Messages, SfError, Lifecycle, EnvironmentVariable } from '@salesforce/core';
|
|
18
18
|
import { getAgentForActivation } from '../../agentActivation.js';
|
|
19
19
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
20
20
|
const messages = Messages.loadMessages('@salesforce/plugin-agent', 'agent.deactivate');
|
|
@@ -23,6 +23,12 @@ export default class AgentDeactivate extends SfCommand {
|
|
|
23
23
|
static description = messages.getMessage('description');
|
|
24
24
|
static examples = messages.getMessages('examples');
|
|
25
25
|
static enableJsonFlag = true;
|
|
26
|
+
static envVariablesSection = toHelpSection('ENVIRONMENT VARIABLES', EnvironmentVariable.SF_TARGET_ORG);
|
|
27
|
+
static errorCodes = toHelpSection('ERROR CODES', {
|
|
28
|
+
'Succeeded (0)': 'Agent deactivated successfully.',
|
|
29
|
+
'NotFound (2)': 'Agent not found in the org.',
|
|
30
|
+
'DeactivationFailed (4)': 'Failed to deactivate the agent due to API or network errors.',
|
|
31
|
+
});
|
|
26
32
|
static flags = {
|
|
27
33
|
'target-org': Flags.requiredOrg(),
|
|
28
34
|
'api-version': Flags.orgApiVersion(),
|
|
@@ -38,9 +44,32 @@ export default class AgentDeactivate extends SfCommand {
|
|
|
38
44
|
if (!apiNameFlag && this.jsonEnabled()) {
|
|
39
45
|
throw messages.createError('error.missingRequiredFlags', ['api-name']);
|
|
40
46
|
}
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
// Get agent with error tracking
|
|
48
|
+
let agent;
|
|
49
|
+
try {
|
|
50
|
+
agent = await getAgentForActivation({ targetOrg, status: 'Inactive', apiNameFlag });
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
const wrapped = SfError.wrap(error);
|
|
54
|
+
if (wrapped.message.toLowerCase().includes('not found') || wrapped.message.toLowerCase().includes('no agent')) {
|
|
55
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_deactivate_agent_not_found' });
|
|
56
|
+
throw new SfError(messages.getMessage('error.agentNotFound', [apiNameFlag ?? 'unknown']), 'AgentNotFound', [], 2, wrapped);
|
|
57
|
+
}
|
|
58
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_deactivate_get_agent_failed' });
|
|
59
|
+
throw wrapped;
|
|
60
|
+
}
|
|
61
|
+
// Deactivate with error tracking
|
|
62
|
+
let result;
|
|
63
|
+
try {
|
|
64
|
+
result = await agent.deactivate();
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
const wrapped = SfError.wrap(error);
|
|
68
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_deactivate_failed' });
|
|
69
|
+
throw new SfError(messages.getMessage('error.deactivationFailed', [wrapped.message]), 'DeactivationFailed', [wrapped.message], 4, wrapped);
|
|
70
|
+
}
|
|
43
71
|
const metadata = await agent.getBotMetadata();
|
|
72
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_deactivate_success' });
|
|
44
73
|
this.log(`${metadata.DeveloperName} v${result.VersionNumber} deactivated.`);
|
|
45
74
|
return { success: true, version: result.VersionNumber };
|
|
46
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deactivate.js","sourceRoot":"","sources":["../../../src/commands/agent/deactivate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"deactivate.js","sourceRoot":"","sources":["../../../src/commands/agent/deactivate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAGjE,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,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,CAAC,UAAU,CAAC,0BAA0B,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAClE,oBAAoB,EACpB,CAAC,OAAO,CAAC,OAAO,CAAC,EACjB,CAAC,EACD,OAAO,CACR,CAAC;QACJ,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,cAAc,EAAE,CAAC;QAC9C,MAAM,SAAS,CAAC,WAAW,EAAE,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,0BAA0B,EAAE,CAAC,CAAC;QAEvF,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,aAAa,KAAK,MAAM,CAAC,aAAa,eAAe,CAAC,CAAC;QAC5E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC;IAC1D,CAAC"}
|
|
@@ -8,6 +8,8 @@ export default class AgentPreviewEnd extends SfCommand<AgentPreviewEndResult> {
|
|
|
8
8
|
static readonly description: string;
|
|
9
9
|
static readonly examples: string[];
|
|
10
10
|
static readonly requiresProject = true;
|
|
11
|
+
static readonly envVariablesSection: import("@oclif/core").HelpSection;
|
|
12
|
+
static readonly errorCodes: import("@oclif/core").HelpSection;
|
|
11
13
|
static readonly flags: {
|
|
12
14
|
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
15
|
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
|
|
17
|
-
import { Messages, SfError } from '@salesforce/core';
|
|
16
|
+
import { Flags, SfCommand, toHelpSection } from '@salesforce/sf-plugins-core';
|
|
17
|
+
import { Messages, SfError, Lifecycle, EnvironmentVariable } from '@salesforce/core';
|
|
18
18
|
import { Agent, ProductionAgent, ScriptAgent } from '@salesforce/agents';
|
|
19
19
|
import { getCachedSessionIds, removeCache, validatePreviewSession } from '../../../previewSessionStore.js';
|
|
20
20
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
@@ -24,6 +24,13 @@ export default class AgentPreviewEnd extends SfCommand {
|
|
|
24
24
|
static description = messages.getMessage('description');
|
|
25
25
|
static examples = messages.getMessages('examples');
|
|
26
26
|
static requiresProject = true;
|
|
27
|
+
static envVariablesSection = toHelpSection('ENVIRONMENT VARIABLES', EnvironmentVariable.SF_TARGET_ORG);
|
|
28
|
+
static errorCodes = toHelpSection('ERROR CODES', {
|
|
29
|
+
'Succeeded (0)': 'Preview session ended successfully and traces saved.',
|
|
30
|
+
'NotFound (2)': 'Agent not found, or no preview session exists for this agent.',
|
|
31
|
+
'PreviewEndFailed (4)': 'Failed to end the preview session.',
|
|
32
|
+
'SessionAmbiguous (5)': 'Multiple preview sessions found; specify --session-id to choose one.',
|
|
33
|
+
});
|
|
27
34
|
static flags = {
|
|
28
35
|
'target-org': Flags.requiredOrg(),
|
|
29
36
|
'api-version': Flags.orgApiVersion(),
|
|
@@ -44,30 +51,60 @@ export default class AgentPreviewEnd extends SfCommand {
|
|
|
44
51
|
async run() {
|
|
45
52
|
const { flags } = await this.parse(AgentPreviewEnd);
|
|
46
53
|
const conn = flags['target-org'].getConnection(flags['api-version']);
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
const agentIdentifier = flags['authoring-bundle'] ?? flags['api-name'];
|
|
55
|
+
// Initialize agent with error tracking
|
|
56
|
+
let agent;
|
|
57
|
+
try {
|
|
58
|
+
agent = flags['authoring-bundle']
|
|
59
|
+
? await Agent.init({ connection: conn, project: this.project, aabName: flags['authoring-bundle'] })
|
|
60
|
+
: await Agent.init({ connection: conn, project: this.project, apiNameOrId: flags['api-name'] });
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
const wrapped = SfError.wrap(error);
|
|
64
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_end_agent_not_found' });
|
|
65
|
+
throw new SfError(messages.getMessage('error.agentNotFound', [agentIdentifier]), 'AgentNotFound', [], 2, wrapped);
|
|
66
|
+
}
|
|
67
|
+
// Get or validate session ID
|
|
50
68
|
let sessionId = flags['session-id'];
|
|
51
69
|
if (sessionId === undefined) {
|
|
52
70
|
const cached = await getCachedSessionIds(this.project, agent);
|
|
53
71
|
if (cached.length === 0) {
|
|
54
|
-
|
|
72
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_end_no_session' });
|
|
73
|
+
throw new SfError(messages.getMessage('error.noSession'), 'PreviewSessionNotFound', [], 2);
|
|
55
74
|
}
|
|
56
75
|
if (cached.length > 1) {
|
|
57
|
-
|
|
76
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_end_multiple_sessions' });
|
|
77
|
+
throw new SfError(messages.getMessage('error.multipleSessions', [cached.join(', ')]), 'PreviewSessionAmbiguous', [], 5);
|
|
58
78
|
}
|
|
59
79
|
sessionId = cached[0];
|
|
60
80
|
}
|
|
61
81
|
agent.setSessionId(sessionId);
|
|
62
|
-
|
|
82
|
+
// Validate session
|
|
83
|
+
try {
|
|
84
|
+
await validatePreviewSession(agent);
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
const wrapped = SfError.wrap(error);
|
|
88
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_end_session_invalid' });
|
|
89
|
+
throw new SfError(messages.getMessage('error.sessionInvalid', [sessionId]), 'PreviewSessionInvalid', [], 2, wrapped);
|
|
90
|
+
}
|
|
63
91
|
const tracesPath = await agent.getHistoryDir();
|
|
64
92
|
await removeCache(agent);
|
|
65
|
-
|
|
66
|
-
|
|
93
|
+
// End preview with error tracking
|
|
94
|
+
try {
|
|
95
|
+
if (agent instanceof ScriptAgent) {
|
|
96
|
+
await agent.preview.end();
|
|
97
|
+
}
|
|
98
|
+
else if (agent instanceof ProductionAgent) {
|
|
99
|
+
await agent.preview.end('UserRequest');
|
|
100
|
+
}
|
|
67
101
|
}
|
|
68
|
-
|
|
69
|
-
|
|
102
|
+
catch (error) {
|
|
103
|
+
const wrapped = SfError.wrap(error);
|
|
104
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_end_failed' });
|
|
105
|
+
throw new SfError(messages.getMessage('error.endFailed', [wrapped.message]), 'PreviewEndFailed', [wrapped.message], 4, wrapped);
|
|
70
106
|
}
|
|
107
|
+
await Lifecycle.getInstance().emitTelemetry({ eventName: 'agent_preview_end_success' });
|
|
71
108
|
const result = { sessionId, tracesPath };
|
|
72
109
|
this.log(messages.getMessage('output.tracesPath', [tracesPath]));
|
|
73
110
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"end.js","sourceRoot":"","sources":["../../../../src/commands/agent/preview/end.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"end.js","sourceRoot":"","sources":["../../../../src/commands/agent/preview/end.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAE3G,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAA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ly description: string;
|
|
11
11
|
static readonly examples: string[];
|
|
12
12
|
static readonly requiresProject = true;
|
|
13
|
+
static readonly envVariablesSection: import("@oclif/core").HelpSection;
|
|
14
|
+
static readonly errorCodes: import("@oclif/core").HelpSection;
|
|
13
15
|
static readonly flags: {
|
|
14
16
|
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
17
|
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|