The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Export agent modelConfiguration and isSystem for twenty app pull (#29102)
Charles Bochet35c04ddab41d
diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-flat-agent-to-agent-manifest.util.spec.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-flat-agent-to-agent-manifest.util.spec.tsindex 345564f381d..f2115312ebf 100644--- a/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-flat-agent-to-agent-manifest.util.spec.ts+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/__tests__/from-flat-agent-to-agent-manifest.util.spec.ts@@ -13,9 +13,7 @@ const CRON_TRIGGER_UID = '44444444-4444-4444-8444-444444444444';const DATABASE_EVENT_TRIGGER_UID = '55555555-5555-4555-8555-555555555555';const NOW = '2026-09-14T10:00:00.000Z';-const AGENT_MANIFEST: Required<- Omit<AgentManifest, 'modelConfiguration' | 'isSystem'>-> = {+const AGENT_MANIFEST: Required<AgentManifest> = {universalIdentifier: AGENT_UID,name: 'lead-scorer',label: 'Lead Scorer',@@ -32,6 +30,11 @@ const AGENT_MANIFEST: Required<additionalProperties: false,},},+ modelConfiguration: {+ webSearch: { enabled: true },+ twitterSearch: { enabled: false, configuration: { maxResults: 5 } },+ },+ isSystem: true,roleUniversalIdentifier: ROLE_UID,triggers: [{@@ -106,7 +109,7 @@ describe('fromFlatAgentToAgentManifest', () => {).toBeUndefined();});- it('should omit what the forward conversion defaults: icon, description, the workspace default model, triggers and the role', () => {+ it('should omit what the forward conversion defaults: icon, description, the workspace default model, model configuration, isSystem, triggers and the role', () => {expect(fromFlatAgentToAgentManifest({flatAgent: forward(MINIMAL_AGENT_MANIFEST),diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/from-flat-agent-to-agent-manifest.util.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/from-flat-agent-to-agent-manifest.util.tsindex ee2c97d9748..b05659c1654 100644--- a/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/from-flat-agent-to-agent-manifest.util.ts+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/converters/from-flat-agent-to-agent-manifest.util.ts@@ -34,6 +34,8 @@ export const fromFlatAgentToAgentManifest = ({| 'prompt'| 'modelId'| 'responseFormat'+ | 'modelConfiguration'+ | 'isSystem'| 'triggers'>;roleUniversalIdentifier?: string;@@ -52,6 +54,10 @@ export const fromFlatAgentToAgentManifest = ({...(isDefined(flatAgent.responseFormat)? { responseFormat: flatAgent.responseFormat }: {}),+ ...(isDefined(flatAgent.modelConfiguration)+ ? { modelConfiguration: flatAgent.modelConfiguration }+ : {}),+ ...(flatAgent.isSystem ? { isSystem: true } : {}),...(isDefined(roleUniversalIdentifier) ? { roleUniversalIdentifier } : {}),...(isNonEmptyArray(flatAgent.triggers)? {diff --git a/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/__tests__/reconstruct-agents-manifest.util.spec.ts b/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/__tests__/reconstruct-agents-manifest.util.spec.tsindex 21ba9391691..8d1c488bd28 100644--- a/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/__tests__/reconstruct-agents-manifest.util.spec.ts+++ b/packages/twenty-server/src/engine/core-modules/application/application-manifest/utils/__tests__/reconstruct-agents-manifest.util.spec.ts@@ -172,6 +172,7 @@ const applicationAgents = [buildFlatAgent(WORKSPACE_ROLE_AGENT_UNIVERSAL_IDENTIFIER),buildFlatAgent(CONFIGURED_AGENT_UNIVERSAL_IDENTIFIER, {modelConfiguration: { webSearch: { enabled: true } },+ isSystem: true,}),buildFlatAgent(DELETED_AGENT_UNIVERSAL_IDENTIFIER, { deletedAt: NOW }),buildFlatAgent(UNASSIGNED_AGENT_UNIVERSAL_IDENTIFIER),@@ -293,12 +294,29 @@ describe('reconstructAgentsManifest', () => {).toBe(ApplicationExportCoverageStatus.EXPORTED);});+ it('should export an agent with its model configuration and system flag', () => {+ expect(+ agents.find(+ ({ universalIdentifier }) =>+ universalIdentifier === CONFIGURED_AGENT_UNIVERSAL_IDENTIFIER,+ ),+ ).toEqual({+ ...buildAgentManifest(CONFIGURED_AGENT_UNIVERSAL_IDENTIFIER),+ modelConfiguration: { webSearch: { enabled: true } },+ isSystem: true,+ });+ expect(+ findCoverage('agent', CONFIGURED_AGENT_UNIVERSAL_IDENTIFIER)?.status,+ ).toBe(ApplicationExportCoverageStatus.EXPORTED);+ });+it('should export an agent bound to a role outside the application and one without a role', () => {expect(agents.map(({ universalIdentifier }) => universalIdentifier),).toEqual([SUPPORT_AGENT_UNIVERSAL_IDENTIFIER,STANDARD_ROLE_AGENT_UNIVERSAL_IDENTIFIER,+ CONFIGURED_AGENT_UNIVERSAL_IDENTIFIER,UNASSIGNED_AGENT_UNIVERSAL_IDENTIFIER,]);expect(@@ -330,10 +348,6 @@ describe('reconstructAgentsManifest', () => {WORKSPACE_ROLE_AGENT_UNIVERSAL_IDENTIFIER,'agent whose role was assigned outside its definition',],- [- CONFIGURED_AGENT_UNIVERSAL_IDENTIFIER,- 'agent with values a definition cannot express: modelConfiguration',- ],])('should report agent %s as unsupported: %s',(universalIdentifier, reason) => {