@salesforce/plugin-agent 1.4.0 → 1.5.1

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.
Files changed (34) hide show
  1. package/README.md +67 -12
  2. package/lib/commands/agent/create.d.ts +1 -0
  3. package/lib/commands/agent/create.js +28 -19
  4. package/lib/commands/agent/create.js.map +1 -1
  5. package/lib/commands/agent/generate/spec.js +1 -1
  6. package/lib/commands/agent/generate/spec.js.map +1 -1
  7. package/lib/commands/agent/preview.d.ts +15 -0
  8. package/lib/commands/agent/preview.js +37 -0
  9. package/lib/commands/agent/preview.js.map +1 -0
  10. package/lib/commands/agent/test/results.d.ts +2 -1
  11. package/lib/commands/agent/test/results.js +11 -5
  12. package/lib/commands/agent/test/results.js.map +1 -1
  13. package/lib/commands/agent/test/resume.d.ts +2 -1
  14. package/lib/commands/agent/test/resume.js +11 -5
  15. package/lib/commands/agent/test/resume.js.map +1 -1
  16. package/lib/commands/agent/test/run.d.ts +2 -1
  17. package/lib/commands/agent/test/run.js +11 -5
  18. package/lib/commands/agent/test/run.js.map +1 -1
  19. package/lib/components/agent-preview-react.d.ts +9 -0
  20. package/lib/components/agent-preview-react.js +56 -0
  21. package/lib/components/agent-preview-react.js.map +1 -0
  22. package/lib/flags.d.ts +5 -1
  23. package/lib/flags.js +6 -1
  24. package/lib/flags.js.map +1 -1
  25. package/lib/handleTestResults.d.ts +8 -0
  26. package/lib/handleTestResults.js +44 -0
  27. package/lib/handleTestResults.js.map +1 -0
  28. package/messages/agent.preview.md +20 -0
  29. package/messages/shared.md +8 -0
  30. package/npm-shrinkwrap.json +12899 -5679
  31. package/oclif.lock +1170 -25
  32. package/oclif.manifest.json +103 -4
  33. package/package.json +13 -5
  34. package/schemas/agent-preview.json +9 -0
@@ -0,0 +1,56 @@
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 React from 'react';
8
+ import { Box, Text } from 'ink';
9
+ import figures from '@inquirer/figures';
10
+ import TextInput from 'ink-text-input';
11
+ import { sleep } from '@salesforce/kit';
12
+ /**
13
+ * Ideas:
14
+ * - Limit height based on terminal height
15
+ * - Add keystroke to clear chat
16
+ * - Add keystroke to scroll up
17
+ * - Add keystroke to scroll down
18
+ */
19
+ export function AgentPreviewReact() {
20
+ const [comments, setComments] = React.useState([]);
21
+ const [query, setQuery] = React.useState('');
22
+ return (React.createElement(Box, { flexDirection: "column" },
23
+ comments.length > 0 && (React.createElement(Box, { flexDirection: "column" },
24
+ comments.map(({ timestamp, role, content }, idx) => (React.createElement(Box, { key: role + '__' + timestamp.toISOString() + '__' + idx.toString(), alignItems: role === 'user' ? 'flex-end' : 'flex-start', flexDirection: "column" },
25
+ React.createElement(Box, { flexDirection: "row", columnGap: 1 },
26
+ React.createElement(Text, null, role === 'user' ? 'You' : role),
27
+ React.createElement(Text, { color: "gray" }, timestamp.toLocaleString())),
28
+ React.createElement(Box, { width: Math.min(process.stdout.columns - 4, content.length + 4), borderStyle: "round", paddingLeft: 1, paddingRight: 1 },
29
+ React.createElement(Text, null, content))))),
30
+ React.createElement(Box, { paddingLeft: 1, paddingRight: 1 },
31
+ React.createElement(Text, { dimColor: true }, '─'.repeat(process.stdout.columns - 2))))),
32
+ React.createElement(Box, null,
33
+ React.createElement(Text, null,
34
+ figures.pointer,
35
+ " "),
36
+ React.createElement(TextInput, { showCursor: true, value: query, placeholder: "Start typing\u2026", onChange: setQuery,
37
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
38
+ onSubmit: async (content) => {
39
+ if (!content)
40
+ return;
41
+ setQuery('');
42
+ setComments((prev) => [...prev, { role: 'user', content, timestamp: new Date() }]);
43
+ await sleep(1000);
44
+ setComments((prev) => {
45
+ const lastComment = prev[prev.length - 1];
46
+ // TODO - use agents library for generations
47
+ return (Math.random() * 2) % 2 > 1
48
+ ? [
49
+ ...prev,
50
+ { role: 'system', content: "I'm sorry, I can't help with this request", timestamp: new Date() },
51
+ ]
52
+ : [...prev, { ...lastComment, role: 'system', content: 'We have a scuba class at 9:30 AM' }];
53
+ });
54
+ } }))));
55
+ }
56
+ //# sourceMappingURL=agent-preview-react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-preview-react.js","sourceRoot":"","sources":["../../src/components/agent-preview-react.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,QAAQ,CAC5C,EAAE,CACH,CAAC;IACF,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC7C,OAAO,CACL,oBAAC,GAAG,IAAC,aAAa,EAAC,QAAQ;QACxB,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,CACtB,oBAAC,GAAG,IAAC,aAAa,EAAC,QAAQ;YACxB,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CACnD,oBAAC,GAAG,IACF,GAAG,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC,WAAW,EAAE,GAAG,IAAI,GAAG,GAAG,CAAC,QAAQ,EAAE,EAClE,UAAU,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,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AE,CAAC,CAAC,CAAC;oBACnF,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;oBAElB,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE;wBACnB,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;wBAC1C,4CAA4C;wBAC5C,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;4BAChC,CAAC,CAAC;gCACE,GAAG,IAAI;gCACP,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,2CAA2C,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE;6BAChG;4BACH,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,EAAE,GAAG,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,kCAAkC,EAAE,CAAC,CAAC;oBACjG,CAAC,CAAC,CAAC;gBACL,CAAC,GACD,CACE,CACF,CACP,CAAC;AACJ,CAAC"}
package/lib/flags.d.ts CHANGED
@@ -1,4 +1,8 @@
1
- export declare const resultFormatFlag: import("@oclif/core/interfaces").FlagDefinition<"json" | "human", import("@oclif/core/interfaces").CustomOptions, {
1
+ export declare const resultFormatFlag: import("@oclif/core/interfaces").FlagDefinition<"json" | "human" | "junit", import("@oclif/core/interfaces").CustomOptions, {
2
2
  multiple: false;
3
3
  requiredOrDefaulted: true;
4
4
  }>;
5
+ export declare const testOutputDirFlag: import("@oclif/core/interfaces").FlagDefinition<string, import("@oclif/core/interfaces").CustomOptions, {
6
+ multiple: false;
7
+ requiredOrDefaulted: false;
8
+ }>;
package/lib/flags.js CHANGED
@@ -12,10 +12,15 @@ export const resultFormatFlag = Flags.option({
12
12
  options: [
13
13
  'json',
14
14
  'human',
15
+ 'junit',
15
16
  // 'tap',
16
- // 'junit'
17
17
  ],
18
18
  default: 'human',
19
19
  summary: messages.getMessage('flags.result-format.summary'),
20
20
  });
21
+ export const testOutputDirFlag = Flags.custom({
22
+ char: 'f',
23
+ description: messages.getMessage('flags.output-dir.description'),
24
+ summary: messages.getMessage('flags.output-dir.summary'),
25
+ });
21
26
  //# sourceMappingURL=flags.js.map
package/lib/flags.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"flags.js","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACpD,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,QAAQ,CAAC,CAAC;AAE7E,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,CAAC;IAC3C,OAAO,EAAE;QACP,MAAM;QACN,OAAO;QACP,SAAS;QACT,UAAU;KACF;IACV,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,6BAA6B,CAAC;CAC5D,CAAC,CAAC"}
1
+ {"version":3,"file":"flags.js","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACpD,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,QAAQ,CAAC,CAAC;AAE7E,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,CAAC;IAC3C,OAAO,EAAE;QACP,MAAM;QACN,OAAO;QACP,OAAO;QACP,SAAS;KACD;IACV,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,6BAA6B,CAAC;CAC5D,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,CAAS;IACpD,IAAI,EAAE,GAAG;IACT,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,8BAA8B,CAAC;IAChE,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,0BAA0B,CAAC;CACzD,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { AgentTestDetailsResponse } from '@salesforce/agents';
2
+ export declare function handleTestResults({ id, format, results, jsonEnabled, outputDir, }: {
3
+ id: string;
4
+ format: 'human' | 'json' | 'junit';
5
+ results: AgentTestDetailsResponse | undefined;
6
+ jsonEnabled: boolean;
7
+ outputDir?: string;
8
+ }): Promise<void>;
@@ -0,0 +1,44 @@
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 { writeFile, mkdir } from 'node:fs/promises';
9
+ import { jsonFormat, humanFormat, junitFormat } from '@salesforce/agents';
10
+ import { Ux } from '@salesforce/sf-plugins-core/Ux';
11
+ async function writeFileToDir(outputDir, fileName, content) {
12
+ // if directory doesn't exist, create it
13
+ await mkdir(outputDir, { recursive: true });
14
+ await writeFile(join(outputDir, fileName), content);
15
+ }
16
+ export async function handleTestResults({ id, format, results, jsonEnabled, outputDir, }) {
17
+ if (!results) {
18
+ // do nothing since there are no results to handle
19
+ return;
20
+ }
21
+ const ux = new Ux({ jsonEnabled });
22
+ if (format === 'human') {
23
+ const formatted = await humanFormat(results);
24
+ ux.log(formatted);
25
+ if (outputDir) {
26
+ await writeFileToDir(outputDir, `test-result-${id}.txt`, formatted);
27
+ }
28
+ }
29
+ if (format === 'json') {
30
+ const formatted = await jsonFormat(results);
31
+ ux.log(formatted);
32
+ if (outputDir) {
33
+ await writeFileToDir(outputDir, `test-result-${id}.json`, formatted);
34
+ }
35
+ }
36
+ if (format === 'junit') {
37
+ const formatted = await junitFormat(results);
38
+ ux.log(formatted);
39
+ if (outputDir) {
40
+ await writeFileToDir(outputDir, `test-result-${id}.xml`, formatted);
41
+ }
42
+ }
43
+ }
44
+ //# sourceMappingURL=handleTestResults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleTestResults.js","sourceRoot":"","sources":["../src/handleTestResults.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAA4B,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACpG,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEpD,KAAK,UAAU,cAAc,CAAC,SAAiB,EAAE,QAAgB,EAAE,OAAe;IAChF,wCAAwC;IACxC,MAAM,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAE5C,MAAM,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,EACtC,EAAE,EACF,MAAM,EACN,OAAO,EACP,WAAW,EACX,SAAS,GAOV;IACC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,kDAAkD;QAClD,OAAO;IACT,CAAC;IAED,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;IAEnC,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;QACvB,MAAM,SAAS,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,CAAC;QAC7C,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAClB,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,cAAc,CAAC,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;IAED,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC;QAC5C,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAClB,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,cAAc,CAAC,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;IAED,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;QACvB,MAAM,SAAS,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,CAAC;QAC7C,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAClB,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,cAAc,CAAC,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,20 @@
1
+ # summary
2
+
3
+ Interact with an active agent, as a user would, to preview responses
4
+
5
+ # description
6
+
7
+ XXX
8
+
9
+ # flags.name.summary
10
+
11
+ The name of the agent you want to preview
12
+
13
+ # flags.name.description
14
+
15
+ the API name of the agent? (TBD based on agents library)
16
+
17
+ # examples
18
+
19
+ - <%= config.bin %> <%= command.id %> --agent HelpDeskAgent
20
+ - <%= config.bin %> <%= command.id %> --agent ConciergeAgent --target-org production
@@ -1,3 +1,11 @@
1
1
  # flags.result-format.summary
2
2
 
3
3
  Format of the test run results.
4
+
5
+ # flags.output-dir.summary
6
+
7
+ Directory to write the test results to.
8
+
9
+ # flags.output-dir.description
10
+
11
+ If test run is complete, write the results to the specified directory. If the tests are still running, the test results will not be written.