@q1k-oss/behaviour-tree-workflows 0.0.1 → 0.0.3

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,931 @@
1
+ /**
2
+ * Event system for observing behavior tree execution
3
+ * Enables external systems (debuggers, monitors, agents) to track execution in real-time
4
+ */
5
+ /**
6
+ * Types of events emitted by nodes during execution
7
+ */
8
+ declare enum NodeEventType {
9
+ TICK_START = "tick_start",
10
+ TICK_END = "tick_end",
11
+ STATUS_CHANGE = "status_change",
12
+ ERROR = "error",
13
+ HALT = "halt",
14
+ RESET = "reset",
15
+ LOG = "log"
16
+ }
17
+ /**
18
+ * Data for LOG events emitted by LogMessage nodes
19
+ */
20
+ interface LogEventData {
21
+ level: "info" | "warn" | "error" | "debug";
22
+ message: string;
23
+ }
24
+ /**
25
+ * Event emitted by a node during execution
26
+ */
27
+ interface NodeEvent<TData> {
28
+ type: NodeEventType;
29
+ nodeId: string;
30
+ nodeName: string;
31
+ nodeType: string;
32
+ timestamp: number;
33
+ /** Tree path (e.g., "/0/1/2") - set by tree execution */
34
+ nodePath?: string;
35
+ data?: TData;
36
+ }
37
+ /**
38
+ * Callback function for node events
39
+ */
40
+ type NodeEventCallback<TData> = (event: NodeEvent<TData>) => void;
41
+ /**
42
+ * Event emitter for behavior tree nodes
43
+ * Supports subscribing to specific event types and emitting events
44
+ */
45
+ declare class NodeEventEmitter {
46
+ private listeners;
47
+ private allListeners;
48
+ /**
49
+ * Subscribe to a specific event type
50
+ * @param type - The event type to listen for
51
+ * @param callback - Function to call when event occurs
52
+ */
53
+ on<TData>(type: NodeEventType, callback: NodeEventCallback<TData>): void;
54
+ /**
55
+ * Subscribe to all event types
56
+ * @param callback - Function to call for any event
57
+ */
58
+ onAll<TData>(callback: NodeEventCallback<TData>): void;
59
+ /**
60
+ * Unsubscribe from a specific event type
61
+ * @param type - The event type to stop listening for
62
+ * @param callback - The callback to remove
63
+ */
64
+ off<TData>(type: NodeEventType, callback: NodeEventCallback<TData>): void;
65
+ /**
66
+ * Unsubscribe from all events
67
+ * @param callback - The callback to remove
68
+ */
69
+ offAll<TData>(callback: NodeEventCallback<TData>): void;
70
+ /**
71
+ * Emit an event to all registered listeners
72
+ * Errors in callbacks are caught and logged to prevent breaking execution
73
+ * @param event - The event to emit
74
+ */
75
+ emit<TData>(event: NodeEvent<TData>): void;
76
+ /**
77
+ * Remove all listeners
78
+ */
79
+ clear(): void;
80
+ /**
81
+ * Get count of listeners for a specific type
82
+ * @param type - The event type to check
83
+ * @returns Number of listeners
84
+ */
85
+ listenerCount(type: NodeEventType): number;
86
+ /**
87
+ * Get count of "all events" listeners
88
+ * @returns Number of listeners
89
+ */
90
+ allListenerCount(): number;
91
+ /**
92
+ * Check if there are any listeners
93
+ * @returns True if any listeners are registered
94
+ */
95
+ hasListeners(): boolean;
96
+ }
97
+
98
+ /**
99
+ * Core types for the Behavior Tree implementation
100
+ * Inspired by BehaviorTree.CPP
101
+ */
102
+ /**
103
+ * Status of a node after tick execution
104
+ */
105
+ declare enum NodeStatus {
106
+ SUCCESS = "SUCCESS",
107
+ FAILURE = "FAILURE",
108
+ RUNNING = "RUNNING",
109
+ IDLE = "IDLE"
110
+ }
111
+ /**
112
+ * Base configuration for all nodes
113
+ */
114
+ interface NodeConfiguration {
115
+ id: string;
116
+ name?: string;
117
+ [key: string]: unknown;
118
+ }
119
+ /**
120
+ * Context passed during tick execution
121
+ */
122
+ interface TickContext {
123
+ blackboard: IScopedBlackboard;
124
+ treeRegistry: ITreeRegistry;
125
+ signal?: AbortSignal;
126
+ deltaTime?: number;
127
+ timestamp: number;
128
+ testData?: Map<string, unknown>;
129
+ /**
130
+ * Immutable workflow input parameters
131
+ * Accessible via ${input.key} syntax in variable resolution
132
+ * These are passed when the workflow starts and should not be modified
133
+ */
134
+ input?: Readonly<Record<string, unknown>>;
135
+ sessionId?: string;
136
+ eventEmitter?: NodeEventEmitter;
137
+ }
138
+ /**
139
+ * Token provider function type for OAuth/API key authentication
140
+ */
141
+ type TokenProvider = (context: TemporalContext, provider: string, connectionId?: string) => Promise<PieceAuth>;
142
+ /**
143
+ * Extended context for Temporal workflow execution
144
+ * Replaces EffectTickContext for Temporal-native execution
145
+ */
146
+ interface TemporalContext extends TickContext {
147
+ workflowInfo?: {
148
+ workflowId: string;
149
+ runId: string;
150
+ namespace: string;
151
+ };
152
+ /**
153
+ * Activity functions for I/O operations
154
+ * When provided, I/O nodes use these instead of inline execution
155
+ * Controlplane creates these via proxyActivities() and passes to context
156
+ */
157
+ activities?: BtreeActivities;
158
+ /**
159
+ * Token provider for IntegrationAction authentication
160
+ * Returns OAuth tokens or API keys for third-party services
161
+ */
162
+ tokenProvider?: TokenProvider;
163
+ }
164
+ /**
165
+ * Activity capabilities that can be provided to behaviour-tree
166
+ * Controlplane creates these via proxyActivities() and passes to context
167
+ */
168
+ interface BtreeActivities {
169
+ /** Execute an Active Pieces action (Google Sheets, Slack, etc.) */
170
+ executePieceAction: (request: PieceActivityRequest) => Promise<unknown>;
171
+ /** Execute Python code via cross-language activity */
172
+ executePythonScript?: (request: PythonScriptRequest) => Promise<PythonScriptResult>;
173
+ /** Parse CSV/Excel file into structured data */
174
+ parseFile?: (request: ParseFileRequest) => Promise<ParseFileResult>;
175
+ /** Generate CSV/Excel file from data */
176
+ generateFile?: (request: GenerateFileRequest) => Promise<GenerateFileResult>;
177
+ /** Make HTTP request (for nodes that don't use Active Pieces) */
178
+ fetchUrl?: (request: HttpRequestActivity) => Promise<HttpResponseActivity>;
179
+ /** Execute code in sandbox (Microsandbox) - supports JavaScript and Python */
180
+ executeCode?: (request: CodeExecutionRequest) => Promise<CodeExecutionResult>;
181
+ /** Upload file to storage, returns DataRef */
182
+ uploadFile?: (request: UploadFileRequest) => Promise<UploadFileResult>;
183
+ /** Download file from storage */
184
+ downloadFile?: (request: DownloadFileRequest) => Promise<DownloadFileResult>;
185
+ /** Delete file from storage */
186
+ deleteFile?: (request: DeleteFileRequest) => Promise<DeleteFileResult>;
187
+ /** Check if file exists in storage */
188
+ fileExists?: (request: FileExistsRequest) => Promise<FileExistsResult>;
189
+ /** Execute LLM chat completion */
190
+ llmChat?: (request: LLMChatRequest) => Promise<LLMChatResult>;
191
+ /** Execute autonomous browser agent via Browserbase + Stagehand */
192
+ browserAgent?: (request: BrowserAgentRequest) => Promise<BrowserAgentResult>;
193
+ /** Execute autonomous Claude agent via Claude Agent SDK */
194
+ claudeAgent?: (request: ClaudeAgentRequest) => Promise<ClaudeAgentResult>;
195
+ /** Execute GitHub operations (create branch, PR, merge, etc.) */
196
+ githubAction?: (request: GitHubActionRequest) => Promise<GitHubActionResult>;
197
+ /** Create a human task (inserts into tasks table, returns taskId) */
198
+ createHumanTask?: (request: CreateHumanTaskRequest) => Promise<CreateHumanTaskResult>;
199
+ /** Wait for a human task to be completed (implemented as Temporal condition in workflow) */
200
+ waitForHumanTask?: (request: WaitForHumanTaskRequest) => Promise<WaitForHumanTaskResult>;
201
+ /** Execute a single LLM turn with tool calling support */
202
+ agentLoopTurn?: (request: AgentLoopTurnRequest) => Promise<AgentLoopTurnResult>;
203
+ /** Execute a tool call by name */
204
+ executeAgentTool?: (request: ExecuteAgentToolRequest) => Promise<ExecuteAgentToolResult>;
205
+ /** Wait for a generic Temporal signal (implemented as condition in workflow) */
206
+ waitForSignal?: (request: WaitForSignalRequest) => Promise<WaitForSignalResult>;
207
+ }
208
+ /**
209
+ * Authentication credentials for a piece
210
+ */
211
+ type PieceAuth = {
212
+ access_token: string;
213
+ refresh_token?: string;
214
+ } | {
215
+ api_key: string;
216
+ } | Record<string, unknown>;
217
+ interface PieceActivityRequest {
218
+ provider: string;
219
+ action: string;
220
+ inputs: Record<string, unknown>;
221
+ auth: PieceAuth;
222
+ }
223
+ interface PythonScriptRequest {
224
+ /** Python code to execute */
225
+ code: string;
226
+ /** Blackboard snapshot (serializable) */
227
+ blackboard: Record<string, unknown>;
228
+ /** Workflow input (read-only) */
229
+ input?: Record<string, unknown>;
230
+ /** Allowed environment variables */
231
+ env?: Record<string, string>;
232
+ /** Execution timeout in ms */
233
+ timeout?: number;
234
+ }
235
+ interface PythonScriptResult {
236
+ /** Modified blackboard values */
237
+ blackboard: Record<string, unknown>;
238
+ /** Stdout from Python execution */
239
+ stdout?: string;
240
+ /** Stderr from Python execution */
241
+ stderr?: string;
242
+ }
243
+ interface ParseFileRequest {
244
+ /** File path or URL */
245
+ file: string;
246
+ /** File format (auto-detect if not specified) */
247
+ format?: "csv" | "xlsx" | "xls" | "auto";
248
+ /** Sheet name for Excel (default: first sheet) */
249
+ sheetName?: string;
250
+ /** Column mapping { "Original Name": "normalizedName" } */
251
+ columnMapping?: Record<string, string>;
252
+ /** Parse options */
253
+ options?: {
254
+ skipRows?: number;
255
+ trim?: boolean;
256
+ emptyAsNull?: boolean;
257
+ dateColumns?: string[];
258
+ dateFormat?: string;
259
+ };
260
+ }
261
+ interface ParseFileResult {
262
+ /** Parsed data rows */
263
+ data: Record<string, unknown>[];
264
+ /** Number of rows parsed */
265
+ rowCount: number;
266
+ /** Column names detected */
267
+ columns: string[];
268
+ }
269
+ interface GenerateFileRequest {
270
+ /** Output format */
271
+ format: "csv" | "xlsx" | "json";
272
+ /** Data to write */
273
+ data: Record<string, unknown>[];
274
+ /** Column definitions */
275
+ columns?: Array<{
276
+ header: string;
277
+ key: string;
278
+ width?: number;
279
+ }>;
280
+ /** Output filename */
281
+ filename: string;
282
+ /** Storage type */
283
+ storage: "temp" | "persistent";
284
+ }
285
+ interface GenerateFileResult {
286
+ /** Generated filename */
287
+ filename: string;
288
+ /** MIME type */
289
+ contentType: string;
290
+ /** File size in bytes */
291
+ size: number;
292
+ /** File path or storage key */
293
+ path: string;
294
+ /** Pre-signed download URL (if persistent) */
295
+ url?: string;
296
+ }
297
+ interface HttpRequestActivity {
298
+ url: string;
299
+ method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
300
+ headers?: Record<string, string>;
301
+ body?: unknown;
302
+ timeout?: number;
303
+ }
304
+ interface HttpResponseActivity {
305
+ status: number;
306
+ headers: Record<string, string>;
307
+ data: unknown;
308
+ }
309
+ interface UploadFileRequest {
310
+ /** Base64-encoded file content */
311
+ fileBytes: string;
312
+ /** Target filename */
313
+ filename: string;
314
+ /** MIME type */
315
+ contentType?: string;
316
+ /** Workflow ID for organizing storage */
317
+ workflowId?: string;
318
+ }
319
+ interface UploadFileResult {
320
+ /** Reference to stored file */
321
+ dataRef: DataRef;
322
+ /** Uploaded filename */
323
+ filename: string;
324
+ /** File size in bytes */
325
+ sizeBytes: number;
326
+ }
327
+ interface DownloadFileRequest {
328
+ /** Reference to file in storage */
329
+ dataRef: DataRef;
330
+ }
331
+ interface DownloadFileResult {
332
+ /** Base64-encoded file content */
333
+ fileBytes: string;
334
+ /** File size in bytes */
335
+ sizeBytes: number;
336
+ }
337
+ interface DeleteFileRequest {
338
+ /** Reference to file in storage */
339
+ dataRef: DataRef;
340
+ }
341
+ interface DeleteFileResult {
342
+ /** Whether deletion was successful */
343
+ deleted: boolean;
344
+ /** Key of deleted file */
345
+ key: string;
346
+ }
347
+ interface FileExistsRequest {
348
+ /** Reference to file in storage */
349
+ dataRef: DataRef;
350
+ }
351
+ interface FileExistsResult {
352
+ /** Whether file exists */
353
+ exists: boolean;
354
+ /** Key checked */
355
+ key: string;
356
+ }
357
+ /**
358
+ * Reference to data stored in a DataStore
359
+ * Import from data-store module for full type, this is a lightweight re-export
360
+ */
361
+ interface DataRef {
362
+ store: "gcs" | "s3" | "redis" | "memory";
363
+ key: string;
364
+ sizeBytes?: number;
365
+ expiresAt?: number;
366
+ }
367
+ /**
368
+ * Request for code execution in a sandboxed environment
369
+ */
370
+ interface CodeExecutionRequest {
371
+ /** Code to execute */
372
+ code: string;
373
+ /** Programming language */
374
+ language: "javascript" | "python";
375
+ /** References to large data stored in DataStore */
376
+ dataRefs?: Record<string, DataRef>;
377
+ /** Inline context data (small values) */
378
+ context?: Record<string, unknown>;
379
+ /** Workflow input data (read-only) */
380
+ input?: Record<string, unknown>;
381
+ /** Execution timeout in milliseconds */
382
+ timeout?: number;
383
+ /** Python packages to install before execution */
384
+ packages?: string[];
385
+ /** Associated workflow ID for data storage */
386
+ workflowId?: string;
387
+ }
388
+ /**
389
+ * Result from code execution
390
+ */
391
+ interface CodeExecutionResult {
392
+ /** Small values returned inline */
393
+ values: Record<string, unknown>;
394
+ /** Large values stored in DataStore (returns refs) */
395
+ dataRefs: Record<string, DataRef>;
396
+ /** Console/stdout output from execution */
397
+ logs: string[];
398
+ /** Total execution time in milliseconds */
399
+ executionTimeMs: number;
400
+ }
401
+ /**
402
+ * Supported LLM providers
403
+ */
404
+ type LLMProvider = "anthropic" | "openai" | "google" | "ollama";
405
+ /**
406
+ * Message role in conversation
407
+ */
408
+ type MessageRole = "system" | "user" | "assistant";
409
+ /**
410
+ * Single message in a conversation
411
+ */
412
+ interface LLMMessage {
413
+ role: MessageRole;
414
+ content: string;
415
+ }
416
+ /**
417
+ * Request for LLM chat completion
418
+ */
419
+ interface LLMChatRequest {
420
+ /** LLM provider to use */
421
+ provider: LLMProvider;
422
+ /** Model identifier (e.g., "claude-sonnet-4-20250514", "gpt-4", "gemini-pro") */
423
+ model: string;
424
+ /** Conversation messages */
425
+ messages: LLMMessage[];
426
+ /** Optional system prompt (prepended as system message) */
427
+ systemPrompt?: string;
428
+ /** Sampling temperature (0-2, default: 1) */
429
+ temperature?: number;
430
+ /** Maximum tokens to generate */
431
+ maxTokens?: number;
432
+ /** Response format: "text" or "json" */
433
+ responseFormat?: "text" | "json";
434
+ /** JSON schema for structured output (when responseFormat is "json") */
435
+ jsonSchema?: Record<string, unknown>;
436
+ /** Request timeout in milliseconds */
437
+ timeout?: number;
438
+ /** Ollama-specific: base URL for local instance */
439
+ baseUrl?: string;
440
+ }
441
+ /**
442
+ * Result from LLM chat completion
443
+ */
444
+ interface LLMChatResult {
445
+ /** Generated response content */
446
+ content: string;
447
+ /** Parsed JSON if responseFormat was "json" */
448
+ parsed?: unknown;
449
+ /** Token usage statistics */
450
+ usage: {
451
+ promptTokens: number;
452
+ completionTokens: number;
453
+ totalTokens: number;
454
+ };
455
+ /** Model used for completion */
456
+ model: string;
457
+ /** Finish reason */
458
+ finishReason: "stop" | "length" | "content_filter" | "tool_calls" | "error";
459
+ }
460
+ /**
461
+ * Request for autonomous browser agent execution
462
+ */
463
+ interface BrowserAgentRequest {
464
+ /** Goal/instruction for the agent to achieve */
465
+ goal: string;
466
+ /** Starting URL (optional - agent may navigate) */
467
+ startUrl?: string;
468
+ /** Context ID for persisting cookies/auth/cache (server-side) */
469
+ contextId?: string;
470
+ /** Whether to persist context changes (default: false) */
471
+ persistContext?: boolean;
472
+ /** Timeout for entire agent execution (ms) */
473
+ timeout?: number;
474
+ /** Max steps/actions the agent can take */
475
+ maxSteps?: number;
476
+ /** LLM provider for agent reasoning */
477
+ llmProvider?: LLMProvider;
478
+ /** LLM model for agent reasoning */
479
+ llmModel?: string;
480
+ }
481
+ /**
482
+ * Result from browser agent execution
483
+ */
484
+ interface BrowserAgentResult {
485
+ /** Whether the agent achieved the goal (from Stagehand) */
486
+ success: boolean;
487
+ /** Whether execution completed (false if hit maxSteps limit) */
488
+ completed: boolean;
489
+ /** Human-readable summary of what was accomplished */
490
+ message: string;
491
+ actions: Array<{
492
+ type: string;
493
+ reasoning?: string;
494
+ taskCompleted: boolean;
495
+ pageUrl: string;
496
+ timestamp: number;
497
+ }>;
498
+ usage: {
499
+ inputTokens: number;
500
+ outputTokens: number;
501
+ reasoningTokens: number;
502
+ };
503
+ /** Browserbase session ID */
504
+ sessionId: string;
505
+ /** URL to view session recording */
506
+ debugUrl: string;
507
+ /** Final URL after agent execution */
508
+ finalUrl: string;
509
+ /** Context ID (for use in subsequent calls) */
510
+ contextId?: string;
511
+ executionTimeMs: number;
512
+ }
513
+ /**
514
+ * MCP server configuration for ClaudeAgent
515
+ */
516
+ type ClaudeAgentMcpServerConfig = {
517
+ type?: "stdio";
518
+ command: string;
519
+ args?: string[];
520
+ env?: Record<string, string>;
521
+ } | {
522
+ type: "sse";
523
+ url: string;
524
+ headers?: Record<string, string>;
525
+ } | {
526
+ type: "http";
527
+ url: string;
528
+ headers?: Record<string, string>;
529
+ };
530
+ /**
531
+ * Subagent definition for ClaudeAgent
532
+ */
533
+ interface ClaudeAgentSubagent {
534
+ description: string;
535
+ prompt: string;
536
+ tools?: string[];
537
+ model?: "sonnet" | "opus" | "haiku" | "inherit";
538
+ }
539
+ /**
540
+ * Request for autonomous Claude agent execution
541
+ */
542
+ interface ClaudeAgentRequest {
543
+ /** Task prompt for the agent */
544
+ prompt: string;
545
+ /** Model to use (e.g., "claude-sonnet-4-5-20250929") */
546
+ model?: string;
547
+ /** System prompt for agent behavior */
548
+ systemPrompt?: string;
549
+ /** Tools the agent can use (e.g., ["Read", "Write", "Edit", "Bash"]) */
550
+ allowedTools?: string[];
551
+ /** Permission mode: default, acceptEdits, bypassPermissions */
552
+ permissionMode?: "default" | "acceptEdits" | "bypassPermissions";
553
+ /** Maximum conversation turns */
554
+ maxTurns?: number;
555
+ /** Maximum budget in USD */
556
+ maxBudgetUsd?: number;
557
+ /** Working directory for the agent */
558
+ cwd?: string;
559
+ /** MCP server configurations */
560
+ mcpServers?: Record<string, ClaudeAgentMcpServerConfig>;
561
+ /** Subagent definitions */
562
+ agents?: Record<string, ClaudeAgentSubagent>;
563
+ /** Extra context data passed from blackboard */
564
+ context?: Record<string, unknown>;
565
+ }
566
+ /**
567
+ * Result from Claude agent execution
568
+ */
569
+ interface ClaudeAgentResult {
570
+ /** Final text result from the agent */
571
+ result: string;
572
+ /** Session ID for resuming/continuing */
573
+ sessionId: string;
574
+ /** Whether the agent completed successfully */
575
+ success: boolean;
576
+ /** Number of conversation turns used */
577
+ numTurns: number;
578
+ /** Total cost in USD */
579
+ totalCostUsd: number;
580
+ /** Token usage statistics */
581
+ usage: {
582
+ inputTokens: number;
583
+ outputTokens: number;
584
+ cacheReadTokens: number;
585
+ cacheCreationTokens: number;
586
+ };
587
+ /** Execution duration in milliseconds */
588
+ durationMs: number;
589
+ /** Errors encountered during execution */
590
+ errors?: string[];
591
+ }
592
+ /**
593
+ * Supported GitHub operations
594
+ */
595
+ type GitHubOperation = "createBranch" | "createPullRequest" | "getPullRequest" | "mergePullRequest" | "closePullRequest" | "createReview" | "listIssues" | "addLabels" | "createComment" | "createRelease";
596
+ /**
597
+ * Request for a GitHub operation
598
+ */
599
+ interface GitHubActionRequest {
600
+ /** The operation to perform */
601
+ operation: GitHubOperation;
602
+ /** Repository in "owner/repo" format */
603
+ repo: string;
604
+ /** Operation-specific parameters */
605
+ params: Record<string, unknown>;
606
+ }
607
+ /**
608
+ * Result of a GitHub operation
609
+ */
610
+ interface GitHubActionResult {
611
+ /** Whether the operation succeeded */
612
+ success: boolean;
613
+ /** Operation-specific response data */
614
+ data: unknown;
615
+ /** The operation that was performed */
616
+ operation: GitHubOperation;
617
+ }
618
+ /**
619
+ * A2UI component definition for human task surfaces
620
+ */
621
+ interface A2UIComponent {
622
+ id: string;
623
+ component: Record<string, unknown>;
624
+ weight?: number;
625
+ }
626
+ /**
627
+ * Request to create a human task
628
+ */
629
+ interface CreateHumanTaskRequest {
630
+ /** Btree node ID that created this task */
631
+ nodeId: string;
632
+ /** Tenant ID for multi-tenancy */
633
+ tenantId: string;
634
+ /** Execution/workflow ID */
635
+ executionId: string;
636
+ /** Task title */
637
+ title: string;
638
+ /** Task description */
639
+ description?: string;
640
+ /** Direct assignee email */
641
+ assigneeEmail?: string;
642
+ /** Role-based assignment */
643
+ assigneeRole?: string;
644
+ /** A2UI component definitions (the frozen surface template) */
645
+ a2uiComponents: A2UIComponent[];
646
+ /** Resolved A2UI data model (bindings already evaluated) */
647
+ a2uiDataModel: Record<string, unknown>;
648
+ /** Timeout in milliseconds before task expires */
649
+ timeoutMs?: number;
650
+ /** What to do on timeout: 'expire' | 'approve' | 'reject' */
651
+ onTimeout?: string;
652
+ /** Optional metadata */
653
+ metadata?: Record<string, unknown>;
654
+ }
655
+ /**
656
+ * Result from creating a human task
657
+ */
658
+ interface CreateHumanTaskResult {
659
+ /** Generated task ID (UUID) */
660
+ taskId: string;
661
+ /** URL where the task can be accessed */
662
+ taskUrl: string;
663
+ }
664
+ /**
665
+ * Request to wait for a human task to be completed
666
+ */
667
+ interface WaitForHumanTaskRequest {
668
+ /** Task ID to wait for */
669
+ taskId: string;
670
+ /** Node ID (for signal routing) */
671
+ nodeId: string;
672
+ /** Timeout in milliseconds */
673
+ timeoutMs?: number;
674
+ /** What to do on timeout */
675
+ onTimeout?: string;
676
+ }
677
+ /**
678
+ * Result from a completed human task
679
+ */
680
+ interface WaitForHumanTaskResult {
681
+ /** Whether the task was completed (vs timed out) */
682
+ completed: boolean;
683
+ /** Submitted form data from the user */
684
+ submittedData?: Record<string, unknown>;
685
+ /** Decision string (e.g., 'approved', 'rejected') */
686
+ decision?: string;
687
+ /** User ID who completed the task */
688
+ completedBy?: string;
689
+ /** Timestamp when completed */
690
+ completedAt?: string;
691
+ /** Whether the task timed out */
692
+ timedOut?: boolean;
693
+ }
694
+ /**
695
+ * Content block types for structured LLM messages (Anthropic-compatible)
696
+ */
697
+ type AgentContentBlock = {
698
+ type: "text";
699
+ text: string;
700
+ } | {
701
+ type: "tool_use";
702
+ id: string;
703
+ name: string;
704
+ input: Record<string, unknown>;
705
+ } | {
706
+ type: "tool_result";
707
+ tool_use_id: string;
708
+ content: string;
709
+ is_error?: boolean;
710
+ };
711
+ /**
712
+ * Rich message format supporting both plain text and structured content blocks
713
+ */
714
+ interface AgentMessage {
715
+ role: "user" | "assistant" | "system";
716
+ content: string | AgentContentBlock[];
717
+ }
718
+ /**
719
+ * Tool definition passed to the LLM for tool calling
720
+ */
721
+ interface AgentToolDefinition {
722
+ name: string;
723
+ description: string;
724
+ inputSchema: Record<string, unknown>;
725
+ }
726
+ /**
727
+ * A single tool call from an LLM response
728
+ */
729
+ interface AgentToolCall {
730
+ id: string;
731
+ name: string;
732
+ input: Record<string, unknown>;
733
+ }
734
+ /**
735
+ * Request for a single LLM turn with tool support
736
+ */
737
+ interface AgentLoopTurnRequest {
738
+ provider: LLMProvider;
739
+ model: string;
740
+ systemPrompt?: string;
741
+ messages: AgentMessage[];
742
+ tools?: AgentToolDefinition[];
743
+ temperature?: number;
744
+ maxTokens?: number;
745
+ streamChannelId?: string;
746
+ }
747
+ /**
748
+ * Result from a single LLM turn with tool support
749
+ */
750
+ interface AgentLoopTurnResult {
751
+ content: string;
752
+ toolCalls?: AgentToolCall[];
753
+ stopReason: "end_turn" | "tool_use" | "max_tokens";
754
+ usage: {
755
+ promptTokens: number;
756
+ completionTokens: number;
757
+ totalTokens: number;
758
+ };
759
+ }
760
+ /**
761
+ * Request to execute a tool by name
762
+ */
763
+ interface ExecuteAgentToolRequest {
764
+ toolName: string;
765
+ toolInput: Record<string, unknown>;
766
+ context?: Record<string, unknown>;
767
+ }
768
+ /**
769
+ * Result from executing a tool
770
+ */
771
+ interface ExecuteAgentToolResult {
772
+ content: string;
773
+ isError: boolean;
774
+ }
775
+ /**
776
+ * Payload for generic Temporal signals
777
+ */
778
+ interface GenericSignalPayload {
779
+ signalName: string;
780
+ signalKey?: string;
781
+ data: Record<string, unknown>;
782
+ }
783
+ /**
784
+ * Request to wait for a Temporal signal
785
+ */
786
+ interface WaitForSignalRequest {
787
+ signalName: string;
788
+ signalKey?: string;
789
+ timeoutMs?: number;
790
+ }
791
+ /**
792
+ * Result from waiting for a signal
793
+ */
794
+ interface WaitForSignalResult {
795
+ received: boolean;
796
+ data?: Record<string, unknown>;
797
+ timedOut: boolean;
798
+ }
799
+ /**
800
+ * Port definition for typed inputs/outputs
801
+ */
802
+ interface PortDefinition {
803
+ name: string;
804
+ type: "input" | "output" | "inout";
805
+ description?: string;
806
+ defaultValue?: unknown;
807
+ required?: boolean;
808
+ }
809
+ /**
810
+ * Base interface for all tree nodes
811
+ */
812
+ interface TreeNode {
813
+ readonly id: string;
814
+ readonly name: string;
815
+ readonly type: string;
816
+ tick(context: TemporalContext): Promise<NodeStatus>;
817
+ halt(): void;
818
+ reset(): void;
819
+ clone(): TreeNode;
820
+ providedPorts?(): PortDefinition[];
821
+ status(): NodeStatus;
822
+ lastError?: string;
823
+ parent?: TreeNode;
824
+ children?: TreeNode[];
825
+ }
826
+ /**
827
+ * Constructor type for node factories
828
+ */
829
+ type NodeConstructor<T extends TreeNode = TreeNode> = new (config: NodeConfiguration) => T;
830
+ /**
831
+ * Node metadata for registry
832
+ */
833
+ interface NodeMetadata {
834
+ type: string;
835
+ category: "action" | "condition" | "decorator" | "composite" | "subtree";
836
+ description?: string;
837
+ ports?: PortDefinition[];
838
+ }
839
+ /**
840
+ * Interface for tree registry (session-scoped)
841
+ * Used by nodes like StepGroup and LocateElement to lookup behavior trees
842
+ */
843
+ interface ITreeRegistry {
844
+ hasTree(id: string): boolean;
845
+ cloneTree(id: string): {
846
+ getRoot(): TreeNode;
847
+ };
848
+ getAllTreeIds(): string[];
849
+ registerTree(id: string, tree: {
850
+ getRoot(): TreeNode;
851
+ clone(): {
852
+ getRoot(): TreeNode;
853
+ };
854
+ }, sourceFile: string): void;
855
+ getTree(id: string): {
856
+ getRoot(): TreeNode;
857
+ clone(): {
858
+ getRoot(): TreeNode;
859
+ };
860
+ } | undefined;
861
+ getTreeSourceFile(id: string): string | undefined;
862
+ getTreesForFile(filePath: string): Map<string, {
863
+ getRoot(): TreeNode;
864
+ clone(): {
865
+ getRoot(): TreeNode;
866
+ };
867
+ }>;
868
+ }
869
+ /**
870
+ * Interface for scoped blackboard
871
+ */
872
+ interface IScopedBlackboard {
873
+ get(key: string): unknown;
874
+ set(key: string, value: unknown): void;
875
+ has(key: string): boolean;
876
+ delete(key: string): void;
877
+ clear(): void;
878
+ createScope(name: string): IScopedBlackboard;
879
+ getParentScope(): IScopedBlackboard | null;
880
+ getScopeName(): string;
881
+ getFullScopePath(): string;
882
+ getPort<T>(key: string, defaultValue?: T): T;
883
+ setPort<T>(key: string, value: T): void;
884
+ keys(): string[];
885
+ entries(): [string, unknown][];
886
+ toJSON(): Record<string, unknown>;
887
+ clone(): IScopedBlackboard;
888
+ }
889
+ /**
890
+ * Arguments passed to a BehaviorTree workflow
891
+ */
892
+ interface WorkflowArgs {
893
+ /**
894
+ * Input data to initialize the blackboard
895
+ */
896
+ input?: Record<string, unknown>;
897
+ /**
898
+ * Tree registry for looking up subtrees
899
+ */
900
+ treeRegistry: ITreeRegistry;
901
+ /**
902
+ * Optional session ID
903
+ */
904
+ sessionId?: string;
905
+ /**
906
+ * Activity functions for I/O operations (optional)
907
+ * When provided, nodes that support activities will use them instead of inline execution
908
+ * Controlplane creates these via proxyActivities() and passes them here
909
+ */
910
+ activities?: BtreeActivities;
911
+ /**
912
+ * Token provider for IntegrationAction authentication (optional)
913
+ * Returns OAuth tokens or API keys for third-party services
914
+ */
915
+ tokenProvider?: TokenProvider;
916
+ }
917
+ /**
918
+ * Result returned from a BehaviorTree workflow
919
+ */
920
+ interface WorkflowResult {
921
+ /**
922
+ * Final status of the tree
923
+ */
924
+ status: NodeStatus;
925
+ /**
926
+ * Final blackboard state
927
+ */
928
+ output: Record<string, unknown>;
929
+ }
930
+
931
+ export { type ClaudeAgentResult as $, type A2UIComponent as A, type BtreeActivities as B, type ClaudeAgentMcpServerConfig as C, type DataRef as D, type UploadFileResult as E, type DownloadFileRequest as F, type GitHubOperation as G, type HttpRequestActivity as H, type IScopedBlackboard as I, type DownloadFileResult as J, type DeleteFileRequest as K, type LLMProvider as L, type MessageRole as M, NodeStatus as N, type DeleteFileResult as O, type PortDefinition as P, type FileExistsRequest as Q, type FileExistsResult as R, type LLMMessage as S, type TreeNode as T, type UploadFileRequest as U, type LLMChatRequest as V, type WorkflowArgs as W, type LLMChatResult as X, type BrowserAgentRequest as Y, type BrowserAgentResult as Z, type ClaudeAgentRequest as _, type NodeConfiguration as a, type GitHubActionRequest as a0, type GitHubActionResult as a1, type CreateHumanTaskRequest as a2, type CreateHumanTaskResult as a3, type WaitForHumanTaskRequest as a4, type WaitForHumanTaskResult as a5, type AgentContentBlock as a6, type AgentMessage as a7, type AgentToolCall as a8, type AgentLoopTurnRequest as a9, type AgentLoopTurnResult as aa, type ExecuteAgentToolRequest as ab, type ExecuteAgentToolResult as ac, type GenericSignalPayload as ad, type WaitForSignalRequest as ae, type WaitForSignalResult as af, NodeEventEmitter as b, type TemporalContext as c, type WorkflowResult as d, type NodeConstructor as e, type NodeMetadata as f, type TokenProvider as g, type PieceActivityRequest as h, type ParseFileRequest as i, type ClaudeAgentSubagent as j, type AgentToolDefinition as k, type ITreeRegistry as l, type PieceAuth as m, type PythonScriptRequest as n, type PythonScriptResult as o, type ParseFileResult as p, type GenerateFileRequest as q, type GenerateFileResult as r, type HttpResponseActivity as s, type CodeExecutionRequest as t, type CodeExecutionResult as u, NodeEventType as v, type LogEventData as w, type NodeEvent as x, type NodeEventCallback as y, type TickContext as z };