@q1k-oss/btree-workflows 0.0.1
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.
- package/.claude/settings.local.json +31 -0
- package/CLAUDE.md +181 -0
- package/LICENSE +21 -0
- package/README.md +920 -0
- package/behaviour-tree-workflows-landing/index.html +16 -0
- package/behaviour-tree-workflows-landing/package-lock.json +2074 -0
- package/behaviour-tree-workflows-landing/package.json +31 -0
- package/behaviour-tree-workflows-landing/public/favicon.svg +17 -0
- package/behaviour-tree-workflows-landing/src/App.css +103 -0
- package/behaviour-tree-workflows-landing/src/App.tsx +176 -0
- package/behaviour-tree-workflows-landing/src/components/BlackboardInspector.css +89 -0
- package/behaviour-tree-workflows-landing/src/components/BlackboardInspector.tsx +64 -0
- package/behaviour-tree-workflows-landing/src/components/ExampleSelector.css +64 -0
- package/behaviour-tree-workflows-landing/src/components/ExampleSelector.tsx +34 -0
- package/behaviour-tree-workflows-landing/src/components/ExecutionLog.css +107 -0
- package/behaviour-tree-workflows-landing/src/components/ExecutionLog.tsx +85 -0
- package/behaviour-tree-workflows-landing/src/components/Header.css +50 -0
- package/behaviour-tree-workflows-landing/src/components/Header.tsx +26 -0
- package/behaviour-tree-workflows-landing/src/components/StatusBadge.css +45 -0
- package/behaviour-tree-workflows-landing/src/components/StatusBadge.tsx +15 -0
- package/behaviour-tree-workflows-landing/src/components/Toolbar.css +74 -0
- package/behaviour-tree-workflows-landing/src/components/Toolbar.tsx +53 -0
- package/behaviour-tree-workflows-landing/src/components/TreeVisualizer.css +67 -0
- package/behaviour-tree-workflows-landing/src/components/TreeVisualizer.tsx +192 -0
- package/behaviour-tree-workflows-landing/src/components/YamlEditor.css +18 -0
- package/behaviour-tree-workflows-landing/src/components/YamlEditor.tsx +96 -0
- package/behaviour-tree-workflows-landing/src/lib/count-nodes.ts +11 -0
- package/behaviour-tree-workflows-landing/src/lib/execution-engine.ts +96 -0
- package/behaviour-tree-workflows-landing/src/lib/tree-layout.ts +136 -0
- package/behaviour-tree-workflows-landing/src/lib/yaml-examples.ts +549 -0
- package/behaviour-tree-workflows-landing/src/main.tsx +9 -0
- package/behaviour-tree-workflows-landing/src/stubs/activepieces.ts +18 -0
- package/behaviour-tree-workflows-landing/src/stubs/fs.ts +24 -0
- package/behaviour-tree-workflows-landing/src/stubs/path.ts +16 -0
- package/behaviour-tree-workflows-landing/src/stubs/temporal-activity.ts +6 -0
- package/behaviour-tree-workflows-landing/src/stubs/temporal-workflow.ts +22 -0
- package/behaviour-tree-workflows-landing/tsconfig.json +25 -0
- package/behaviour-tree-workflows-landing/vite.config.ts +40 -0
- package/demo-google-sheets.ts +181 -0
- package/demo-runtime-variables.ts +174 -0
- package/demo-template.ts +208 -0
- package/docs/ARCHITECTURE_SUMMARY.md +613 -0
- package/docs/NODE_REFERENCE.md +504 -0
- package/docs/README.md +53 -0
- package/docs/custom-nodes-architecture.md +826 -0
- package/docs/observability.md +175 -0
- package/docs/yaml-specification.md +990 -0
- package/examples/temporal/README.md +117 -0
- package/examples/temporal/activities.ts +373 -0
- package/examples/temporal/client.ts +115 -0
- package/examples/temporal/python-worker/activities.py +339 -0
- package/examples/temporal/python-worker/requirements.txt +12 -0
- package/examples/temporal/python-worker/worker.py +106 -0
- package/examples/temporal/worker.ts +66 -0
- package/examples/temporal/workflows.ts +6 -0
- package/examples/temporal/yaml-workflow-loader.ts +105 -0
- package/examples/yaml-test.ts +97 -0
- package/examples/yaml-workflows/01-simple-sequence.yaml +25 -0
- package/examples/yaml-workflows/02-parallel-timeout.yaml +45 -0
- package/examples/yaml-workflows/03-ecommerce-checkout.yaml +94 -0
- package/examples/yaml-workflows/04-ai-agent-workflow.yaml +346 -0
- package/examples/yaml-workflows/05-order-processing.yaml +146 -0
- package/examples/yaml-workflows/06-activity-test.yaml +71 -0
- package/examples/yaml-workflows/07-activity-simple-test.yaml +43 -0
- package/examples/yaml-workflows/08-file-processing.yaml +141 -0
- package/examples/yaml-workflows/09-http-request.yaml +137 -0
- package/examples/yaml-workflows/README.md +211 -0
- package/package.json +38 -0
- package/src/actions/code-execution.schema.ts +27 -0
- package/src/actions/code-execution.ts +218 -0
- package/src/actions/generate-file.test.ts +516 -0
- package/src/actions/generate-file.ts +166 -0
- package/src/actions/http-request.test.ts +784 -0
- package/src/actions/http-request.ts +228 -0
- package/src/actions/index.ts +20 -0
- package/src/actions/parse-file.test.ts +448 -0
- package/src/actions/parse-file.ts +139 -0
- package/src/actions/python-script.test.ts +439 -0
- package/src/actions/python-script.ts +154 -0
- package/src/base-node.test.ts +511 -0
- package/src/base-node.ts +605 -0
- package/src/behavior-tree.test.ts +431 -0
- package/src/behavior-tree.ts +283 -0
- package/src/blackboard.test.ts +222 -0
- package/src/blackboard.ts +192 -0
- package/src/composites/conditional.schema.ts +19 -0
- package/src/composites/conditional.test.ts +309 -0
- package/src/composites/conditional.ts +129 -0
- package/src/composites/for-each.schema.ts +23 -0
- package/src/composites/for-each.test.ts +254 -0
- package/src/composites/for-each.ts +132 -0
- package/src/composites/index.ts +15 -0
- package/src/composites/memory-sequence.schema.ts +19 -0
- package/src/composites/memory-sequence.test.ts +223 -0
- package/src/composites/memory-sequence.ts +98 -0
- package/src/composites/parallel.schema.ts +28 -0
- package/src/composites/parallel.test.ts +502 -0
- package/src/composites/parallel.ts +157 -0
- package/src/composites/reactive-sequence.schema.ts +19 -0
- package/src/composites/reactive-sequence.test.ts +170 -0
- package/src/composites/reactive-sequence.ts +85 -0
- package/src/composites/recovery.schema.ts +19 -0
- package/src/composites/recovery.test.ts +366 -0
- package/src/composites/recovery.ts +90 -0
- package/src/composites/selector.schema.ts +19 -0
- package/src/composites/selector.test.ts +387 -0
- package/src/composites/selector.ts +85 -0
- package/src/composites/sequence.schema.ts +19 -0
- package/src/composites/sequence.test.ts +337 -0
- package/src/composites/sequence.ts +72 -0
- package/src/composites/sub-tree.schema.ts +21 -0
- package/src/composites/sub-tree.test.ts +893 -0
- package/src/composites/sub-tree.ts +177 -0
- package/src/composites/while.schema.ts +24 -0
- package/src/composites/while.test.ts +381 -0
- package/src/composites/while.ts +149 -0
- package/src/data-store/index.ts +10 -0
- package/src/data-store/memory-store.ts +161 -0
- package/src/data-store/types.ts +94 -0
- package/src/debug/breakpoint.test.ts +47 -0
- package/src/debug/breakpoint.ts +30 -0
- package/src/debug/index.ts +17 -0
- package/src/debug/resume-point.test.ts +49 -0
- package/src/debug/resume-point.ts +29 -0
- package/src/decorators/delay.schema.ts +21 -0
- package/src/decorators/delay.test.ts +261 -0
- package/src/decorators/delay.ts +140 -0
- package/src/decorators/force-result.schema.ts +32 -0
- package/src/decorators/force-result.test.ts +133 -0
- package/src/decorators/force-result.ts +63 -0
- package/src/decorators/index.ts +13 -0
- package/src/decorators/invert.schema.ts +19 -0
- package/src/decorators/invert.test.ts +135 -0
- package/src/decorators/invert.ts +42 -0
- package/src/decorators/keep-running.schema.ts +20 -0
- package/src/decorators/keep-running.test.ts +105 -0
- package/src/decorators/keep-running.ts +49 -0
- package/src/decorators/precondition.schema.ts +19 -0
- package/src/decorators/precondition.test.ts +351 -0
- package/src/decorators/precondition.ts +139 -0
- package/src/decorators/repeat.schema.ts +21 -0
- package/src/decorators/repeat.test.ts +187 -0
- package/src/decorators/repeat.ts +94 -0
- package/src/decorators/run-once.schema.ts +19 -0
- package/src/decorators/run-once.test.ts +140 -0
- package/src/decorators/run-once.ts +61 -0
- package/src/decorators/soft-assert.schema.ts +19 -0
- package/src/decorators/soft-assert.test.ts +107 -0
- package/src/decorators/soft-assert.ts +68 -0
- package/src/decorators/timeout.schema.ts +21 -0
- package/src/decorators/timeout.test.ts +274 -0
- package/src/decorators/timeout.ts +159 -0
- package/src/errors.test.ts +63 -0
- package/src/errors.ts +34 -0
- package/src/events.test.ts +347 -0
- package/src/events.ts +183 -0
- package/src/index.ts +80 -0
- package/src/integrations/index.ts +30 -0
- package/src/integrations/integration-action.test.ts +571 -0
- package/src/integrations/integration-action.ts +233 -0
- package/src/integrations/piece-executor.ts +320 -0
- package/src/observability/execution-tracker.ts +320 -0
- package/src/observability/index.ts +23 -0
- package/src/observability/sinks.ts +138 -0
- package/src/observability/types.ts +130 -0
- package/src/registry-utils.ts +147 -0
- package/src/registry.test.ts +466 -0
- package/src/registry.ts +334 -0
- package/src/schemas/base.schema.ts +104 -0
- package/src/schemas/index.ts +223 -0
- package/src/schemas/integration.test.ts +238 -0
- package/src/schemas/tree-definition.schema.ts +170 -0
- package/src/schemas/validation.test.ts +146 -0
- package/src/schemas/validation.ts +122 -0
- package/src/scripting/index.ts +22 -0
- package/src/templates/template-loader.test.ts +281 -0
- package/src/templates/template-loader.ts +152 -0
- package/src/temporal-integration.test.ts +213 -0
- package/src/test-nodes.ts +259 -0
- package/src/types.ts +503 -0
- package/src/utilities/index.ts +17 -0
- package/src/utilities/log-message.test.ts +275 -0
- package/src/utilities/log-message.ts +134 -0
- package/src/utilities/regex-extract.test.ts +138 -0
- package/src/utilities/regex-extract.ts +108 -0
- package/src/utilities/variable-resolver.test.ts +416 -0
- package/src/utilities/variable-resolver.ts +318 -0
- package/src/utils/error-handler.test.ts +117 -0
- package/src/utils/error-handler.ts +48 -0
- package/src/utils/signal-check.test.ts +234 -0
- package/src/utils/signal-check.ts +140 -0
- package/src/yaml/errors.ts +143 -0
- package/src/yaml/index.ts +30 -0
- package/src/yaml/loader.ts +39 -0
- package/src/yaml/parser.ts +286 -0
- package/src/yaml/validation/semantic-validator.ts +196 -0
- package/templates/google-sheets/insert-row.yaml +76 -0
- package/templates/notification-sender.yaml +33 -0
- package/templates/order-validation.yaml +44 -0
- package/tsconfig.json +24 -0
- package/vitest.config.ts +25 -0
- package/workflows/order-processor.yaml +59 -0
- package/workflows/process-order-workflow.yaml +142 -0
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
# BTree Node Reference
|
|
2
|
+
|
|
3
|
+
Quick reference for all available nodes in the btree library.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Composites (Control Flow)
|
|
8
|
+
|
|
9
|
+
### Sequence
|
|
10
|
+
Execute children in order. **All must succeed** for sequence to succeed.
|
|
11
|
+
|
|
12
|
+
```yaml
|
|
13
|
+
type: Sequence
|
|
14
|
+
id: my-sequence
|
|
15
|
+
children:
|
|
16
|
+
- type: PrintAction
|
|
17
|
+
props: { message: "Step 1" }
|
|
18
|
+
- type: PrintAction
|
|
19
|
+
props: { message: "Step 2" }
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
| Behavior | Result |
|
|
23
|
+
|----------|--------|
|
|
24
|
+
| All children SUCCESS | SUCCESS |
|
|
25
|
+
| Any child FAILURE | FAILURE (stops immediately) |
|
|
26
|
+
| Child RUNNING | RUNNING (resumes from that child) |
|
|
27
|
+
| No children | SUCCESS |
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
### Selector (aka Fallback)
|
|
32
|
+
Execute children in order. **First success wins**.
|
|
33
|
+
|
|
34
|
+
```yaml
|
|
35
|
+
type: Selector
|
|
36
|
+
id: try-options
|
|
37
|
+
children:
|
|
38
|
+
- type: TryPrimary
|
|
39
|
+
- type: TrySecondary
|
|
40
|
+
- type: TryFallback
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
| Behavior | Result |
|
|
44
|
+
|----------|--------|
|
|
45
|
+
| Any child SUCCESS | SUCCESS (stops immediately) |
|
|
46
|
+
| All children FAILURE | FAILURE |
|
|
47
|
+
| No children | FAILURE |
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
### Conditional
|
|
52
|
+
If-then-else logic. First child is condition, second is "then", third (optional) is "else".
|
|
53
|
+
|
|
54
|
+
```yaml
|
|
55
|
+
type: Conditional
|
|
56
|
+
id: if-ready
|
|
57
|
+
children:
|
|
58
|
+
# Child 1: Condition
|
|
59
|
+
- type: CheckCondition
|
|
60
|
+
props:
|
|
61
|
+
key: "status"
|
|
62
|
+
operator: "=="
|
|
63
|
+
value: "ready"
|
|
64
|
+
# Child 2: Then branch
|
|
65
|
+
- type: PrintAction
|
|
66
|
+
props: { message: "Ready!" }
|
|
67
|
+
# Child 3: Else branch (optional)
|
|
68
|
+
- type: PrintAction
|
|
69
|
+
props: { message: "Not ready" }
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Requirements:** 2-3 children exactly.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
### ForEach
|
|
77
|
+
Iterate over an array from blackboard.
|
|
78
|
+
|
|
79
|
+
```yaml
|
|
80
|
+
type: ForEach
|
|
81
|
+
id: process-items
|
|
82
|
+
props:
|
|
83
|
+
collectionKey: "items" # Blackboard key with array
|
|
84
|
+
itemKey: "item" # Current item stored here
|
|
85
|
+
indexKey: "idx" # Current index (optional)
|
|
86
|
+
children:
|
|
87
|
+
- type: LogMessage
|
|
88
|
+
props:
|
|
89
|
+
message: "Processing ${item} at ${idx}"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
| Behavior | Result |
|
|
93
|
+
|----------|--------|
|
|
94
|
+
| All iterations SUCCESS | SUCCESS |
|
|
95
|
+
| Any iteration FAILURE | FAILURE (stops) |
|
|
96
|
+
| Empty collection | SUCCESS |
|
|
97
|
+
| Missing collection | FAILURE |
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
### While
|
|
102
|
+
Loop while condition succeeds.
|
|
103
|
+
|
|
104
|
+
```yaml
|
|
105
|
+
type: While
|
|
106
|
+
id: retry-loop
|
|
107
|
+
children:
|
|
108
|
+
# Child 1: Condition
|
|
109
|
+
- type: CheckCondition
|
|
110
|
+
props:
|
|
111
|
+
key: "retries"
|
|
112
|
+
operator: "<"
|
|
113
|
+
value: 3
|
|
114
|
+
# Child 2: Body
|
|
115
|
+
- type: Sequence
|
|
116
|
+
children:
|
|
117
|
+
- type: TryAction
|
|
118
|
+
- type: CounterAction
|
|
119
|
+
props: { counterKey: "retries" }
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Requirements:** Exactly 2 children (condition, body).
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
### Parallel
|
|
127
|
+
Execute all children simultaneously.
|
|
128
|
+
|
|
129
|
+
```yaml
|
|
130
|
+
type: Parallel
|
|
131
|
+
id: parallel-tasks
|
|
132
|
+
props:
|
|
133
|
+
policy: "all" # "all" | "one" - success policy
|
|
134
|
+
children:
|
|
135
|
+
- type: TaskA
|
|
136
|
+
- type: TaskB
|
|
137
|
+
- type: TaskC
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
| Policy | SUCCESS when |
|
|
141
|
+
|--------|--------------|
|
|
142
|
+
| `all` | All children succeed |
|
|
143
|
+
| `one` | Any child succeeds |
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
### SubTree
|
|
148
|
+
Execute a registered behavior tree by ID.
|
|
149
|
+
|
|
150
|
+
```yaml
|
|
151
|
+
type: SubTree
|
|
152
|
+
id: run-template
|
|
153
|
+
props:
|
|
154
|
+
treeId: "GoogleSheets.insert-row"
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Creates a scoped blackboard for isolation.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
### Recovery
|
|
162
|
+
Execute recovery action if main action fails.
|
|
163
|
+
|
|
164
|
+
```yaml
|
|
165
|
+
type: Recovery
|
|
166
|
+
id: with-recovery
|
|
167
|
+
children:
|
|
168
|
+
# Child 1: Main action
|
|
169
|
+
- type: MainTask
|
|
170
|
+
# Child 2: Recovery action
|
|
171
|
+
- type: HandleFailure
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Decorators
|
|
177
|
+
|
|
178
|
+
### Timeout
|
|
179
|
+
Fail if child takes too long.
|
|
180
|
+
|
|
181
|
+
```yaml
|
|
182
|
+
type: Timeout
|
|
183
|
+
id: limited-task
|
|
184
|
+
props:
|
|
185
|
+
ms: 5000 # 5 seconds
|
|
186
|
+
children:
|
|
187
|
+
- type: LongRunningTask
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
### Delay
|
|
193
|
+
Wait before executing child.
|
|
194
|
+
|
|
195
|
+
```yaml
|
|
196
|
+
type: Delay
|
|
197
|
+
id: delayed-action
|
|
198
|
+
props:
|
|
199
|
+
ms: 1000 # Wait 1 second
|
|
200
|
+
children:
|
|
201
|
+
- type: MyAction
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
### Repeat
|
|
207
|
+
Execute child multiple times.
|
|
208
|
+
|
|
209
|
+
```yaml
|
|
210
|
+
type: Repeat
|
|
211
|
+
id: retry-3-times
|
|
212
|
+
props:
|
|
213
|
+
times: 3
|
|
214
|
+
stopOnFailure: true # Stop early on failure
|
|
215
|
+
children:
|
|
216
|
+
- type: MyAction
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
### Invert
|
|
222
|
+
Invert child's result (SUCCESS ↔ FAILURE).
|
|
223
|
+
|
|
224
|
+
```yaml
|
|
225
|
+
type: Invert
|
|
226
|
+
id: not-condition
|
|
227
|
+
children:
|
|
228
|
+
- type: CheckCondition
|
|
229
|
+
props:
|
|
230
|
+
key: "isBlocked"
|
|
231
|
+
operator: "=="
|
|
232
|
+
value: true
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
### ForceSuccess / ForceFailure
|
|
238
|
+
Always return specified status regardless of child.
|
|
239
|
+
|
|
240
|
+
```yaml
|
|
241
|
+
type: ForceSuccess
|
|
242
|
+
id: ignore-failure
|
|
243
|
+
children:
|
|
244
|
+
- type: OptionalAction
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
### Precondition
|
|
250
|
+
Check condition before running child.
|
|
251
|
+
|
|
252
|
+
```yaml
|
|
253
|
+
type: Precondition
|
|
254
|
+
id: guarded-action
|
|
255
|
+
props:
|
|
256
|
+
condition: "isEnabled" # Blackboard key (truthy check)
|
|
257
|
+
children:
|
|
258
|
+
- type: MyAction
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
### RunOnce
|
|
264
|
+
Execute child only once (memoized).
|
|
265
|
+
|
|
266
|
+
```yaml
|
|
267
|
+
type: RunOnce
|
|
268
|
+
id: init-once
|
|
269
|
+
children:
|
|
270
|
+
- type: InitializeSystem
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## Actions
|
|
276
|
+
|
|
277
|
+
### CodeExecution
|
|
278
|
+
Execute JavaScript or Python code in a secure sandboxed environment via Microsandbox.
|
|
279
|
+
|
|
280
|
+
```yaml
|
|
281
|
+
type: CodeExecution
|
|
282
|
+
id: calculate-total
|
|
283
|
+
props:
|
|
284
|
+
language: javascript # or 'python'
|
|
285
|
+
timeout: 30000 # Optional, default 30000ms
|
|
286
|
+
code: |
|
|
287
|
+
const items = getBB('items') || [];
|
|
288
|
+
const taxRate = 0.1;
|
|
289
|
+
const subtotal = items.reduce((sum, i) => sum + i.price * i.quantity, 0);
|
|
290
|
+
const total = subtotal * (1 + taxRate);
|
|
291
|
+
setBB('total', total);
|
|
292
|
+
setBB('itemCount', items.length);
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**Python Example:**
|
|
296
|
+
```yaml
|
|
297
|
+
type: CodeExecution
|
|
298
|
+
id: analyze-data
|
|
299
|
+
props:
|
|
300
|
+
language: python
|
|
301
|
+
packages: # Optional: Python packages to install
|
|
302
|
+
- pandas
|
|
303
|
+
code: |
|
|
304
|
+
users = getBB('users')
|
|
305
|
+
setBB('userCount', len(users))
|
|
306
|
+
setBB('domains', list(set(u['email'].split('@')[1] for u in users)))
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
**Available Functions:**
|
|
310
|
+
- `getBB(key)` - Read value from blackboard
|
|
311
|
+
- `setBB(key, value)` - Write value to blackboard
|
|
312
|
+
- `getInput(key)` - Read workflow input (read-only)
|
|
313
|
+
- `console.log(...)` / `print(...)` - Debug logging
|
|
314
|
+
|
|
315
|
+
**Note:** CodeExecution runs in an isolated microVM (Microsandbox) with no network
|
|
316
|
+
access and no cloud credentials. Requires the `executeCode` activity to be configured.
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
### LogMessage
|
|
321
|
+
Log message with blackboard value substitution.
|
|
322
|
+
|
|
323
|
+
```yaml
|
|
324
|
+
type: LogMessage
|
|
325
|
+
id: log-status
|
|
326
|
+
props:
|
|
327
|
+
message: "User ${userId} has ${itemCount} items"
|
|
328
|
+
level: "info" # info | warn | error | debug
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
### PrintAction
|
|
334
|
+
Simple print to console.
|
|
335
|
+
|
|
336
|
+
```yaml
|
|
337
|
+
type: PrintAction
|
|
338
|
+
id: print-hello
|
|
339
|
+
props:
|
|
340
|
+
message: "Hello World"
|
|
341
|
+
outputKey: "lastMessage" # Optional: store in blackboard
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
### WaitAction
|
|
347
|
+
Return RUNNING for specified duration, then SUCCESS.
|
|
348
|
+
|
|
349
|
+
```yaml
|
|
350
|
+
type: WaitAction
|
|
351
|
+
id: wait-1s
|
|
352
|
+
props:
|
|
353
|
+
waitMs: 1000
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
### CounterAction
|
|
359
|
+
Increment a blackboard counter.
|
|
360
|
+
|
|
361
|
+
```yaml
|
|
362
|
+
type: CounterAction
|
|
363
|
+
id: inc-retry
|
|
364
|
+
props:
|
|
365
|
+
counterKey: "retries" # Default: "counter"
|
|
366
|
+
increment: 1 # Default: 1
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
### IntegrationAction
|
|
372
|
+
Execute Active Pieces integration action.
|
|
373
|
+
|
|
374
|
+
```yaml
|
|
375
|
+
type: IntegrationAction
|
|
376
|
+
id: insert-row
|
|
377
|
+
props:
|
|
378
|
+
provider: "google"
|
|
379
|
+
action: "insert_row"
|
|
380
|
+
inputs:
|
|
381
|
+
spreadsheetId: "${bb.sheetId}"
|
|
382
|
+
sheetId: 0
|
|
383
|
+
values:
|
|
384
|
+
values:
|
|
385
|
+
- "Value 1"
|
|
386
|
+
- "Value 2"
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
Result stored in `{nodeId}.result` on blackboard.
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## Conditions
|
|
394
|
+
|
|
395
|
+
### CheckCondition
|
|
396
|
+
Compare blackboard value against expected.
|
|
397
|
+
|
|
398
|
+
```yaml
|
|
399
|
+
type: CheckCondition
|
|
400
|
+
id: is-ready
|
|
401
|
+
props:
|
|
402
|
+
key: "status"
|
|
403
|
+
operator: "==" # ==, !=, >, <, >=, <=
|
|
404
|
+
value: "ready"
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
| Condition | Result |
|
|
408
|
+
|-----------|--------|
|
|
409
|
+
| Comparison true | SUCCESS |
|
|
410
|
+
| Comparison false | FAILURE |
|
|
411
|
+
|
|
412
|
+
---
|
|
413
|
+
|
|
414
|
+
### AlwaysCondition
|
|
415
|
+
Always return configured status.
|
|
416
|
+
|
|
417
|
+
```yaml
|
|
418
|
+
type: AlwaysCondition
|
|
419
|
+
id: always-true
|
|
420
|
+
props:
|
|
421
|
+
returnStatus: 1 # 1=SUCCESS, 0=FAILURE
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
## Blackboard Variable Resolution
|
|
427
|
+
|
|
428
|
+
Many nodes support `${bb.key}` syntax for dynamic values:
|
|
429
|
+
|
|
430
|
+
```yaml
|
|
431
|
+
type: LogMessage
|
|
432
|
+
props:
|
|
433
|
+
message: "Processing ${bb.currentItem} for user ${bb.userId}"
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
For CodeExecution node, use getter/setter functions:
|
|
437
|
+
|
|
438
|
+
```yaml
|
|
439
|
+
type: CodeExecution
|
|
440
|
+
props:
|
|
441
|
+
language: javascript
|
|
442
|
+
code: |
|
|
443
|
+
const user = getBB('userId');
|
|
444
|
+
setBB('greeting', 'Hello, ' + user + '!');
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
---
|
|
448
|
+
|
|
449
|
+
## Common Patterns
|
|
450
|
+
|
|
451
|
+
### Retry with Counter
|
|
452
|
+
|
|
453
|
+
```yaml
|
|
454
|
+
type: While
|
|
455
|
+
id: retry-loop
|
|
456
|
+
children:
|
|
457
|
+
- type: CheckCondition
|
|
458
|
+
props: { key: "retries", operator: "<", value: 3 }
|
|
459
|
+
- type: Sequence
|
|
460
|
+
children:
|
|
461
|
+
- type: Selector
|
|
462
|
+
children:
|
|
463
|
+
- type: MyAction
|
|
464
|
+
- type: ForceSuccess
|
|
465
|
+
children:
|
|
466
|
+
- type: LogMessage
|
|
467
|
+
props: { message: "Attempt ${retries} failed" }
|
|
468
|
+
- type: CounterAction
|
|
469
|
+
props: { counterKey: "retries" }
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
### Conditional Execution
|
|
473
|
+
|
|
474
|
+
```yaml
|
|
475
|
+
type: Conditional
|
|
476
|
+
children:
|
|
477
|
+
- type: CheckCondition
|
|
478
|
+
props: { key: "feature.enabled", operator: "==", value: true }
|
|
479
|
+
- type: FeatureWorkflow
|
|
480
|
+
- type: LogMessage
|
|
481
|
+
props: { message: "Feature disabled, skipping" }
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
### Process Array Items
|
|
485
|
+
|
|
486
|
+
```yaml
|
|
487
|
+
type: ForEach
|
|
488
|
+
props:
|
|
489
|
+
collectionKey: "orders"
|
|
490
|
+
itemKey: "order"
|
|
491
|
+
children:
|
|
492
|
+
- type: Sequence
|
|
493
|
+
children:
|
|
494
|
+
- type: LogMessage
|
|
495
|
+
props: { message: "Processing order ${order.id}" }
|
|
496
|
+
- type: IntegrationAction
|
|
497
|
+
props:
|
|
498
|
+
provider: google
|
|
499
|
+
action: insert_row
|
|
500
|
+
inputs:
|
|
501
|
+
spreadsheetId: "${bb.sheetId}"
|
|
502
|
+
values:
|
|
503
|
+
values: ["${bb.order.id}", "${bb.order.customer}"]
|
|
504
|
+
```
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# btree Documentation
|
|
2
|
+
|
|
3
|
+
Documentation for the @wayfarer-ai/btree-workflows library.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
| Document | Description |
|
|
8
|
+
|----------|-------------|
|
|
9
|
+
| [ARCHITECTURE_SUMMARY.md](./ARCHITECTURE_SUMMARY.md) | Overall architecture, data flow patterns, DataStore interface |
|
|
10
|
+
| [NODE_REFERENCE.md](./NODE_REFERENCE.md) | Quick reference for all node types |
|
|
11
|
+
| [yaml-specification.md](./yaml-specification.md) | YAML workflow format specification |
|
|
12
|
+
| [custom-nodes-architecture.md](./custom-nodes-architecture.md) | Guide for creating custom nodes |
|
|
13
|
+
| [observability.md](./observability.md) | ExecutionTracker, error capture, timeline |
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import {
|
|
19
|
+
Registry,
|
|
20
|
+
registerStandardNodes,
|
|
21
|
+
loadTreeFromYaml,
|
|
22
|
+
BehaviorTree,
|
|
23
|
+
} from '@wayfarer-ai/btree';
|
|
24
|
+
|
|
25
|
+
// Setup registry
|
|
26
|
+
const registry = new Registry();
|
|
27
|
+
registerStandardNodes(registry);
|
|
28
|
+
|
|
29
|
+
// Load and execute workflow
|
|
30
|
+
const tree = loadTreeFromYaml(yamlContent, registry);
|
|
31
|
+
const bt = new BehaviorTree(tree);
|
|
32
|
+
const result = await bt.execute();
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Node Categories
|
|
36
|
+
|
|
37
|
+
| Category | Count | Examples |
|
|
38
|
+
|----------|-------|----------|
|
|
39
|
+
| Composites | 10 | Sequence, Selector, Parallel, ForEach, While, Conditional |
|
|
40
|
+
| Decorators | 10 | Timeout, Delay, Repeat, Invert, ForceSuccess, Precondition |
|
|
41
|
+
| Actions | 9+ | PrintAction, CodeExecution, LogMessage, HttpRequest |
|
|
42
|
+
|
|
43
|
+
## Key Concepts
|
|
44
|
+
|
|
45
|
+
- **NodeStatus**: `SUCCESS | FAILURE | RUNNING | IDLE`
|
|
46
|
+
- **ScopedBlackboard**: Hierarchical key-value store
|
|
47
|
+
- **TickEngine**: Executes tree with exponential backoff
|
|
48
|
+
- **ExecutionTracker**: Aggregates events for observability
|
|
49
|
+
|
|
50
|
+
## Related
|
|
51
|
+
|
|
52
|
+
- [q1k-controlplane](https://github.com/wayfarer-ai/q1k-controlplane) - Application using btree
|
|
53
|
+
- [Temporal.io](https://temporal.io) - Durable execution runtime
|