@prompd/cli 0.3.4 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1605 @@
1
+ /**
2
+ * Workflow Types - TypeScript interfaces for .pdflow files
3
+ */
4
+ export interface WorkflowFile {
5
+ version: string;
6
+ metadata: WorkflowMetadata;
7
+ parameters?: WorkflowParameter[];
8
+ using?: PackageAlias[];
9
+ variables?: WorkflowVariable[];
10
+ nodes: WorkflowNode[];
11
+ edges: WorkflowEdge[];
12
+ errorHandling?: ErrorHandlingConfig;
13
+ execution?: ExecutionConfig;
14
+ }
15
+ export interface WorkflowMetadata {
16
+ id: string;
17
+ name: string;
18
+ description?: string;
19
+ author?: string;
20
+ version?: string;
21
+ tags?: string[];
22
+ }
23
+ export interface WorkflowParameter {
24
+ name: string;
25
+ type: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'integer';
26
+ required?: boolean;
27
+ description?: string;
28
+ default?: unknown;
29
+ enum?: string[];
30
+ min?: number;
31
+ max?: number;
32
+ }
33
+ export interface PackageAlias {
34
+ name: string;
35
+ prefix: string;
36
+ }
37
+ export interface WorkflowVariable {
38
+ name: string;
39
+ type: string;
40
+ scope?: 'workflow' | 'node';
41
+ default?: unknown;
42
+ }
43
+ export type WorkflowNodeType = 'trigger' | 'prompt' | 'provider' | 'condition' | 'loop' | 'parallel' | 'merge' | 'transformer' | 'api' | 'tool' | 'tool-call-parser' | 'tool-call-router' | 'agent' | 'chat-agent' | 'guardrail' | 'callback' | 'checkpoint' | 'user-input' | 'error-handler' | 'command' | 'claude-code' | 'workflow' | 'mcp-tool' | 'code' | 'memory' | 'output';
44
+ export interface WorkflowNode {
45
+ id: string;
46
+ type: WorkflowNodeType;
47
+ position: {
48
+ x: number;
49
+ y: number;
50
+ };
51
+ data: TriggerNodeData | PromptNodeData | ProviderNodeData | ConditionNodeData | LoopNodeData | ParallelNodeData | MergeNodeData | TransformerNodeData | ApiNodeData | ToolNodeData | ToolCallParserNodeData | ToolCallRouterNodeData | AgentNodeData | ChatAgentNodeData | GuardrailNodeData | CallbackNodeData | UserInputNodeData | ErrorHandlerNodeData | CommandNodeData | ClaudeCodeNodeData | WorkflowNodeData | McpToolNodeData | CodeNodeData | MemoryNodeData | OutputNodeData;
52
+ /** Parent node ID for compound nodes (loop/parallel containers) */
53
+ parentId?: string;
54
+ /** Extent for child nodes - 'parent' constrains to parent bounds */
55
+ extent?: 'parent' | [number, number, number, number];
56
+ /** Whether this node is expandable (container nodes) */
57
+ expandParent?: boolean;
58
+ /** Width for resizable container nodes */
59
+ width?: number;
60
+ /** Height for resizable container nodes */
61
+ height?: number;
62
+ /** Style overrides */
63
+ style?: Record<string, unknown>;
64
+ }
65
+ export interface BaseNodeData {
66
+ label: string;
67
+ /** Disable this node to skip it during workflow execution */
68
+ disabled?: boolean;
69
+ /** Lock the node to prevent dragging/moving */
70
+ locked?: boolean;
71
+ /** Reference to ErrorHandler node for this node's errors */
72
+ errorHandlerNodeId?: string;
73
+ /** Override: stop workflow immediately on error (ignores errorHandler) */
74
+ failFast?: boolean;
75
+ /** Reference to a Connection for external service access (SSH, Database, HTTP API, etc.) */
76
+ connectionId?: string;
77
+ /**
78
+ * Docking configuration - when this node is docked to another node's handle.
79
+ * Docked nodes appear as mini 24px circle previews attached to the host handle.
80
+ */
81
+ dockedTo?: {
82
+ /** ID of the host node this node is docked to */
83
+ nodeId: string;
84
+ /** Handle ID on the host node (e.g., 'rejected', 'onError', 'output') */
85
+ handleId: string;
86
+ };
87
+ /** Saved width before docking (for restoring on undock) */
88
+ _preDockWidth?: number;
89
+ /** Saved height before docking (for restoring on undock) */
90
+ _preDockHeight?: number;
91
+ /** Saved position before docking (for restoring on undock) */
92
+ _preDockPosition?: {
93
+ x: number;
94
+ y: number;
95
+ };
96
+ [key: string]: unknown;
97
+ }
98
+ /** Node types that can be docked to handles */
99
+ export declare const DOCKABLE_NODE_TYPES: WorkflowNodeType[];
100
+ /** Handle configurations that accept docked nodes */
101
+ export declare const DOCKABLE_HANDLES: Array<{
102
+ nodeType: WorkflowNodeType;
103
+ handleId: string;
104
+ position: {
105
+ side: 'left' | 'right' | 'bottom';
106
+ topPercent: number;
107
+ };
108
+ acceptsTypes: WorkflowNodeType[];
109
+ }>;
110
+ /**
111
+ * TriggerNodeData - Workflow entry point configuration
112
+ *
113
+ * Trigger types:
114
+ * - manual: User clicks "Run" button (default)
115
+ * - webhook: HTTP POST to a generated endpoint
116
+ * - schedule: Cron expression or interval-based
117
+ * - file-watch: File system changes (Electron only)
118
+ * - event: Internal event from another workflow
119
+ *
120
+ * Every workflow should have exactly one TriggerNode as its entry point.
121
+ * The trigger node has no inputs and one output that starts the workflow.
122
+ */
123
+ export interface TriggerNodeData extends BaseNodeData {
124
+ /** Type of trigger */
125
+ triggerType: 'manual' | 'webhook' | 'schedule' | 'file-watch' | 'event';
126
+ /** Description of when/how this workflow runs */
127
+ description?: string;
128
+ /** Webhook path suffix (e.g., '/my-workflow' -> POST /api/webhooks/my-workflow) */
129
+ webhookPath?: string;
130
+ /** Secret for HMAC signature validation */
131
+ webhookSecret?: string;
132
+ /** HTTP methods to accept (default: POST only) */
133
+ webhookMethods?: ('GET' | 'POST' | 'PUT')[];
134
+ /** Whether to require authentication */
135
+ webhookRequireAuth?: boolean;
136
+ /** Schedule type */
137
+ scheduleType?: 'cron' | 'interval';
138
+ /** Cron expression (e.g., '0 9 * * *' for 9am daily) */
139
+ scheduleCron?: string;
140
+ /** Interval in milliseconds (e.g., 60000 for every minute) */
141
+ scheduleIntervalMs?: number;
142
+ /** Timezone for cron expressions (default: UTC) */
143
+ scheduleTimezone?: string;
144
+ /** Whether schedule is currently active */
145
+ scheduleEnabled?: boolean;
146
+ /** Glob patterns for files to watch */
147
+ fileWatchPaths?: string[];
148
+ /** Events to trigger on */
149
+ fileWatchEvents?: ('create' | 'modify' | 'delete')[];
150
+ /** Debounce time in ms to batch rapid changes */
151
+ fileWatchDebounceMs?: number;
152
+ /** Whether to watch subdirectories */
153
+ fileWatchRecursive?: boolean;
154
+ /** Event name to listen for */
155
+ eventName?: string;
156
+ /** Optional filter expression for event data */
157
+ eventFilter?: string;
158
+ /** Schema for data this trigger provides to the workflow */
159
+ outputSchema?: JsonSchema;
160
+ }
161
+ export interface PromptNodeData extends BaseNodeData {
162
+ /** Source type: 'file' for .prmd file reference, 'raw' for inline text */
163
+ sourceType?: 'file' | 'raw';
164
+ /** Path to .prmd file or package reference (used when sourceType is 'file' or undefined) */
165
+ source: string;
166
+ /** Raw prompt text (used when sourceType is 'raw') */
167
+ rawPrompt?: string;
168
+ /** Reference to a provider node ID, or inline provider name */
169
+ provider?: string;
170
+ /** Model name (used with inline provider, ignored if providerNodeId is set) */
171
+ model?: string;
172
+ /** Reference to a provider node by ID (preferred over inline provider/model) */
173
+ providerNodeId?: string;
174
+ parameters?: Record<string, string>;
175
+ context?: {
176
+ previous_output?: 'auto' | string;
177
+ };
178
+ outputMapping?: Record<string, string>;
179
+ inputSchema?: JsonSchema;
180
+ outputSchema?: JsonSchema;
181
+ }
182
+ /**
183
+ * ProviderNodeData - LLM provider configuration node
184
+ *
185
+ * Centralizes provider/model selection so multiple prompt nodes can reference
186
+ * the same provider configuration. This makes it easy to switch providers
187
+ * across an entire workflow.
188
+ */
189
+ export interface ProviderNodeData extends BaseNodeData {
190
+ /** Provider ID (e.g., 'openai', 'anthropic', 'google') */
191
+ providerId: string;
192
+ /** Model ID (e.g., 'gpt-4o', 'claude-sonnet-4-20250514') */
193
+ model: string;
194
+ /** Optional description for this provider configuration */
195
+ description?: string;
196
+ /** Temperature override (0-2) */
197
+ temperature?: number;
198
+ /** Max tokens override */
199
+ maxTokens?: number;
200
+ }
201
+ export interface ConditionNodeData extends BaseNodeData {
202
+ conditions: ConditionBranch[];
203
+ default?: string;
204
+ }
205
+ export interface ConditionBranch {
206
+ id: string;
207
+ expression: string;
208
+ target: string;
209
+ }
210
+ export interface LoopNodeData extends BaseNodeData {
211
+ loopType: 'while' | 'for-each' | 'count';
212
+ condition?: string;
213
+ items?: string;
214
+ itemVariable?: string;
215
+ count?: number;
216
+ maxIterations: number;
217
+ body: string[];
218
+ onComplete?: string;
219
+ /** Whether the container is collapsed (hides child nodes) */
220
+ collapsed?: boolean;
221
+ }
222
+ export interface ParallelNodeData extends BaseNodeData {
223
+ /** Execution mode: 'broadcast' (container) or 'fork' (edge-based branches) */
224
+ mode: 'broadcast' | 'fork';
225
+ /** Number of output handles in fork mode */
226
+ forkCount?: number;
227
+ /** Custom labels for fork branches (indexed by branch number) */
228
+ forkLabels?: string[];
229
+ branches: ParallelBranch[];
230
+ waitFor: 'all' | 'any' | 'race';
231
+ mergeStrategy: 'object' | 'array' | 'first';
232
+ /** Whether the container is collapsed (hides child nodes) */
233
+ collapsed?: boolean;
234
+ }
235
+ export interface ParallelBranch {
236
+ id: string;
237
+ label?: string;
238
+ nodes: string[];
239
+ }
240
+ export interface MergeNodeData extends BaseNodeData {
241
+ inputs: string[];
242
+ mergeAs: 'object' | 'array';
243
+ /**
244
+ * Merge mode determines how the merge node behaves:
245
+ * - 'wait': Waits for all connected inputs to have outputs before executing (default)
246
+ * - 'transform': Executes immediately with whatever inputs are available (router/passthrough)
247
+ */
248
+ mode?: 'wait' | 'transform';
249
+ }
250
+ /**
251
+ * TransformerNodeData - Data transformation node
252
+ *
253
+ * Transform, reshape, or filter data using templates with {{ variable }} syntax.
254
+ * Supports multiple transform modes for different use cases.
255
+ *
256
+ * Transform Modes:
257
+ * - template: JSON template with {{ }} variable interpolation
258
+ * - jq: JQ-style query expressions (future)
259
+ * - javascript: Inline JS expression (sandboxed)
260
+ *
261
+ * Variables:
262
+ * - {{ previous_output }} - Output from the connected input node
263
+ * - {{ node_id.property }} - Access specific node outputs
264
+ * - {{ workflow.param_name }} - Workflow parameters
265
+ */
266
+ export interface TransformerNodeData extends BaseNodeData {
267
+ /** Transform mode */
268
+ mode: 'template' | 'jq' | 'expression';
269
+ /** JSON template string with {{ variable }} syntax (for template mode) */
270
+ template?: string;
271
+ /** JQ-style query expression (for jq mode, future) */
272
+ jqExpression?: string;
273
+ /** JavaScript expression that returns transformed value (for expression mode) */
274
+ expression?: string;
275
+ /** Input variable name (defaults to 'input') */
276
+ inputVariable?: string;
277
+ /** Whether to pass through unchanged if transform fails */
278
+ passthroughOnError?: boolean;
279
+ /** Description of what this transform does */
280
+ description?: string;
281
+ transform?: string;
282
+ }
283
+ export interface ApiNodeData extends BaseNodeData {
284
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
285
+ url: string;
286
+ headers?: Record<string, string>;
287
+ body?: string;
288
+ retryPolicy?: RetryPolicy;
289
+ }
290
+ /**
291
+ * ToolNodeData - Unified tool execution node
292
+ *
293
+ * Supports five tool types:
294
+ * - function: Call a registered function/callback provided to the workflow executor
295
+ * - mcp: Call a tool exposed by an MCP (Model Context Protocol) server
296
+ * - http: Make an HTTP request (similar to ApiNodeData but unified interface)
297
+ * - command: Execute a whitelisted shell command (npm, git, python, etc.)
298
+ * - code: Execute code snippets (TypeScript/JavaScript, Python, or C#)
299
+ *
300
+ * Use cases:
301
+ * - Database lookups
302
+ * - Code execution
303
+ * - External API integration
304
+ * - MCP-compatible AI tools
305
+ * - Custom business logic
306
+ * - Shell command execution
307
+ * - Data transformation via code
308
+ */
309
+ export interface ToolNodeData extends BaseNodeData {
310
+ /** Tool type determines how the tool is invoked */
311
+ toolType: 'function' | 'mcp' | 'http' | 'command' | 'code';
312
+ /** Tool name - for function/mcp types, this identifies the tool to call */
313
+ toolName: string;
314
+ /** Description shown in the node and used for documentation */
315
+ description?: string;
316
+ /** Input parameters - template expressions supported */
317
+ parameters?: Record<string, unknown>;
318
+ /** Parameter schema for validation and UI generation */
319
+ parameterSchema?: {
320
+ type: 'object';
321
+ properties?: Record<string, {
322
+ type: string;
323
+ description?: string;
324
+ default?: unknown;
325
+ enum?: string[];
326
+ }>;
327
+ required?: string[];
328
+ };
329
+ /** HTTP method (only for http type) */
330
+ httpMethod?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
331
+ /** URL template (only for http type) */
332
+ httpUrl?: string;
333
+ /** HTTP headers (only for http type) */
334
+ httpHeaders?: Record<string, string>;
335
+ /** Request body template (only for http type) */
336
+ httpBody?: string;
337
+ /** MCP server URL (only for mcp type) */
338
+ mcpServerUrl?: string;
339
+ /** MCP server name/identifier (alternative to URL for configured servers) */
340
+ mcpServerName?: string;
341
+ /** The executable to run (must be in allowed list or custom commands) */
342
+ commandExecutable?: string;
343
+ /** Action/subcommand (e.g., 'run' for npm, 'status' for git) */
344
+ commandAction?: string;
345
+ /** Arguments template (supports {{ }} expressions) */
346
+ commandArgs?: string;
347
+ /** Working directory (relative to workspace) */
348
+ commandCwd?: string;
349
+ /** Whether this command requires user approval before execution */
350
+ commandRequiresApproval?: boolean;
351
+ /** Custom command ID (references CustomCommandConfig from connections) */
352
+ customCommandId?: string;
353
+ /** Programming language for code execution */
354
+ codeLanguage?: 'typescript' | 'javascript' | 'python' | 'csharp';
355
+ /** The code snippet to execute */
356
+ codeSnippet?: string;
357
+ /** Variable name for previous_output (default: 'input') */
358
+ codeInputVariable?: string;
359
+ /** For TS/JS: execution context */
360
+ codeExecutionContext?: 'isolated' | 'main';
361
+ /** Timeout in milliseconds */
362
+ timeout?: number;
363
+ /** Retry policy for failed executions */
364
+ retryPolicy?: RetryPolicy;
365
+ /** Transform the result before passing to next node */
366
+ outputTransform?: string;
367
+ }
368
+ /**
369
+ * ToolCallParserNodeData - Parse LLM output for tool call requests
370
+ *
371
+ * This node detects and extracts tool calls from LLM responses, enabling
372
+ * agentic workflows where the LLM decides which tools to call.
373
+ *
374
+ * Supported formats:
375
+ * - openai: OpenAI function calling format (tool_calls array)
376
+ * - anthropic: Anthropic tool_use blocks
377
+ * - xml: XML-style <tool_call> tags
378
+ * - json: Generic JSON with configurable field names
379
+ * - auto: Automatically detect format
380
+ *
381
+ * Output structure:
382
+ * {
383
+ * hasToolCall: boolean,
384
+ * toolName: string | null,
385
+ * toolParameters: Record<string, unknown> | null,
386
+ * remainingText: string, // Text after tool call extraction
387
+ * rawToolCall: unknown, // Original tool call data
388
+ * format: string // Detected format
389
+ * }
390
+ */
391
+ export interface ToolCallParserNodeData extends BaseNodeData {
392
+ /** Format to parse - 'auto' will attempt to detect */
393
+ format: 'auto' | 'openai' | 'anthropic' | 'xml' | 'json';
394
+ /** For 'json' format: field name containing the tool name */
395
+ jsonToolNameField?: string;
396
+ /** For 'json' format: field name containing the parameters */
397
+ jsonParametersField?: string;
398
+ /** For 'xml' format: tag name for tool calls (default: 'tool_call') */
399
+ xmlTagName?: string;
400
+ /** List of valid tool names - if provided, only these will be recognized */
401
+ allowedTools?: string[];
402
+ /** What to do if no tool call is found */
403
+ noToolCallBehavior: 'passthrough' | 'error' | 'default';
404
+ /** Default tool to use if noToolCallBehavior is 'default' */
405
+ defaultTool?: string;
406
+ defaultParameters?: Record<string, unknown>;
407
+ }
408
+ /**
409
+ * ToolCallRouterNodeData - Container node for grouping Tool nodes
410
+ *
411
+ * This node acts as a container that groups Tool nodes together and routes
412
+ * tool calls from Agent nodes to the appropriate Tool node based on tool name.
413
+ *
414
+ * Usage:
415
+ * 1. Create a ToolCallRouter node on the canvas
416
+ * 2. Drag Tool nodes inside the container (they become children via parentId)
417
+ * 3. Connect Agent's onCheckpoint handle to router's toolCall input
418
+ * 4. Connect router's toolResult output back to Agent's toolResult input
419
+ *
420
+ * The router automatically collects tool schemas from child Tool nodes and
421
+ * dispatches tool calls to the matching Tool node for execution.
422
+ */
423
+ export interface ToolCallRouterNodeData extends BaseNodeData {
424
+ /** How tool calls are matched to Tool nodes */
425
+ routingMode: 'name-match' | 'pattern' | 'fallback';
426
+ /** Behavior when no Tool node matches the requested tool name */
427
+ onNoMatch: 'error' | 'passthrough' | 'fallback-tool';
428
+ /** ID of a Tool node inside this router to use as fallback */
429
+ fallbackToolId?: string;
430
+ /** Whether the container is collapsed (hides child nodes) */
431
+ collapsed?: boolean;
432
+ }
433
+ export interface OutputNodeData extends BaseNodeData {
434
+ outputSchema?: JsonSchema;
435
+ result?: unknown;
436
+ }
437
+ /**
438
+ * ErrorHandlerNodeData - Workflow-level error handling configuration
439
+ *
440
+ * Error handling is configured as a **workflow-level node** that other nodes
441
+ * reference by ID (similar to how nodes reference Provider nodes). This avoids
442
+ * cluttering the graph with inline error edges.
443
+ *
444
+ * Nodes reference an ErrorHandler via `errorHandlerNodeId` in BaseNodeData.
445
+ * When an error occurs, the executor routes it to the referenced ErrorHandler
446
+ * for retry, fallback, or notification handling.
447
+ *
448
+ * Strategies:
449
+ * - retry: Attempt the operation again with backoff
450
+ * - fallback: Return a fallback value or execute a fallback node
451
+ * - notify: Send notification (webhook, log) and continue
452
+ * - ignore: Swallow the error and continue with null/undefined
453
+ * - rethrow: Re-throw the error to stop execution
454
+ *
455
+ * Visual representation:
456
+ * - Displayed in "Error Handlers" section of NodePalette
457
+ * - Rose/red color theme
458
+ * - Dashed border to indicate "config node" vs "flow node"
459
+ * - No edges - referenced by ID from other nodes
460
+ */
461
+ export interface ErrorHandlerNodeData extends BaseNodeData {
462
+ /** Error handling strategy */
463
+ strategy: 'retry' | 'fallback' | 'notify' | 'ignore' | 'rethrow';
464
+ /** Retry policy */
465
+ retry?: {
466
+ /** Maximum number of retry attempts */
467
+ maxAttempts: number;
468
+ /** Initial backoff delay in milliseconds */
469
+ backoffMs: number;
470
+ /** Backoff multiplier for exponential backoff (e.g., 2 for doubling) */
471
+ backoffMultiplier?: number;
472
+ /** Maximum backoff delay in milliseconds */
473
+ maxBackoffMs?: number;
474
+ /** Error codes/patterns that should trigger a retry (empty = retry all) */
475
+ retryOn?: string[];
476
+ /** Error codes/patterns that should NOT trigger a retry */
477
+ noRetryOn?: string[];
478
+ };
479
+ /** Fallback value or node when all retries exhausted or strategy is 'fallback' */
480
+ fallback?: {
481
+ /** Type of fallback */
482
+ type: 'value' | 'template' | 'node';
483
+ /** Static value to return (when type is 'value') */
484
+ value?: unknown;
485
+ /** Template expression to evaluate (when type is 'template') */
486
+ template?: string;
487
+ /** Node ID to execute as fallback (when type is 'node') */
488
+ nodeId?: string;
489
+ };
490
+ /** Notification settings */
491
+ notify?: {
492
+ /** Webhook URL to POST error details */
493
+ webhookUrl?: string;
494
+ /** HTTP headers for webhook */
495
+ webhookHeaders?: Record<string, string>;
496
+ /** Whether to include stack trace in notification */
497
+ includeStack?: boolean;
498
+ /** Whether to include node input/context in notification */
499
+ includeContext?: boolean;
500
+ /** Custom message template (supports {{ error.message }}, {{ node.id }}, etc.) */
501
+ messageTemplate?: string;
502
+ };
503
+ /** Logging settings */
504
+ log?: {
505
+ /** Log level for this error handler */
506
+ level: 'error' | 'warn' | 'info' | 'debug';
507
+ /** Whether to include the node data that caused the error */
508
+ includeNodeData?: boolean;
509
+ /** Whether to include input data */
510
+ includeInput?: boolean;
511
+ };
512
+ /** Only handle errors matching these conditions */
513
+ conditions?: {
514
+ /** Error codes/patterns to match (regex supported) */
515
+ errorCodes?: string[];
516
+ /** Error message patterns to match (regex supported) */
517
+ messagePatterns?: string[];
518
+ /** Node types this handler applies to */
519
+ nodeTypes?: WorkflowNodeType[];
520
+ };
521
+ /** Description of this error handler */
522
+ description?: string;
523
+ }
524
+ /**
525
+ * CheckpointNodeData - Configurable observation point for workflow execution
526
+ *
527
+ * The Checkpoint node is a flexible observation/control point that can:
528
+ * - Log data to console and execution history
529
+ * - Pause execution in debug mode (breakpoint)
530
+ * - Gate execution requiring human approval (production use)
531
+ * - Send webhook notifications to external systems
532
+ *
533
+ * Pre-Node Aware: The checkpoint detects what type of node feeds into it
534
+ * and can subscribe to specific events from that node (e.g., Agent iterations).
535
+ *
536
+ * All behaviors are toggleable and can be combined.
537
+ */
538
+ export interface CallbackNodeData extends BaseNodeData {
539
+ /** Custom name for this checkpoint (shown in logs/UI) */
540
+ checkpointName?: string;
541
+ /** Description of what this checkpoint monitors */
542
+ description?: string;
543
+ /** Log checkpoint data to console/stdout */
544
+ logToConsole?: boolean;
545
+ /** Store checkpoint data in execution history for later review */
546
+ logToHistory?: boolean;
547
+ /** Pause execution when running in debug mode (breakpoint) */
548
+ pauseInDebug?: boolean;
549
+ /** Require human approval before continuing (works in production) */
550
+ requireApproval?: boolean;
551
+ /** Send HTTP webhook notification */
552
+ sendWebhook?: boolean;
553
+ /** Include the previous node's output in checkpoint data */
554
+ capturePreviousOutput?: boolean;
555
+ /** Include timestamp and execution duration */
556
+ captureTimestamp?: boolean;
557
+ /** Include full execution context (all variables, workflow state) */
558
+ captureFullContext?: boolean;
559
+ /** Custom message template (supports {{ }} expressions) */
560
+ message?: string;
561
+ /** Title shown in approval dialog */
562
+ approvalTitle?: string;
563
+ /** Instructions for the reviewer */
564
+ approvalInstructions?: string;
565
+ /** Timeout in ms to wait for approval (0 = wait indefinitely) */
566
+ approvalTimeoutMs?: number;
567
+ /** What to do if approval times out */
568
+ approvalTimeoutAction?: 'continue' | 'fail' | 'skip';
569
+ /** Webhook URL to POST checkpoint data */
570
+ webhookUrl?: string;
571
+ /** Custom headers to include in webhook request */
572
+ webhookHeaders?: Record<string, string>;
573
+ /** Whether to wait for webhook acknowledgment before continuing */
574
+ webhookWaitForAck?: boolean;
575
+ /** Timeout in ms to wait for acknowledgment (0 = no timeout) */
576
+ webhookAckTimeoutMs?: number;
577
+ /**
578
+ * Detected type of the node connected to this checkpoint's input.
579
+ * This is auto-populated and used to show relevant options in the UI.
580
+ * @readonly - Set automatically, not user-configurable
581
+ */
582
+ _detectedSourceType?: WorkflowNodeType;
583
+ /** Include full iteration history from agent execution */
584
+ agentCaptureIterations?: boolean;
585
+ /** Include conversation/message history */
586
+ agentCaptureConversation?: boolean;
587
+ /** Include tool call details and results */
588
+ agentCaptureToolCalls?: boolean;
589
+ /** Include agent's thinking/reasoning (if available) */
590
+ agentCaptureThinking?: boolean;
591
+ /**
592
+ * Event types to listen for when connected to an Agent's onCheckpoint handle.
593
+ * If empty or undefined, listens to all event types.
594
+ */
595
+ listenTo?: AgentCheckpointEventType[];
596
+ /** Capture current iteration index */
597
+ loopCaptureIteration?: boolean;
598
+ /** Capture loop variable value */
599
+ loopCaptureVariable?: boolean;
600
+ /** Include the compiled prompt that was sent to the LLM */
601
+ promptCaptureCompiled?: boolean;
602
+ /** Include token usage stats */
603
+ promptCaptureTokens?: boolean;
604
+ /** @deprecated Use individual behavior toggles instead */
605
+ mode?: 'passthrough' | 'pause' | 'report';
606
+ /** @deprecated Use capturePreviousOutput instead */
607
+ includePreviousOutput?: boolean;
608
+ /** @deprecated Use captureFullContext instead */
609
+ includeNextNodeInfo?: boolean;
610
+ /** @deprecated Use webhookWaitForAck instead */
611
+ waitForAck?: boolean;
612
+ /** @deprecated Use webhookAckTimeoutMs instead */
613
+ ackTimeoutMs?: number;
614
+ /** @deprecated Use agentCaptureIterations instead */
615
+ agentIncludeIterationHistory?: boolean;
616
+ /** @deprecated Use agentCaptureConversation instead */
617
+ agentIncludeConversationHistory?: boolean;
618
+ /** @deprecated Use agentCaptureToolCalls instead */
619
+ agentIncludeToolCalls?: boolean;
620
+ }
621
+ /**
622
+ * UserInputNodeData - Pause workflow and collect user input
623
+ *
624
+ * This node pauses execution and waits for user input. It can be used for:
625
+ * - Interactive chat loops (user message -> LLM -> user message -> ...)
626
+ * - Human-in-the-loop approval workflows
627
+ * - Data collection mid-workflow
628
+ * - Debugging with manual input injection
629
+ *
630
+ * The node provides context (previous output, conversation history) to help
631
+ * the user understand what input is needed.
632
+ */
633
+ export interface UserInputNodeData extends BaseNodeData {
634
+ /** Prompt message shown to the user (supports {{ }} template expressions) */
635
+ prompt: string;
636
+ /** Type of input to collect */
637
+ inputType: 'text' | 'textarea' | 'choice' | 'confirm' | 'number';
638
+ /** Choices for 'choice' input type */
639
+ choices?: string[];
640
+ /** Placeholder text for input field */
641
+ placeholder?: string;
642
+ /** Default value for the input */
643
+ defaultValue?: string;
644
+ /** Whether input is required to continue */
645
+ required?: boolean;
646
+ /** Whether to show the previous node's output to the user */
647
+ showContext?: boolean;
648
+ /** Custom template for displaying context (supports {{ previous_output }}, {{ variables }}) */
649
+ contextTemplate?: string;
650
+ /** Timeout in ms (0 = wait indefinitely) */
651
+ timeout?: number;
652
+ }
653
+ /**
654
+ * CommandNodeData - Execute whitelisted shell commands
655
+ *
656
+ * This node executes shell commands with proper security controls:
657
+ * - Commands can be whitelisted by admin
658
+ * - Arguments are passed safely (not interpolated into command string)
659
+ * - Output is captured and parsed
660
+ * - Requires approval for sensitive operations
661
+ */
662
+ export interface CommandNodeData extends BaseNodeData {
663
+ /** Command template (supports {{ }} expressions for arguments) */
664
+ command: string;
665
+ /** Command arguments (safer than string interpolation) */
666
+ args?: string[];
667
+ /** Working directory (relative to workspace) */
668
+ cwd?: string;
669
+ /** Environment variables to set */
670
+ env?: Record<string, string>;
671
+ /** Timeout in milliseconds */
672
+ timeoutMs?: number;
673
+ /** Output parsing format */
674
+ outputFormat: 'text' | 'json' | 'lines';
675
+ /** Whether this command requires user approval before execution */
676
+ requiresApproval?: boolean;
677
+ /** Description shown in approval dialog */
678
+ approvalMessage?: string;
679
+ }
680
+ /**
681
+ * ClaudeCodeNodeData - Claude Code agent with SSH support for remote development
682
+ *
683
+ * This node encapsulates a full Claude Code agent that can:
684
+ * - Connect to local or remote systems via SSH
685
+ * - Execute multi-turn development tasks
686
+ * - Use file editing, command execution, and web tools
687
+ * - Stream progress back to the workflow
688
+ */
689
+ export interface ClaudeCodeNodeData extends BaseNodeData {
690
+ /** Connection type and configuration */
691
+ connection: {
692
+ type: 'local' | 'ssh';
693
+ /** SSH settings (when type === 'ssh') */
694
+ ssh?: {
695
+ /** Reference to SSH connection from Connections Panel */
696
+ connectionId?: string;
697
+ /** Or inline config (deprecated - use connectionId) */
698
+ host?: string;
699
+ port?: number;
700
+ username?: string;
701
+ authMethod?: 'key' | 'agent';
702
+ keyPath?: string;
703
+ };
704
+ };
705
+ /** Task configuration */
706
+ task: {
707
+ /** Main task description (supports {{ }} template expressions) */
708
+ prompt: string;
709
+ /** Optional system prompt override */
710
+ systemPrompt?: string;
711
+ /** Working directory on target (relative or absolute) */
712
+ workingDirectory?: string;
713
+ /** Files to include as context (glob patterns) */
714
+ contextFiles?: string[];
715
+ };
716
+ /** Execution constraints */
717
+ constraints: {
718
+ /** Maximum agent turns before forcing completion */
719
+ maxTurns?: number;
720
+ /** Allowed tool categories */
721
+ allowedTools?: ('read' | 'write' | 'execute' | 'web')[];
722
+ /** Blocked file patterns (security) */
723
+ blockedPaths?: string[];
724
+ /** Require approval for write operations */
725
+ requireApprovalForWrites?: boolean;
726
+ /** Timeout for entire execution (ms) */
727
+ timeoutMs?: number;
728
+ };
729
+ /** Output configuration */
730
+ output: {
731
+ /** What to return as node output */
732
+ format: 'final-response' | 'full-conversation' | 'files-changed' | 'structured';
733
+ /** For structured output - JSON schema to enforce */
734
+ schema?: JsonSchema;
735
+ /** Include execution metadata (tokens, duration, etc.) */
736
+ includeMetadata?: boolean;
737
+ };
738
+ }
739
+ /**
740
+ * WorkflowNodeData - Invoke another .pdflow as a sub-workflow
741
+ *
742
+ * This enables workflow composition:
743
+ * - Call reusable workflow modules
744
+ * - Pass parameters and receive outputs
745
+ * - Support for recursive workflows (with depth limit)
746
+ */
747
+ export interface WorkflowNodeData extends BaseNodeData {
748
+ /** Source workflow path or package reference */
749
+ source: string;
750
+ /** Parameter mapping (input to sub-workflow) */
751
+ parameters: Record<string, string>;
752
+ /** Output mapping (sub-workflow output to this node's output) */
753
+ outputMapping?: Record<string, string>;
754
+ /** Execution options */
755
+ timeout?: number;
756
+ /** Whether to pass parent workflow variables */
757
+ inheritVariables?: boolean;
758
+ /** Maximum recursion depth (to prevent infinite loops) */
759
+ maxDepth?: number;
760
+ }
761
+ /**
762
+ * McpToolNodeData - Execute tools from external MCP servers
763
+ *
764
+ * This node connects to external MCP servers and executes their tools.
765
+ * Unlike the generic Tool node, this is specifically for MCP protocol
766
+ * and supports MCP-specific features like resources and prompts.
767
+ */
768
+ export interface McpToolNodeData extends BaseNodeData {
769
+ /** Reference to MCP server connection from Connections Panel */
770
+ connectionId?: string;
771
+ /** Or inline MCP server config (deprecated - use connectionId) */
772
+ serverConfig?: {
773
+ serverUrl?: string;
774
+ serverName?: string;
775
+ transport?: 'stdio' | 'http' | 'websocket';
776
+ };
777
+ /** Tool name to execute */
778
+ toolName: string;
779
+ /** Parameter mapping (supports {{ }} expressions) */
780
+ parameters: Record<string, string>;
781
+ /** Timeout for tool execution (ms) */
782
+ timeoutMs?: number;
783
+ /** Whether to include tool result in conversation context */
784
+ includeInContext?: boolean;
785
+ }
786
+ /**
787
+ * CodeNodeData - Execute code snippets in various languages
788
+ *
789
+ * Supports:
790
+ * - TypeScript/JavaScript: Runs in isolated VM context or via temp file
791
+ * - Python: Executes via python -c or temp file
792
+ * - C#: Executes via dotnet-script or compiled temp file
793
+ *
794
+ * The previous_output is available as a variable (default name: 'input')
795
+ */
796
+ export interface CodeNodeData extends BaseNodeData {
797
+ /** Programming language */
798
+ language: 'typescript' | 'javascript' | 'python' | 'csharp';
799
+ /** The code to execute */
800
+ code: string;
801
+ /** Variable name for the input (previous_output), default: 'input' */
802
+ inputVariable?: string;
803
+ /** For TS/JS: run in isolated VM or main context */
804
+ executionContext?: 'isolated' | 'main';
805
+ /** Timeout in milliseconds (default: 30000) */
806
+ timeoutMs?: number;
807
+ /** Description of what this code does */
808
+ description?: string;
809
+ }
810
+ /**
811
+ * MemoryNodeData - Configurable memory storage node
812
+ *
813
+ * Supports multiple memory patterns:
814
+ * - 'kv': Key-value store for passing state between nodes
815
+ * - 'conversation': Message history with sliding window for chat context
816
+ * - 'cache': Time-based caching for expensive operations
817
+ *
818
+ * Memory is scoped to workflow execution by default, but can be
819
+ * persisted across executions via the 'persistent' flag.
820
+ *
821
+ * Handles:
822
+ * - input (left) - Data to store or key to retrieve
823
+ * - output (right) - Retrieved value or confirmation
824
+ */
825
+ /** Memory operation type */
826
+ export type MemoryOperation = 'get' | 'set' | 'delete' | 'clear' | 'list' | 'append';
827
+ /** Operations available per memory mode */
828
+ export declare const MEMORY_OPERATIONS_BY_MODE: Record<string, MemoryOperation[]>;
829
+ export interface MemoryNodeData extends BaseNodeData {
830
+ /** Memory operation mode */
831
+ mode: 'kv' | 'conversation' | 'cache';
832
+ /**
833
+ * Operations this node can perform (multi-select).
834
+ * When multiple operations are enabled, the input data's `operation` field
835
+ * determines which to execute, or defaults to the first enabled operation.
836
+ */
837
+ operations: MemoryOperation[];
838
+ /**
839
+ * Key for the value (supports {{ }} template expressions).
840
+ * Used in kv and cache modes.
841
+ */
842
+ key?: string;
843
+ /**
844
+ * Value to store (supports {{ }} template expressions).
845
+ * Used with 'set' operation. If not provided, uses input data.
846
+ */
847
+ value?: string;
848
+ /**
849
+ * Default value to return if key doesn't exist.
850
+ * Used with 'get' operation.
851
+ */
852
+ defaultValue?: string;
853
+ /**
854
+ * Conversation/thread identifier (supports {{ }} expressions).
855
+ * Allows multiple separate conversation histories.
856
+ */
857
+ conversationId?: string;
858
+ /**
859
+ * Role for the message being appended ('user', 'assistant', 'system').
860
+ * Used with 'append' operation in conversation mode.
861
+ */
862
+ messageRole?: 'user' | 'assistant' | 'system';
863
+ /**
864
+ * Maximum messages to retain in sliding window.
865
+ * Older messages are removed when limit is exceeded.
866
+ * Set to 0 for unlimited.
867
+ */
868
+ maxMessages?: number;
869
+ /**
870
+ * Include system messages in the sliding window count.
871
+ * If false, system messages are always retained.
872
+ */
873
+ includeSystemInWindow?: boolean;
874
+ /**
875
+ * Time-to-live in seconds for cached values.
876
+ * After TTL expires, 'get' returns defaultValue or undefined.
877
+ * Set to 0 for no expiration.
878
+ */
879
+ ttlSeconds?: number;
880
+ /**
881
+ * Refresh TTL on read (sliding expiration).
882
+ * If true, reading a value resets its TTL.
883
+ */
884
+ refreshOnRead?: boolean;
885
+ /**
886
+ * Memory scope:
887
+ * - 'execution': Cleared when workflow execution completes (default)
888
+ * - 'workflow': Persists across executions of this workflow
889
+ * - 'global': Shared across all workflows (use with caution)
890
+ */
891
+ scope?: 'execution' | 'workflow' | 'global';
892
+ /**
893
+ * Namespace to isolate this memory from others.
894
+ * Useful for avoiding key collisions in global scope.
895
+ */
896
+ namespace?: string;
897
+ /**
898
+ * What to output after the operation:
899
+ * - 'value': The retrieved/stored value
900
+ * - 'success': Boolean indicating success
901
+ * - 'metadata': Object with value, timestamp, ttl info
902
+ * - 'passthrough': Pass input through unchanged
903
+ */
904
+ outputMode?: 'value' | 'success' | 'metadata' | 'passthrough';
905
+ }
906
+ /**
907
+ * CustomCommandConfig - User-defined allowed commands
908
+ *
909
+ * Stored in the Connections panel, these allow users to whitelist
910
+ * additional shell commands for use in Tool nodes.
911
+ */
912
+ export interface CustomCommandConfig {
913
+ /** Unique identifier */
914
+ id: string;
915
+ /** The executable name (e.g., 'cargo', 'terraform', 'kubectl') */
916
+ executable: string;
917
+ /** Allowed actions/subcommands (if empty, any args allowed with validation) */
918
+ allowedActions?: string[];
919
+ /** Human-readable description */
920
+ description?: string;
921
+ /** Whether to require approval before execution */
922
+ requiresApproval: boolean;
923
+ /** When this command was added */
924
+ addedAt: number;
925
+ }
926
+ /**
927
+ * Built-in allowed executables for command tool type
928
+ */
929
+ export declare const BUILTIN_COMMAND_EXECUTABLES: readonly [{
930
+ readonly executable: "npm";
931
+ readonly description: "Node.js package manager";
932
+ readonly actions: readonly ["run", "install", "test", "build", "start"];
933
+ }, {
934
+ readonly executable: "npx";
935
+ readonly description: "Execute npm packages";
936
+ readonly actions: readonly [];
937
+ }, {
938
+ readonly executable: "node";
939
+ readonly description: "Node.js runtime";
940
+ readonly actions: readonly [];
941
+ }, {
942
+ readonly executable: "yarn";
943
+ readonly description: "Yarn package manager";
944
+ readonly actions: readonly ["run", "install", "test", "build", "start"];
945
+ }, {
946
+ readonly executable: "pnpm";
947
+ readonly description: "PNPM package manager";
948
+ readonly actions: readonly ["run", "install", "test", "build", "start"];
949
+ }, {
950
+ readonly executable: "git";
951
+ readonly description: "Version control";
952
+ readonly actions: readonly ["status", "add", "commit", "push", "pull", "log", "diff", "branch"];
953
+ }, {
954
+ readonly executable: "python";
955
+ readonly description: "Python interpreter";
956
+ readonly actions: readonly [];
957
+ }, {
958
+ readonly executable: "python3";
959
+ readonly description: "Python 3 interpreter";
960
+ readonly actions: readonly [];
961
+ }, {
962
+ readonly executable: "pip";
963
+ readonly description: "Python package manager";
964
+ readonly actions: readonly ["install", "list", "show"];
965
+ }, {
966
+ readonly executable: "prompd";
967
+ readonly description: "Prompd CLI";
968
+ readonly actions: readonly ["compile", "run", "validate", "package"];
969
+ }, {
970
+ readonly executable: "dotnet";
971
+ readonly description: ".NET CLI";
972
+ readonly actions: readonly ["build", "run", "test", "publish"];
973
+ }, {
974
+ readonly executable: "tsc";
975
+ readonly description: "TypeScript compiler";
976
+ readonly actions: readonly [];
977
+ }, {
978
+ readonly executable: "eslint";
979
+ readonly description: "JavaScript linter";
980
+ readonly actions: readonly [];
981
+ }, {
982
+ readonly executable: "prettier";
983
+ readonly description: "Code formatter";
984
+ readonly actions: readonly [];
985
+ }, {
986
+ readonly executable: "echo";
987
+ readonly description: "Print text";
988
+ readonly actions: readonly [];
989
+ }];
990
+ /**
991
+ * AgentIterationRecord - Record of a single agent iteration for debugging
992
+ */
993
+ export interface AgentIterationRecord {
994
+ iteration: number;
995
+ timestamp: number;
996
+ llmInput: {
997
+ systemPrompt: string;
998
+ conversationHistory: Array<{
999
+ role: string;
1000
+ content: string;
1001
+ }>;
1002
+ };
1003
+ llmOutput: {
1004
+ response: string;
1005
+ hasToolCall: boolean;
1006
+ toolName?: string;
1007
+ toolParams?: Record<string, unknown>;
1008
+ };
1009
+ toolExecution?: {
1010
+ toolName: string;
1011
+ parameters: Record<string, unknown>;
1012
+ result: unknown;
1013
+ error?: string;
1014
+ durationMs: number;
1015
+ };
1016
+ durationMs: number;
1017
+ }
1018
+ /**
1019
+ * AgentCheckpointEvent - Events emitted by Agent nodes during execution
1020
+ *
1021
+ * Agent nodes emit these events through their onCheckpoint handle, allowing
1022
+ * connected Callback nodes to observe and react to agent execution.
1023
+ *
1024
+ * Event types:
1025
+ * - toolCall: Agent is requesting a tool execution
1026
+ * - iteration: Agent completed an iteration of the ReAct loop
1027
+ * - thinking: Agent emitted reasoning/chain-of-thought
1028
+ * - error: An error occurred during agent execution
1029
+ * - complete: Agent finished execution
1030
+ */
1031
+ export type AgentCheckpointEventType = 'toolCall' | 'iteration' | 'thinking' | 'error' | 'complete';
1032
+ export interface AgentCheckpointEvent {
1033
+ /** Type of event */
1034
+ type: AgentCheckpointEventType;
1035
+ /** When the event occurred */
1036
+ timestamp: number;
1037
+ /** Current iteration number (1-indexed) */
1038
+ iteration: number;
1039
+ /** Node ID of the agent that emitted this event */
1040
+ agentNodeId: string;
1041
+ /** Event-specific data */
1042
+ data: ToolCallEventData | IterationEventData | ThinkingEventData | ErrorEventData | CompleteEventData;
1043
+ }
1044
+ /** Data for 'toolCall' events - agent is requesting tool execution */
1045
+ export interface ToolCallEventData {
1046
+ toolName: string;
1047
+ parameters: Record<string, unknown>;
1048
+ /** Tool schema for validation (if available) */
1049
+ schema?: {
1050
+ type: 'object';
1051
+ properties?: Record<string, {
1052
+ type: string;
1053
+ description?: string;
1054
+ }>;
1055
+ required?: string[];
1056
+ };
1057
+ }
1058
+ /** Data for 'iteration' events - agent completed a ReAct loop iteration */
1059
+ export interface IterationEventData {
1060
+ iterationNumber: number;
1061
+ llmInput: {
1062
+ systemPrompt: string;
1063
+ messages: Array<{
1064
+ role: string;
1065
+ content: string;
1066
+ }>;
1067
+ };
1068
+ llmOutput: {
1069
+ response: string;
1070
+ hasToolCall: boolean;
1071
+ toolName?: string;
1072
+ toolParams?: Record<string, unknown>;
1073
+ };
1074
+ durationMs: number;
1075
+ }
1076
+ /** Data for 'thinking' events - agent's reasoning/chain-of-thought */
1077
+ export interface ThinkingEventData {
1078
+ thought: string;
1079
+ }
1080
+ /** Data for 'error' events - an error occurred */
1081
+ export interface ErrorEventData {
1082
+ message: string;
1083
+ code?: string;
1084
+ stack?: string;
1085
+ recoverable: boolean;
1086
+ }
1087
+ /** Data for 'complete' events - agent finished execution */
1088
+ export interface CompleteEventData {
1089
+ finalResponse: string;
1090
+ totalIterations: number;
1091
+ totalDurationMs: number;
1092
+ stopReason: 'max-iterations' | 'stop-phrase' | 'no-tool-call' | 'error' | 'completed';
1093
+ }
1094
+ /**
1095
+ * AgentNodeData - Autonomous AI agent with tool-use loop
1096
+ *
1097
+ * Implements a ReAct-style (Reasoning + Acting) agent that:
1098
+ * 1. Sends a prompt to an LLM with tool definitions
1099
+ * 2. Parses the response for tool calls
1100
+ * 3. Executes requested tools
1101
+ * 4. Feeds results back to the LLM
1102
+ * 5. Repeats until LLM provides final answer or max iterations reached
1103
+ *
1104
+ * This encapsulates the common "agentic loop" pattern into a single node.
1105
+ *
1106
+ * Debug Mode:
1107
+ * When debugConfig.debugMode is enabled, the agent emits detailed traces at
1108
+ * internal checkpoints and can optionally pause at each checkpoint (like breakpoints).
1109
+ * Iteration history is stored in the node output for downstream analysis.
1110
+ */
1111
+ export interface AgentNodeData extends BaseNodeData {
1112
+ /** System prompt that defines the agent's behavior and available tools */
1113
+ systemPrompt: string;
1114
+ /** Initial user message / task description (supports {{ }} template expressions) */
1115
+ userPrompt: string;
1116
+ /** Reference to a Provider node by ID (preferred - enables centralized config) */
1117
+ providerNodeId?: string;
1118
+ /** Inline LLM provider (fallback if no providerNodeId) */
1119
+ provider?: string;
1120
+ /** Inline model (fallback if no providerNodeId) */
1121
+ model?: string;
1122
+ /** Tool definitions available to the agent (legacy - prefer toolRouterNodeId) */
1123
+ tools: AgentTool[];
1124
+ /** Reference to a ToolCallRouter node by ID (preferred over inline tools) */
1125
+ toolRouterNodeId?: string;
1126
+ /** Maximum number of tool-use iterations before stopping */
1127
+ maxIterations: number;
1128
+ /** Format for tool calls in LLM responses */
1129
+ toolCallFormat: 'auto' | 'openai' | 'anthropic' | 'xml' | 'json';
1130
+ /** What to output when agent completes */
1131
+ outputMode: 'final-response' | 'full-conversation' | 'last-tool-result';
1132
+ /** Whether to include conversation history in context */
1133
+ includeHistory?: boolean;
1134
+ /** Stop phrases that indicate the agent is done (in addition to no tool call) */
1135
+ stopPhrases?: string[];
1136
+ /** Temperature for LLM calls */
1137
+ temperature?: number;
1138
+ /** Timeout per LLM call in ms */
1139
+ llmTimeout?: number;
1140
+ }
1141
+ /**
1142
+ * GuardrailNodeData - Input validation node with success/rejected branching
1143
+ *
1144
+ * Validates input against a system prompt and routes to success or rejected paths.
1145
+ * Uses an LLM to evaluate the input and determine if it passes validation.
1146
+ *
1147
+ * Handles:
1148
+ * - input (left, top) - Data to validate
1149
+ * - rejected (left, bottom) - Source handle for routing rejected input back
1150
+ *
1151
+ * Outputs:
1152
+ * - output (right) - Validated input passes through on success
1153
+ *
1154
+ * The guardrail evaluates the input using the configured provider and system prompt,
1155
+ * then uses the passExpression to determine if the result indicates pass or fail.
1156
+ */
1157
+ export interface GuardrailNodeData extends BaseNodeData {
1158
+ /** System prompt that defines the validation criteria */
1159
+ systemPrompt: string;
1160
+ /** Reference to a Provider node by ID for LLM evaluation */
1161
+ providerNodeId?: string;
1162
+ /** Inline provider (fallback if no providerNodeId) */
1163
+ provider?: string;
1164
+ /** Inline model (fallback if no providerNodeId) */
1165
+ model?: string;
1166
+ /**
1167
+ * Expression to evaluate pass/fail from the LLM response.
1168
+ * Supports {{ }} template syntax with access to the parsed response.
1169
+ *
1170
+ * Examples:
1171
+ * - "{{ score >= 0.8 }}" - Pass if score is 0.8 or higher
1172
+ * - "{{ !rejected }}" - Pass if rejected is falsy
1173
+ * - "{{ score >= 0.8 && !rejected }}" - Combined conditions
1174
+ *
1175
+ * The expression is evaluated against the parsed JSON response from the LLM.
1176
+ * If the LLM returns a non-JSON response, it's wrapped as { response: "..." }
1177
+ */
1178
+ passExpression?: string;
1179
+ /**
1180
+ * Numeric threshold for pass/fail (alternative to passExpression).
1181
+ * If the LLM response contains a 'score' field, this threshold is used.
1182
+ * Input passes if score >= scoreThreshold.
1183
+ */
1184
+ scoreThreshold?: number;
1185
+ /** Temperature for LLM evaluation (default: 0 for deterministic) */
1186
+ temperature?: number;
1187
+ /** Timeout for LLM call in ms */
1188
+ timeout?: number;
1189
+ /** Description of what this guardrail validates */
1190
+ description?: string;
1191
+ }
1192
+ /**
1193
+ * ChatAgentNodeData - Composite container for conversational AI agent pattern
1194
+ *
1195
+ * Bundles the common pattern of: User Input → Guardrail → AI Agent ↔ Tool Router
1196
+ * into a single, configurable node with checkpoints at each stage.
1197
+ *
1198
+ * When collapsed: Shows as a single node with key metrics
1199
+ * When expanded: Shows all internal nodes for detailed editing
1200
+ *
1201
+ * Internal nodes (auto-created):
1202
+ * - UserInput: Collects user message
1203
+ * - Guardrail: Validates input before processing
1204
+ * - Agent: AI agent with ReAct loop
1205
+ * - ToolRouter: Container for available tools
1206
+ *
1207
+ * Handles:
1208
+ * - input (left) - Workflow data / conversation context
1209
+ * - output (right) - Final agent response
1210
+ * - rejected (left, bottom) - Guardrail rejection path
1211
+ */
1212
+ export interface ChatAgentNodeData extends BaseNodeData {
1213
+ /** Whether the container is collapsed (shows as single node) */
1214
+ collapsed?: boolean;
1215
+ /** Saved dimensions when expanded */
1216
+ _savedWidth?: number;
1217
+ _savedHeight?: number;
1218
+ /**
1219
+ * Agent prompt source type:
1220
+ * - 'raw': Inline text prompt (agentSystemPrompt field)
1221
+ * - 'file': Reference to .prmd file or package (agentPromptSource field)
1222
+ */
1223
+ agentPromptSourceType?: 'raw' | 'file';
1224
+ /** System prompt for the AI agent (used when agentPromptSourceType is 'raw' or not set) */
1225
+ agentSystemPrompt: string;
1226
+ /** Source file for agent prompt (used when agentPromptSourceType is 'file') - local .prmd path or package reference */
1227
+ agentPromptSource?: string;
1228
+ /** Initial user prompt template (supports {{ }} expressions) */
1229
+ agentUserPrompt?: string;
1230
+ /** Reference to Provider node for LLM */
1231
+ providerNodeId?: string;
1232
+ /** Inline provider (fallback) */
1233
+ provider?: string;
1234
+ /** Inline model (fallback) */
1235
+ model?: string;
1236
+ /** Maximum ReAct loop iterations */
1237
+ maxIterations?: number;
1238
+ /** Tool call format detection */
1239
+ toolCallFormat?: 'auto' | 'openai' | 'anthropic' | 'xml' | 'json';
1240
+ /** What to output when complete */
1241
+ outputMode?: 'final-response' | 'full-conversation' | 'last-tool-result';
1242
+ /** Temperature for LLM calls */
1243
+ temperature?: number;
1244
+ /**
1245
+ * Loop mode for the chat agent:
1246
+ * - 'single-turn': Execute once and return (no looping)
1247
+ * - 'multi-turn': Continue until stop condition or max iterations
1248
+ * - 'until-complete': Loop until agent signals completion
1249
+ * - 'user-driven': Loop back for user input after each response
1250
+ */
1251
+ loopMode?: 'single-turn' | 'multi-turn' | 'until-complete' | 'user-driven';
1252
+ /**
1253
+ * Condition expression to continue looping (for multi-turn mode).
1254
+ * Evaluated after each iteration. Loop continues while this is true.
1255
+ * Uses {{ }} template syntax with access to iteration context.
1256
+ *
1257
+ * Examples:
1258
+ * - "{{ iteration < 5 }}" - Continue for 5 iterations
1259
+ * - "{{ !response.includes('DONE') }}" - Until response contains DONE
1260
+ * - "{{ tools_used > 0 }}" - Continue if tools were used
1261
+ */
1262
+ loopCondition?: string;
1263
+ /**
1264
+ * Stop phrases that signal the agent is done.
1265
+ * If the response contains any of these, the loop terminates.
1266
+ */
1267
+ stopPhrases?: string[];
1268
+ /**
1269
+ * Whether to prompt for user input after each agent response (for user-driven mode).
1270
+ * When true, the loop pauses for user input before continuing.
1271
+ */
1272
+ loopOnUserInput?: boolean;
1273
+ /**
1274
+ * Minimum number of iterations before stop condition is checked.
1275
+ * Ensures the agent runs at least this many times.
1276
+ */
1277
+ minIterations?: number;
1278
+ /**
1279
+ * Delay between iterations in milliseconds.
1280
+ * Useful for rate limiting or allowing processing time.
1281
+ */
1282
+ iterationDelayMs?: number;
1283
+ /** Whether guardrail is enabled */
1284
+ guardrailEnabled?: boolean;
1285
+ /** Guardrail system prompt */
1286
+ guardrailSystemPrompt?: string;
1287
+ /** Reference to Provider node for guardrail LLM (can be different from agent's provider) */
1288
+ guardrailProviderNodeId?: string;
1289
+ /** Inline provider for guardrail (fallback if no guardrailProviderNodeId) */
1290
+ guardrailProvider?: string;
1291
+ /** Inline model for guardrail (fallback if no guardrailProviderNodeId) */
1292
+ guardrailModel?: string;
1293
+ /** Temperature for guardrail LLM evaluation (default: 0 for deterministic) */
1294
+ guardrailTemperature?: number;
1295
+ /** Pass/fail expression */
1296
+ guardrailPassExpression?: string;
1297
+ /** Score threshold alternative */
1298
+ guardrailScoreThreshold?: number;
1299
+ /** Whether to prompt for user input at start of each iteration */
1300
+ userInputEnabled?: boolean;
1301
+ /** Prompt message shown to user */
1302
+ userInputPrompt?: string;
1303
+ /** Input type */
1304
+ userInputType?: 'text' | 'textarea' | 'choice' | 'confirm';
1305
+ /** Placeholder text */
1306
+ userInputPlaceholder?: string;
1307
+ /** Whether to show previous context to user */
1308
+ userInputShowContext?: boolean;
1309
+ /** Inline tool definitions (for simple cases) */
1310
+ tools?: AgentTool[];
1311
+ /** Reference to external ToolRouter node (for complex tool setups) */
1312
+ toolRouterNodeId?: string;
1313
+ /** Checkpoint settings for different stages */
1314
+ checkpoints?: {
1315
+ /** On user input received */
1316
+ onUserInput?: ChatAgentCheckpointConfig;
1317
+ /** Before guardrail validation */
1318
+ beforeGuardrail?: ChatAgentCheckpointConfig;
1319
+ /** After guardrail (pass or reject) */
1320
+ afterGuardrail?: ChatAgentCheckpointConfig;
1321
+ /** Before each agent iteration */
1322
+ onIterationStart?: ChatAgentCheckpointConfig;
1323
+ /** After each agent iteration */
1324
+ onIterationEnd?: ChatAgentCheckpointConfig;
1325
+ /** When agent requests a tool call */
1326
+ onToolCall?: ChatAgentCheckpointConfig;
1327
+ /** After tool execution returns */
1328
+ onToolResult?: ChatAgentCheckpointConfig;
1329
+ /** When agent completes */
1330
+ onAgentComplete?: ChatAgentCheckpointConfig;
1331
+ };
1332
+ /** IDs of internal nodes (auto-created, managed by the container) */
1333
+ _internalNodes?: {
1334
+ userInputId?: string;
1335
+ guardrailId?: string;
1336
+ agentId?: string;
1337
+ toolRouterId?: string;
1338
+ };
1339
+ }
1340
+ /**
1341
+ * Checkpoint configuration for ChatAgentNode stages
1342
+ */
1343
+ export interface ChatAgentCheckpointConfig {
1344
+ /** Whether this checkpoint is enabled */
1345
+ enabled: boolean;
1346
+ /** Pause execution at this point (debug mode) */
1347
+ pause?: boolean;
1348
+ /** Log to console */
1349
+ logToConsole?: boolean;
1350
+ /** Log to execution history */
1351
+ logToHistory?: boolean;
1352
+ /** Require approval to continue */
1353
+ requireApproval?: boolean;
1354
+ /** Send webhook notification */
1355
+ sendWebhook?: boolean;
1356
+ webhookUrl?: string;
1357
+ /** Custom message template */
1358
+ message?: string;
1359
+ /** Include full context in checkpoint data */
1360
+ includeFullContext?: boolean;
1361
+ }
1362
+ /**
1363
+ * Tool definition for an agent
1364
+ */
1365
+ export interface AgentTool {
1366
+ /** Unique tool name */
1367
+ name: string;
1368
+ /** Description shown to the LLM */
1369
+ description: string;
1370
+ /** JSON schema for tool parameters */
1371
+ parameters?: {
1372
+ type: 'object';
1373
+ properties?: Record<string, {
1374
+ type: string;
1375
+ description?: string;
1376
+ enum?: string[];
1377
+ default?: unknown;
1378
+ }>;
1379
+ required?: string[];
1380
+ };
1381
+ /** How this tool is executed */
1382
+ toolType: 'function' | 'http' | 'mcp' | 'workflow' | 'command' | 'code';
1383
+ /** For HTTP tools */
1384
+ httpConfig?: {
1385
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
1386
+ url: string;
1387
+ headers?: Record<string, string>;
1388
+ bodyTemplate?: string;
1389
+ };
1390
+ /** For MCP tools */
1391
+ mcpConfig?: {
1392
+ serverUrl?: string;
1393
+ serverName?: string;
1394
+ };
1395
+ /** For workflow tools - execute a sub-workflow */
1396
+ workflowConfig?: {
1397
+ workflowPath: string;
1398
+ };
1399
+ /** For command tools - execute shell commands */
1400
+ commandConfig?: {
1401
+ executable: string;
1402
+ action?: string;
1403
+ args?: string;
1404
+ cwd?: string;
1405
+ requiresApproval?: boolean;
1406
+ };
1407
+ /** For code tools - execute code snippets */
1408
+ codeConfig?: {
1409
+ language: 'typescript' | 'javascript' | 'python' | 'csharp';
1410
+ snippet: string;
1411
+ inputVariable?: string;
1412
+ executionContext?: 'isolated' | 'main';
1413
+ };
1414
+ }
1415
+ /**
1416
+ * WorkflowEdge uses React Flow's standard edge format directly.
1417
+ * This eliminates conversion overhead and makes debugging easier.
1418
+ */
1419
+ export interface WorkflowEdge {
1420
+ id: string;
1421
+ source: string;
1422
+ target: string;
1423
+ sourceHandle?: string;
1424
+ targetHandle?: string;
1425
+ animated?: boolean;
1426
+ label?: string;
1427
+ }
1428
+ export interface ErrorHandlingConfig {
1429
+ onError: 'continue' | 'stop' | 'retry';
1430
+ retryPolicy?: RetryPolicy;
1431
+ fallbackNode?: string;
1432
+ }
1433
+ export interface RetryPolicy {
1434
+ enabled: boolean;
1435
+ maxRetries: number;
1436
+ backoffMs: number;
1437
+ backoffMultiplier?: number;
1438
+ }
1439
+ export interface ExecutionConfig {
1440
+ timeout?: number;
1441
+ parallelism?: {
1442
+ enabled: boolean;
1443
+ maxConcurrency: number;
1444
+ };
1445
+ logging?: {
1446
+ level: 'debug' | 'info' | 'warn' | 'error';
1447
+ includeTimings?: boolean;
1448
+ };
1449
+ caching?: {
1450
+ enabled: boolean;
1451
+ ttlMs: number;
1452
+ };
1453
+ }
1454
+ export interface JsonSchema {
1455
+ type: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'integer';
1456
+ properties?: Record<string, JsonSchema>;
1457
+ items?: JsonSchema;
1458
+ required?: string[];
1459
+ minLength?: number;
1460
+ maxLength?: number;
1461
+ minimum?: number;
1462
+ maximum?: number;
1463
+ enum?: unknown[];
1464
+ }
1465
+ export interface WorkflowValidationError {
1466
+ nodeId?: string;
1467
+ connectionId?: string;
1468
+ field?: string;
1469
+ message: string;
1470
+ code: string;
1471
+ }
1472
+ export interface WorkflowValidationWarning {
1473
+ nodeId?: string;
1474
+ message: string;
1475
+ code: string;
1476
+ }
1477
+ export type WorkflowExecutionStatus = 'idle' | 'running' | 'paused' | 'completed' | 'failed';
1478
+ export type NodeExecutionStatus = 'pending' | 'running' | 'paused' | 'completed' | 'failed' | 'skipped';
1479
+ export interface WorkflowExecutionState {
1480
+ workflowId: string;
1481
+ status: WorkflowExecutionStatus;
1482
+ currentNodeId?: string;
1483
+ nodeStates: Record<string, NodeExecutionState>;
1484
+ nodeOutputs: Record<string, unknown>;
1485
+ variables: Record<string, unknown>;
1486
+ errors: WorkflowExecutionError[];
1487
+ startTime?: number;
1488
+ endTime?: number;
1489
+ /** Memory storage for MemoryNode operations */
1490
+ memory?: {
1491
+ /** Key-value store (by namespace or root) */
1492
+ kv: Record<string, unknown>;
1493
+ /** Conversation histories (by conversation ID) */
1494
+ conversation: Record<string, unknown[]>;
1495
+ /** Cache entries with TTL (by namespace or root) */
1496
+ cache: Record<string, unknown>;
1497
+ };
1498
+ }
1499
+ export interface NodeExecutionState {
1500
+ nodeId: string;
1501
+ status: NodeExecutionStatus;
1502
+ startTime?: number;
1503
+ endTime?: number;
1504
+ output?: unknown;
1505
+ error?: string;
1506
+ retryCount: number;
1507
+ streamingContent?: string;
1508
+ }
1509
+ export interface WorkflowExecutionError {
1510
+ nodeId?: string;
1511
+ message: string;
1512
+ stack?: string;
1513
+ timestamp: number;
1514
+ }
1515
+ export interface WorkflowResult {
1516
+ success: boolean;
1517
+ output?: unknown;
1518
+ nodeOutputs: Record<string, unknown>;
1519
+ errors: WorkflowExecutionError[];
1520
+ metrics: {
1521
+ totalDuration: number;
1522
+ nodeMetrics: Record<string, {
1523
+ duration: number;
1524
+ tokens?: number;
1525
+ }>;
1526
+ };
1527
+ }
1528
+ /**
1529
+ * WorkflowConnectionType - Types of external connections managed in the Connections panel
1530
+ *
1531
+ * Connections are managed in a dedicated panel (not canvas nodes) to scale to
1532
+ * hundreds of connection types. Nodes reference connections by ID.
1533
+ */
1534
+ export type WorkflowConnectionType = 'ssh' | 'database' | 'http-api' | 'slack' | 'github' | 'mcp-server' | 'websocket' | 'custom';
1535
+ export type WorkflowConnectionStatus = 'disconnected' | 'connecting' | 'connected' | 'error';
1536
+ /**
1537
+ * WorkflowConnection - External service connection managed in the Connections panel
1538
+ *
1539
+ * Stored separately from workflow nodes - connections are workflow-scoped resources
1540
+ * that can be referenced by multiple nodes via connectionId.
1541
+ */
1542
+ export interface WorkflowConnection {
1543
+ id: string;
1544
+ name: string;
1545
+ type: WorkflowConnectionType;
1546
+ status: WorkflowConnectionStatus;
1547
+ lastConnected?: number;
1548
+ lastError?: string;
1549
+ config: WorkflowConnectionConfig;
1550
+ }
1551
+ /** Union type for all connection configs */
1552
+ export type WorkflowConnectionConfig = SSHConnectionConfig | DatabaseConnectionConfig | HttpApiConnectionConfig | SlackConnectionConfig | GitHubConnectionConfig | McpServerConnectionConfig | WebSocketConnectionConfig | CustomConnectionConfig;
1553
+ export interface SSHConnectionConfig {
1554
+ type: 'ssh';
1555
+ host: string;
1556
+ port?: number;
1557
+ username: string;
1558
+ authMethod: 'key' | 'password' | 'agent';
1559
+ keyPath?: string;
1560
+ }
1561
+ export interface DatabaseConnectionConfig {
1562
+ type: 'database';
1563
+ dbType: 'postgresql' | 'mysql' | 'mongodb' | 'redis' | 'sqlite';
1564
+ host?: string;
1565
+ port?: number;
1566
+ database: string;
1567
+ username?: string;
1568
+ ssl?: boolean;
1569
+ connectionString?: string;
1570
+ }
1571
+ export interface HttpApiConnectionConfig {
1572
+ type: 'http-api';
1573
+ baseUrl: string;
1574
+ authType: 'none' | 'bearer' | 'api-key' | 'basic' | 'oauth2';
1575
+ headers?: Record<string, string>;
1576
+ apiKeyHeader?: string;
1577
+ }
1578
+ export interface SlackConnectionConfig {
1579
+ type: 'slack';
1580
+ workspace: string;
1581
+ defaultChannel?: string;
1582
+ }
1583
+ export interface GitHubConnectionConfig {
1584
+ type: 'github';
1585
+ owner?: string;
1586
+ repo?: string;
1587
+ baseUrl?: string;
1588
+ }
1589
+ export interface McpServerConnectionConfig {
1590
+ type: 'mcp-server';
1591
+ serverUrl: string;
1592
+ serverName: string;
1593
+ transport: 'stdio' | 'http' | 'websocket';
1594
+ }
1595
+ export interface WebSocketConnectionConfig {
1596
+ type: 'websocket';
1597
+ url: string;
1598
+ protocols?: string[];
1599
+ headers?: Record<string, string>;
1600
+ }
1601
+ export interface CustomConnectionConfig {
1602
+ type: 'custom';
1603
+ [key: string]: unknown;
1604
+ }
1605
+ //# sourceMappingURL=workflowTypes.d.ts.map