(
blocks: Record<string, TriggerBlockLike>,
edges?: Array<{ source: string; target: string }>
)
| 272 | * guaranteeing describe == enforce. |
| 273 | */ |
| 274 | export function resolveTriggerRunOptions( |
| 275 | blocks: Record<string, TriggerBlockLike>, |
| 276 | edges?: Array<{ source: string; target: string }> |
| 277 | ): TriggerRunOption[] { |
| 278 | const manual = resolveStartCandidates(blocks, { execution: 'manual' }) |
| 279 | const chat = resolveStartCandidates(blocks, { execution: 'chat' }) |
| 280 | |
| 281 | const byId = new Map<string, StartBlockCandidate<TriggerBlockLike>>() |
| 282 | for (const candidate of [...manual, ...chat]) { |
| 283 | if (!byId.has(candidate.blockId)) { |
| 284 | byId.set(candidate.blockId, candidate) |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | const candidates = [...byId.values()] |
| 289 | if (candidates.length === 0) { |
| 290 | return [] |
| 291 | } |
| 292 | |
| 293 | // Single overall default (no edges => one best); ties broken by trigger priority. |
| 294 | const defaultBlockId = selectBestTrigger(candidates)[0]?.blockId |
| 295 | |
| 296 | return candidates.map((candidate) => |
| 297 | buildTriggerRunOption(candidate, candidate.blockId === defaultBlockId) |
| 298 | ) |
| 299 | } |
| 300 | |
| 301 | /** Strips internal fields so the option can be returned to the agent. */ |
| 302 | export function toPublicRunOption(option: TriggerRunOption): { |
no test coverage detected