diff --git a/packages/deploy/src/preflight.ts b/packages/deploy/src/preflight.ts index 2f47e97a..2cfb5558 100644 --- a/packages/deploy/src/preflight.ts +++ b/packages/deploy/src/preflight.ts @@ -1,8 +1,10 @@ import { readFile, stat } from 'node:fs/promises'; import path from 'node:path'; import { + KNOWN_TRIGGER_PROVIDER_ALIASES, lintTriggers, parsePersonaSpec, + type AgentSpec, type PersonaIntent, type PersonaSpec } from '@agentworkforce/persona-kit'; @@ -102,14 +104,21 @@ export async function preflightPersona(personaPath: string): Promise `${issue.path}: ${issue.message}` ); return { persona, - agent, + agent: normalizedAgent, personaPath: absPath, personaDir, onEventPath, @@ -143,3 +152,21 @@ async function readPersonaSource(absPath: string): Promise { const { persona } = await loadPersonaSourceFile(absPath); return persona; } + +/** + * Replace alias trigger provider names with their canonical counterparts so + * the cloud API never sees a name it doesn't recognise. E.g. 'google-mail' + * (the integration provider id) → 'gmail' (the trigger catalog name). + * The persona's `integrations` map is left untouched — the cloud resolves + * integrations and triggers under different namespaces. + */ +function normalizeTriggerProviderAliases(agent: AgentSpec): AgentSpec { + const { triggers } = agent; + if (!triggers) return agent; + const aliases = KNOWN_TRIGGER_PROVIDER_ALIASES as Record; + const normalized: NonNullable = {}; + for (const [provider, list] of Object.entries(triggers)) { + normalized[aliases[provider] ?? provider] = list; + } + return { ...agent, triggers: normalized }; +}