MCPcopy Index your code
hub / github.com/simstudioai/sim / resolveTriggerRunOptions

Function resolveTriggerRunOptions

apps/sim/lib/workflows/triggers/run-options.ts:274–299  ·  view source on GitHub ↗
(
  blocks: Record<string, TriggerBlockLike>,
  edges?: Array<{ source: string; target: string }>
)

Source from the content-addressed store, hash-verified

272 * guaranteeing describe == enforce.
273 */
274export 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. */
302export function toPublicRunOption(option: TriggerRunOption): {

Callers 2

Calls 4

resolveStartCandidatesFunction · 0.90
selectBestTriggerFunction · 0.90
buildTriggerRunOptionFunction · 0.85
setMethod · 0.65

Tested by

no test coverage detected