From 6579537a8b9522d10b9373ddfc41dc2535c30f87 Mon Sep 17 00:00:00 2001 From: Willie Ruemmele Date: Wed, 18 Feb 2026 15:34:00 -0700 Subject: [PATCH 1/3] fix: allow --use-live-actions to affect --authoring-bundle --- src/commands/agent/preview.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/commands/agent/preview.ts b/src/commands/agent/preview.ts index 3026841..d46faa3 100644 --- a/src/commands/agent/preview.ts +++ b/src/commands/agent/preview.ts @@ -86,6 +86,7 @@ export default class AgentPreview extends SfCommand { if (aabName) { // user specified --authoring-bundle, use the API name directly selectedAgent = await Agent.init({ connection: conn, project: this.project!, aabName }); + selectedAgent.preview.setMockMode(flags['use-live-actions'] ? 'Live Test' : 'Mock'); } else if (apiNameOrId) { selectedAgent = await Agent.init({ connection: conn, project: this.project!, apiNameOrId }); } else { @@ -173,9 +174,7 @@ export const getPreviewChoiceLabel = (agent: PreviewableAgent): string => ? `${agent.developerName ?? agent.name} (Published)` : `${agent.name} (Agent Script)`; -export const getPreviewChoices = ( - agents: PreviewableAgent[] -): Array<{ name: string; value: PreviewableAgent }> => +export const getPreviewChoices = (agents: PreviewableAgent[]): Array<{ name: string; value: PreviewableAgent }> => sortPreviewableAgents(agents).map((agent) => ({ name: getPreviewChoiceLabel(agent), value: agent, From dcd911620f9a544747e16f6a630bf67c2355ed50 Mon Sep 17 00:00:00 2001 From: Willie Ruemmele Date: Tue, 24 Feb 2026 14:50:08 -0700 Subject: [PATCH 2/3] chore: add test, bump agents --- package.json | 2 +- test/commands/agent/preview/start.test.ts | 100 ++++++++++++++++++++++ yarn.lock | 73 ++++++++++++++-- 3 files changed, 165 insertions(+), 10 deletions(-) create mode 100644 test/commands/agent/preview/start.test.ts diff --git a/package.json b/package.json index b25cefd..ecd9ac4 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "@inquirer/prompts": "^7.10.1", "@oclif/core": "^4", "@oclif/multi-stage-output": "^0.8.29", - "@salesforce/agents": "^0.23.1", + "@salesforce/agents": "^0.23.4", "@salesforce/core": "^8.25.1", "@salesforce/kit": "^3.2.4", "@salesforce/sf-plugins-core": "^12.2.6", diff --git a/test/commands/agent/preview/start.test.ts b/test/commands/agent/preview/start.test.ts new file mode 100644 index 0000000..f71c493 --- /dev/null +++ b/test/commands/agent/preview/start.test.ts @@ -0,0 +1,100 @@ +/* + * Copyright 2026, Salesforce, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-explicit-any */ + +import { join } from 'node:path'; +import { expect } from 'chai'; +import sinon from 'sinon'; +import esmock from 'esmock'; +import { TestContext } from '@salesforce/core/testSetup'; +import { SfProject } from '@salesforce/core'; + +const MOCK_PROJECT_DIR = join(process.cwd(), 'test', 'mock-projects', 'agent-generate-template'); + +describe('agent preview start', () => { + const $$ = new TestContext(); + let setMockModeStub: sinon.SinonStub; + let initStub: sinon.SinonStub; + let createCacheStub: sinon.SinonStub; + let AgentPreviewStart: any; + + beforeEach(async () => { + setMockModeStub = $$.SANDBOX.stub(); + const mockPreview = { + setMockMode: setMockModeStub, + start: $$.SANDBOX.stub().resolves({ sessionId: 'test-session-id' }), + }; + class MockScriptAgent { + public preview = mockPreview; + public name = 'TestAgent'; + } + const mockAgent = new MockScriptAgent(); + initStub = $$.SANDBOX.stub().resolves(mockAgent); + createCacheStub = $$.SANDBOX.stub().resolves(); + + const mod = await esmock('../../../../src/commands/agent/preview/start.js', { + '@salesforce/agents': { + Agent: { init: initStub }, + ScriptAgent: MockScriptAgent, + ProductionAgent: class ProductionAgent {}, + }, + '../../../../src/previewSessionStore.js': { + createCache: createCacheStub, + }, + }); + + AgentPreviewStart = mod.default; + + $$.inProject(true); + + const mockProject = { + getPath: () => MOCK_PROJECT_DIR, + getDefaultPackage: () => ({ + fullPath: join(MOCK_PROJECT_DIR, 'force-app'), + }), + } as unknown as SfProject; + + $$.SANDBOX.stub(SfProject, 'resolve').resolves(mockProject); + $$.SANDBOX.stub(SfProject, 'getInstance').returns(mockProject); + }); + + afterEach(() => { + $$.restore(); + }); + + describe('setMockMode', () => { + it('should call setMockMode with "Mock" when --use-live-actions is not set', async () => { + await AgentPreviewStart.run(['--authoring-bundle', 'MyAgent', '--target-org', 'test@org.com']); + + expect(setMockModeStub.calledOnce).to.be.true; + expect(setMockModeStub.firstCall.args[0]).to.equal('Mock'); + }); + + it('should call setMockMode with "Live Test" when --use-live-actions is set', async () => { + await AgentPreviewStart.run([ + '--authoring-bundle', + 'MyAgent', + '--use-live-actions', + '--target-org', + 'test@org.com', + ]); + + expect(setMockModeStub.calledOnce).to.be.true; + expect(setMockModeStub.firstCall.args[0]).to.equal('Live Test'); + }); + }); +}); diff --git a/yarn.lock b/yarn.lock index 43bc375..9f6b9ea 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1743,16 +1743,16 @@ resolved "https://registry.yarnpkg.com/@rtsao/scc/-/scc-1.1.0.tgz#927dd2fae9bc3361403ac2c7a00c32ddce9ad7e8" integrity sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g== -"@salesforce/agents@^0.23.1": - version "0.23.1" - resolved "https://registry.yarnpkg.com/@salesforce/agents/-/agents-0.23.1.tgz#a570619c92eb9103fc3b0280e8895e1cc41d6812" - integrity sha512-mQ140OBRbjIpf7/rgpMuMS4s5O0n8bkS16EdDFK6VZ87R66/m5sLb+T2VzSU7d9fS99O8ZC4/yy1X0UcbLDGPg== +"@salesforce/agents@^0.23.4": + version "0.23.4" + resolved "https://registry.yarnpkg.com/@salesforce/agents/-/agents-0.23.4.tgz#2f4537ebd033f0e63d0929f4743a918e8460ff8f" + integrity sha512-MKoiQvEX4fBggHDSEntFUzIheKd2NrTCaaWe+ExQoegqToN32RW1YqfeNQjayt4WpMNCnOAJ2jEHN4ecSu6HvQ== dependencies: - "@salesforce/core" "^8.25.1" + "@salesforce/core" "^8.26.2" "@salesforce/kit" "^3.2.4" - "@salesforce/source-deploy-retrieve" "^12.31.10" + "@salesforce/source-deploy-retrieve" "^12.31.12" "@salesforce/types" "^1.6.0" - fast-xml-parser "^5.3.5" + fast-xml-parser "^5.3.6" nock "^13.5.6" yaml "^2.8.2" @@ -1797,6 +1797,31 @@ ts-retry-promise "^0.8.1" zod "^4.1.12" +"@salesforce/core@^8.26.2": + version "8.26.2" + resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-8.26.2.tgz#1b82f7bc8e8598ba1ed8779759a5188b74841445" + integrity sha512-P1otybl1d+sXg5FORl3PD82TzaOOP5aH1j0UVkpGf1p4BLw6VD0mJekS4mDc0pz6UKK2iIt0CFxXAEMKa/YtBA== + dependencies: + "@jsforce/jsforce-node" "^3.10.13" + "@salesforce/kit" "^3.2.4" + "@salesforce/ts-types" "^2.0.12" + ajv "^8.18.0" + change-case "^4.1.2" + fast-levenshtein "^3.0.0" + faye "^1.4.1" + form-data "^4.0.4" + js2xmlparser "^4.0.1" + jsonwebtoken "9.0.3" + jszip "3.10.1" + memfs "^4.30.1" + pino "^9.7.0" + pino-abstract-transport "^1.2.0" + pino-pretty "^11.3.0" + proper-lockfile "^4.1.2" + semver "^7.7.3" + ts-retry-promise "^0.8.1" + zod "^4.1.12" + "@salesforce/dev-config@^4.3.1": version "4.3.2" resolved "https://registry.yarnpkg.com/@salesforce/dev-config/-/dev-config-4.3.2.tgz#10047e2b8d289c93f157ab4243a1b1de57f2d6a2" @@ -1894,7 +1919,7 @@ cli-progress "^3.12.0" terminal-link "^3.0.0" -"@salesforce/source-deploy-retrieve@^12.31.10", "@salesforce/source-deploy-retrieve@^12.31.11": +"@salesforce/source-deploy-retrieve@^12.31.11": version "12.31.11" resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-12.31.11.tgz#58c51ebb54bd2fc2242c6374ce25fc3a3b71aea0" integrity sha512-7LGWY4GsXl8iFz/ZvZrRdufnefQ5iezi0Pm1YQVRmJfqpBY/4kz/98gRW65h3XERASuuvAfVRLXfPVKtCHW4yA== @@ -1914,6 +1939,26 @@ proxy-agent "^6.4.0" yaml "^2.8.1" +"@salesforce/source-deploy-retrieve@^12.31.12": + version "12.31.14" + resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-12.31.14.tgz#6ed0a2fdb9a14d60ed64a2dd8fdc18c16af143a6" + integrity sha512-tLnTCG6t+d+MN8pGijF6nL4lsqE37FaBINZZvyd+IDAw+7eWffFqIXK/nNyQ1ZARTNeHOs5K/NlNXNBp5+x/YQ== + dependencies: + "@salesforce/core" "^8.26.2" + "@salesforce/kit" "^3.2.4" + "@salesforce/ts-types" "^2.0.12" + "@salesforce/types" "^1.6.0" + fast-levenshtein "^3.0.0" + fast-xml-parser "^5.3.6" + got "^11.8.6" + graceful-fs "^4.2.11" + ignore "^5.3.2" + jszip "^3.10.1" + mime "2.6.0" + minimatch "^9.0.5" + proxy-agent "^6.4.0" + yaml "^2.8.1" + "@salesforce/ts-types@^2.0.11", "@salesforce/ts-types@^2.0.12": version "2.0.12" resolved "https://registry.yarnpkg.com/@salesforce/ts-types/-/ts-types-2.0.12.tgz#60420622812a7ec7e46d220667bc29b42dc247ff" @@ -2992,6 +3037,16 @@ ajv@^8.11.0, ajv@^8.17.1: json-schema-traverse "^1.0.0" require-from-string "^2.0.2" +ajv@^8.18.0: + version "8.18.0" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.18.0.tgz#8864186b6738d003eb3a933172bb3833e10cefbc" + integrity sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A== + dependencies: + fast-deep-equal "^3.1.3" + fast-uri "^3.0.1" + json-schema-traverse "^1.0.0" + require-from-string "^2.0.2" + ansi-colors@^4.1.3: version "4.1.3" resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.3.tgz#37611340eb2243e70cc604cad35d63270d48781b" @@ -4723,7 +4778,7 @@ fast-xml-parser@5.3.4: dependencies: strnum "^2.1.0" -fast-xml-parser@^5.3.4, fast-xml-parser@^5.3.5, fast-xml-parser@^5.3.6: +fast-xml-parser@^5.3.4, fast-xml-parser@^5.3.6: version "5.3.6" resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-5.3.6.tgz#85a69117ca156b1b3c52e426495b6de266cb6a4b" integrity sha512-QNI3sAvSvaOiaMl8FYU4trnEzCwiRr8XMWgAHzlrWpTSj+QaCSvOf1h82OEP1s4hiAXhnbXSyFWCf4ldZzZRVA== From ac363eec503c30b771d995ac9acf05b875b19150 Mon Sep 17 00:00:00 2001 From: Willie Ruemmele Date: Tue, 24 Feb 2026 14:53:23 -0700 Subject: [PATCH 3/3] test: fix assertions --- test/commands/agent/generate/authoring-bundle.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/commands/agent/generate/authoring-bundle.test.ts b/test/commands/agent/generate/authoring-bundle.test.ts index 0db9c8b..412604d 100644 --- a/test/commands/agent/generate/authoring-bundle.test.ts +++ b/test/commands/agent/generate/authoring-bundle.test.ts @@ -473,7 +473,7 @@ describe('agent generate authoring-bundle', () => { ]); expect.fail('Expected error'); } catch (error) { - expect((error as Error).message).to.include('you must specify --name'); + expect((error as Error).message).to.include('you must also specify --name'); } }); @@ -490,7 +490,7 @@ describe('agent generate authoring-bundle', () => { ]); expect.fail('Expected error'); } catch (error) { - expect((error as Error).message).to.include('you must specify either --spec or --no-spec'); + expect((error as Error).message).to.include('you must also specify either --spec or --no-spec'); } });