diff --git a/messages/agent.generate.test-spec.md b/messages/agent.generate.test-spec.md index 67c1bbb..abbcc96 100644 --- a/messages/agent.generate.test-spec.md +++ b/messages/agent.generate.test-spec.md @@ -55,4 +55,4 @@ File must be an AiEvaluationDefinition metadata XML file. # error.NoAgentsFound -No agents found in %s. +No published agents ('GenAiPlannerBundle', 'GenAiPlugin', 'Bot') found in %s. diff --git a/src/commands/agent/generate/test-spec.ts b/src/commands/agent/generate/test-spec.ts index 4fb026a..dfac863 100644 --- a/src/commands/agent/generate/test-spec.ts +++ b/src/commands/agent/generate/test-spec.ts @@ -346,22 +346,36 @@ export async function getPluginsAndFunctions( ); const parsedPlannerBundle = parser.parse(plannerBundleXml) as { GenAiPlannerBundle: { - genAiPlugins: Array< - | { - genAiPluginName: string; - } - | { genAiPluginName: string; genAiCustomizedPlugin: { genAiFunctions: Array<{ functionName: string }> } } - >; + localTopicLinks: Array<{ + genAiPluginName: string; + }>; + localTopics: Array<{ + fullName: string; + canEscalate: boolean; + description: string; + developerName: string; + language: string; + localDeveloperName: string; + masterLabel: string; + pluginType: string; + localActionLinks?: Array<{ functionName: string }>; + genAiPluginInstructions: { + description: string; + developerName: string; + language: string; + masterLabel: string; + sortOrder: number; + }; + }>; }; }; - genAiFunctions = ensureArray(parsedPlannerBundle.GenAiPlannerBundle.genAiPlugins) - .filter((f) => 'genAiCustomizedPlugin' in f) - .map( - ({ genAiCustomizedPlugin }) => - genAiCustomizedPlugin.genAiFunctions?.find((plugin) => plugin.functionName !== '')!.functionName - ); - - genAiPlugins = ensureArray(parsedPlannerBundle.GenAiPlannerBundle.genAiPlugins).reduce( + genAiFunctions = ensureArray( + parsedPlannerBundle.GenAiPlannerBundle.localTopics + .flatMap((topic) => topic.localActionLinks?.map((lal) => lal.functionName)) + .filter((f) => typeof f === 'string') + ); + + genAiPlugins = ensureArray(parsedPlannerBundle.GenAiPlannerBundle.localTopicLinks).reduce( (acc, { genAiPluginName }) => ({ ...acc, [genAiPluginName]: cs.getComponentFilenamesByNameAndType({ @@ -480,7 +494,7 @@ export default class AgentGenerateTestSpec extends SfCommand { const cs = await ComponentSetBuilder.build({ metadata: { - metadataEntries: ['GenAiPlanner', 'GenAiPlannerBundle', 'GenAiPlugin', 'Bot'], + metadataEntries: ['GenAiPlanner:*', 'GenAiPlannerBundle:*', 'GenAiPlugin:*', 'Bot:*'], directoryPaths, }, }); diff --git a/test/commands/agent/generate/test-spec.test.ts b/test/commands/agent/generate/test-spec.test.ts index d990ed3..f399115 100644 --- a/test/commands/agent/generate/test-spec.test.ts +++ b/test/commands/agent/generate/test-spec.test.ts @@ -87,29 +87,101 @@ describe('AgentGenerateTestSpec Helper Methods', () => { .rejects() .onThirdCall().resolves(` - - PluginName - - - PluginName2 - - - function1 - - - - - - + Helps internal employees manage company events, including event lookup, venue booking, and announcement drafting. + + ambiguous_question_16jKS000000CaeR + + + off_topic_16jKS000000CaeR + false + Redirect conversation to event-related topics when user request goes off-topic + off_topic_16jKS000000CaeR + + You are the Event Coordinator assistant, helping internal employees manage company events. Be professional, helpful, and concise. + instruction0_179KS000000Gn4A + en_US + instruction0_179KS000000Gn4A + 1 + + en_US + off_topic + Off Topic + Topic + + + event_management_16jKS000000CaeR + false + Handle event lookup, venue booking, and event announcement requests + event_management_16jKS000000CaeR + + You are the Event Coordinator assistant, helping internal employees manage company events. Be professional, helpful, and concise. + instruction0_179KS000000Gn49 + en_US + instruction0_179KS000000Gn49 + 1 + + en_US + + lookup_events_179KS000000Gn49 + + + book_venue_179KS000000Gn49 + + + lookup_events_179KS000000Gn49 + Search for upcoming company events by date or category + lookup_events_179KS000000Gn49 + EventLookupController + apex + false + false + lookup_events + Lookup Events + + + book_venue_179KS000000Gn49 + Check venue availability and reserve a room for an event + book_venue_179KS000000Gn49 + VenueBookingController + apex + false + false + book_venue + Book Venue + + event_management + Event Management + Topic + + + topic_selector_16jKS000000CaeR + false + Welcome the user and route to the appropriate topic based on their request + topic_selector_16jKS000000CaeR + + You are the Event Coordinator assistant, helping internal employees manage company events. Be professional, helpful, and concise. + instruction0_179KS000000Gn48 + en_US + instruction0_179KS000000Gn48 + 1 + + en_US + topic_selector + Topic Selector + Topic + + Event Coordinator + Atlas__ConcurrentMultiAgentOrchestration + `); const result = await getPluginsAndFunctions(name, cs); expect(result).to.deep.equal({ - genAiFunctions: ['function1'], + genAiFunctions: ['lookup_events_179KS000000Gn49', 'book_venue_179KS000000Gn49'], genAiPlugins: { - PluginName: 'PluginName.genAiPlugin-meta.xml', - PluginName2: 'PluginName2.genAiPlugin-meta.xml', + // eslint-disable-next-line camelcase + ambiguous_question_16jKS000000CaeR: 'PluginName.genAiPlugin-meta.xml', }, }); }); @@ -122,6 +194,22 @@ describe('AgentGenerateTestSpec Helper Methods', () => { fullName: 'myGenAiPlannerBundle', type: { name: 'GenAiPlannerBundle', id: 'genaiplannerbundle', directoryName: 'genaiplannerbundle' }, }, + { + fullName: 'ambiguous_question_16jKS000000CaeR', + type: { name: 'GenAiPlugin', id: 'genaiplugin', directoryName: 'genaiplugin' }, + }, + { + fullName: 'event_management_16jKS000000CaeR', + type: { name: 'GenAiPlugin', id: 'genaiplugin', directoryName: 'genaiplugin' }, + }, + { + fullName: 'off_topic_16jKS000000CaeR', + type: { name: 'GenAiPlugin', id: 'genaiplugin', directoryName: 'genaiplugin' }, + }, + { + fullName: 'topic_selector_16jKS000000CaeR', + type: { name: 'GenAiPlugin', id: 'genaiplugin', directoryName: 'genaiplugin' }, + }, ]); $$.stub(cs, 'getComponentFilenamesByNameAndType') @@ -130,7 +218,15 @@ describe('AgentGenerateTestSpec Helper Methods', () => { .onSecondCall() .rejects() // genAiPlanner attempt .onThirdCall() - .returns(['myGenAiPlannerBundle.genAiPlannerBundle-meta.xml']); + .returns(['myGenAiPlannerBundle.genAiPlannerBundle-meta.xml']) + .onCall(3) + .returns(['ambiguous_question.genAiPlugin-meta.xml']) + .onCall(4) + .returns(['event_management.genAiPlugin-meta.xml']) + .onCall(5) + .returns(['off_topic.genAiPlugin-meta.xml']) + .onCall(6) + .returns(['topic_selector.genAiPlugin-meta.xml']); $$.stub(fs.promises, 'readFile') .onFirstCall() @@ -149,30 +245,95 @@ describe('AgentGenerateTestSpec Helper Methods', () => { .resolves( ` - - - false - System level instructions for config. - - ... - instruction_0_1756241650786 - - instruction_0_1756241650786 - + Helps internal employees manage company events, including event lookup, venue booking, and announcement drafting. + + ambiguous_question_16jKS000000CaeR + + + event_management_16jKS000000CaeR + + + off_topic_16jKS000000CaeR + + + topic_selector_16jKS000000CaeR + + + off_topic_16jKS000000CaeR + false + Redirect conversation to event-related topics when user request goes off-topic + off_topic_16jKS000000CaeR + + You are the Event Coordinator assistant, helping internal employees manage company events. Be professional, helpful, and concise. + instruction0_179KS000000Gn4A + en_US + instruction0_179KS000000Gn4A + 1 + + en_US + off_topic + Off Topic + Topic + + + event_management_16jKS000000CaeR + false + Handle event lookup, venue booking, and event announcement requests + event_management_16jKS000000CaeR + + You are the Event Coordinator assistant, helping internal employees manage company events. Be professional, helpful, and concise. + instruction0_179KS000000Gn49 + en_US + instruction0_179KS000000Gn49 + 1 + + en_US + event_management + Event Management + Topic + + + topic_selector_16jKS000000CaeR + false + Welcome the user and route to the appropriate topic based on their request + topic_selector_16jKS000000CaeR + + You are the Event Coordinator assistant, helping internal employees manage company events. Be professional, helpful, and concise. + instruction0_179KS000000Gn48 + en_US + instruction0_179KS000000Gn48 + 1 + + en_US + topic_selector + Topic Selector + Topic + + + ambiguous_question_16jKS000000CaeR + false + Ask for clarification when user request is unclear + ambiguous_question_16jKS000000CaeR + + You are the Event Coordinator assistant, helping internal employees manage company events. Be professional, helpful, and concise. + instruction0_179KS000000Gn47 en_US - B2C Global Instructions - B2CGlobalInstructions1 - Topic - Define system-level instructions, including hardcoded values. - - COMMERCE_SHOPPER_COPILOT_B2C__B2CGlobalInstructions - + instruction0_179KS000000Gn47 + 1 + + en_US + ambiguous_question + Ambiguous Question + Topic + + Event Coordinator + Atlas__ConcurrentMultiAgentOrchestration ` ); const result = await getPluginsAndFunctions(name, cs); - expect(result.genAiFunctions).to.deep.equal([undefined]); + expect(result.genAiFunctions).to.deep.equal([]); }); });