diff --git a/packages/deploy/src/deploy.test.ts b/packages/deploy/src/deploy.test.ts index 81192bf..2ab6d49 100644 --- a/packages/deploy/src/deploy.test.ts +++ b/packages/deploy/src/deploy.test.ts @@ -87,6 +87,16 @@ export default defineAgent({ }); `; +const GMAIL_ALIAS_COLLISION_AGENT_SRC = `import { defineAgent } from '@agentworkforce/runtime'; +export default defineAgent({ + triggers: { + 'google-mail': [{ on: 'file.created', match: 'from-alias' }], + gmail: [{ on: 'file.created', match: 'from-canonical' }] + }, + handler: async () => {} +}); +`; + async function withTempPersona( persona: Record, agentSource = SCHEDULE_AGENT_SRC @@ -403,6 +413,25 @@ test('preflightPersona refuses when the agent triggers a provider the persona do } }); +test('preflightPersona merges trigger lists when an alias collides with its canonical provider', async () => { + const { personaPath, cleanup } = await withTempPersona( + basePersonaJson({ integrations: { 'google-mail': {}, gmail: {} } }), + GMAIL_ALIAS_COLLISION_AGENT_SRC + ); + try { + const pre = await preflightPersona(personaPath); + assert.deepEqual(pre.agent.triggers, { + gmail: [ + { on: 'file.created', match: 'from-alias' }, + { on: 'file.created', match: 'from-canonical' } + ] + }); + assert.deepEqual(pre.warnings, []); + } finally { + await cleanup(); + } +}); + test('preflightPersona refuses optional integrations enabled by undeclared inputs', async () => { const { personaPath, cleanup } = await withTempPersona( basePersonaJson({ diff --git a/packages/deploy/src/preflight.ts b/packages/deploy/src/preflight.ts index 0c0d4de..6b9699f 100644 --- a/packages/deploy/src/preflight.ts +++ b/packages/deploy/src/preflight.ts @@ -127,7 +127,8 @@ function normalizeTriggerProviderAliases(agent: AgentSpec): AgentSpec { const aliases = KNOWN_TRIGGER_PROVIDER_ALIASES as Record; const normalized: NonNullable = {}; for (const [provider, list] of Object.entries(triggers)) { - normalized[aliases[provider] ?? provider] = list; + const key = aliases[provider] ?? provider; + normalized[key] = [...(normalized[key] ?? []), ...list]; } return { ...agent, triggers: normalized }; }