Skip to content
Merged
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
9 changes: 9 additions & 0 deletions apps/sim/blocks/blocks/start_trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ export const StartTriggerBlock: BlockConfig = {
type: 'input-format',
description: 'Add custom fields beyond the built-in input, conversationId, and files fields.',
},
{
id: 'runMetadata',
title: 'Add run metadata',
type: 'switch',
mode: 'advanced',
defaultValue: false,
description:
'Expose trusted, server-injected run metadata under <start.metadata>: userEmail, workspaceId, workflowId, executionId, executionType, executionMode, startTime. Fields describe the invoking run — inside a custom block they identify the calling user and workflow.',
},
],
tools: {
access: [],
Expand Down
2 changes: 2 additions & 0 deletions apps/sim/executor/execution/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ export class DAGExecutor {
this.contextExtensions.metadata?.useDraftState ??
this.contextExtensions.isDeployedContext !== true,
},
startRunMetadata: this.contextExtensions.startRunMetadata,
environmentVariables: this.environmentVariables,
workflowVariables: this.workflowVariables,
decisions: {
Expand Down Expand Up @@ -620,6 +621,7 @@ export class DAGExecutor {
const blockOutput = buildStartBlockOutput({
resolution: startResolution,
workflowInput: this.workflowInput,
runMetadata: this.contextExtensions.startRunMetadata,
})

state.setBlockState(startResolution.block.id, {
Expand Down
7 changes: 7 additions & 0 deletions apps/sim/executor/execution/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
BlockLog,
BlockState,
NormalizedBlockOutput,
StartBlockRunMetadata,
StreamingExecution,
} from '@/executor/types'
import type { RunFromBlockContext } from '@/executor/utils/run-from-block'
Expand Down Expand Up @@ -192,6 +193,12 @@ export interface ContextExtensions {
dagIncomingEdges?: Record<string, string[]>
snapshotState?: SerializableExecutionState
metadata?: ExecutionMetadata
/**
* Trusted run metadata injected into the Start block output when its
* "Add run metadata" toggle is enabled. Built server-side at the two
* Executor construction sites — never from caller-supplied input.
*/
startRunMetadata?: StartBlockRunMetadata
/**
* AbortSignal for cancellation support.
* When aborted, the execution should stop gracefully.
Expand Down
Loading
Loading