Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions packages/deploy/src/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, unknown>,
agentSource = SCHEDULE_AGENT_SRC
Expand Down Expand Up @@ -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({
Expand Down
3 changes: 2 additions & 1 deletion packages/deploy/src/preflight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ function normalizeTriggerProviderAliases(agent: AgentSpec): AgentSpec {
const aliases = KNOWN_TRIGGER_PROVIDER_ALIASES as Record<string, string>;
const normalized: NonNullable<AgentSpec['triggers']> = {};
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 };
}
Loading