syv-conductor-nodes 0.1.0__tar.gz
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.
- syv_conductor_nodes-0.1.0/.gitignore +49 -0
- syv_conductor_nodes-0.1.0/LICENSE +199 -0
- syv_conductor_nodes-0.1.0/PKG-INFO +17 -0
- syv_conductor_nodes-0.1.0/pyproject.toml +26 -0
- syv_conductor_nodes-0.1.0/src/conductor_nodes/__init__.py +111 -0
- syv_conductor_nodes-0.1.0/src/conductor_nodes/decision.py +47 -0
- syv_conductor_nodes-0.1.0/src/conductor_nodes/json_ops.py +61 -0
- syv_conductor_nodes-0.1.0/src/conductor_nodes/logic.py +59 -0
- syv_conductor_nodes-0.1.0/src/conductor_nodes/loop.py +57 -0
- syv_conductor_nodes-0.1.0/src/conductor_nodes/math.py +94 -0
- syv_conductor_nodes-0.1.0/src/conductor_nodes/regex_ops.py +55 -0
- syv_conductor_nodes-0.1.0/src/conductor_nodes/signal.py +77 -0
- syv_conductor_nodes-0.1.0/src/conductor_nodes/subprocess.py +47 -0
- syv_conductor_nodes-0.1.0/src/conductor_nodes/text.py +91 -0
- syv_conductor_nodes-0.1.0/src/conductor_nodes/while_loop.py +56 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
*.egg-info/
|
|
7
|
+
*.egg
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
*.whl
|
|
11
|
+
|
|
12
|
+
# Virtual environments
|
|
13
|
+
.venv/
|
|
14
|
+
venv/
|
|
15
|
+
env/
|
|
16
|
+
|
|
17
|
+
# uv
|
|
18
|
+
uv.lock
|
|
19
|
+
|
|
20
|
+
# IDE
|
|
21
|
+
.idea/
|
|
22
|
+
.vscode/
|
|
23
|
+
*.swp
|
|
24
|
+
*.swo
|
|
25
|
+
*~
|
|
26
|
+
|
|
27
|
+
# OS
|
|
28
|
+
.DS_Store
|
|
29
|
+
Thumbs.db
|
|
30
|
+
|
|
31
|
+
# Testing
|
|
32
|
+
.pytest_cache/
|
|
33
|
+
.coverage
|
|
34
|
+
htmlcov/
|
|
35
|
+
.mypy_cache/
|
|
36
|
+
|
|
37
|
+
# Docs build
|
|
38
|
+
site/
|
|
39
|
+
|
|
40
|
+
# Notebooks
|
|
41
|
+
*.ipynb
|
|
42
|
+
.ipynb_checkpoints/
|
|
43
|
+
# ...but keep the tutorial notebooks in examples/
|
|
44
|
+
!examples/*.ipynb
|
|
45
|
+
|
|
46
|
+
# Misc
|
|
47
|
+
*.log
|
|
48
|
+
.env
|
|
49
|
+
.env.*
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may accept warranty, liability,
|
|
167
|
+
or other obligations and/or rights consistent with this License.
|
|
168
|
+
However, in accepting such obligations, You may act only on Your
|
|
169
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
170
|
+
other Contributor, and only if You agree to indemnify, defend,
|
|
171
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
172
|
+
or claims asserted against, such Contributor by reason of your
|
|
173
|
+
accepting any such warranty or support.
|
|
174
|
+
|
|
175
|
+
END OF TERMS AND CONDITIONS
|
|
176
|
+
|
|
177
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
178
|
+
|
|
179
|
+
To apply the Apache License to your work, attach the following
|
|
180
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
181
|
+
replaced with your own identifying information. (Don't include
|
|
182
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
183
|
+
comment syntax for the file format. We also recommend that a
|
|
184
|
+
file or class name and description of a copyright owner be provided
|
|
185
|
+
on a separate line in the Source form of the Work.
|
|
186
|
+
|
|
187
|
+
Copyright 2026 Syvai
|
|
188
|
+
|
|
189
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
190
|
+
you may not use this file except in compliance with the License.
|
|
191
|
+
You may obtain a copy of the License at
|
|
192
|
+
|
|
193
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
194
|
+
|
|
195
|
+
Unless required by applicable law or agreed to in writing, software
|
|
196
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
197
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
198
|
+
implied. See the License for the specific language governing
|
|
199
|
+
permissions and limitations under the License.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: syv-conductor-nodes
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Standard-library nodes for conductor — text, math, logic, JSON, regex, and loop markers. Categories opt-in via register_all(registry, categories=[...]).
|
|
5
|
+
Project-URL: Repository, https://github.com/syvai/conductor
|
|
6
|
+
Author-email: Syvai <billy@syv.ai>
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Typing :: Typed
|
|
15
|
+
Requires-Python: >=3.12
|
|
16
|
+
Requires-Dist: pydantic>=2.0
|
|
17
|
+
Requires-Dist: syv-conductor
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "syv-conductor-nodes"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Standard-library nodes for conductor — text, math, logic, JSON, regex, and loop markers. Categories opt-in via register_all(registry, categories=[...])."
|
|
5
|
+
requires-python = ">=3.12"
|
|
6
|
+
authors = [{ name = "Syvai", email = "billy@syv.ai" }]
|
|
7
|
+
license = "Apache-2.0"
|
|
8
|
+
classifiers = [
|
|
9
|
+
"Development Status :: 4 - Beta",
|
|
10
|
+
"Intended Audience :: Developers",
|
|
11
|
+
"License :: OSI Approved :: Apache Software License",
|
|
12
|
+
"Programming Language :: Python :: 3",
|
|
13
|
+
"Programming Language :: Python :: 3.12",
|
|
14
|
+
"Typing :: Typed",
|
|
15
|
+
]
|
|
16
|
+
dependencies = ["syv-conductor", "pydantic>=2.0"]
|
|
17
|
+
|
|
18
|
+
[project.urls]
|
|
19
|
+
Repository = "https://github.com/syvai/conductor"
|
|
20
|
+
|
|
21
|
+
[build-system]
|
|
22
|
+
requires = ["hatchling"]
|
|
23
|
+
build-backend = "hatchling.build"
|
|
24
|
+
|
|
25
|
+
[tool.hatch.build.targets.wheel]
|
|
26
|
+
packages = ["src/conductor_nodes"]
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""conductor-nodes — reusable node library for the conductor DAG engine.
|
|
2
|
+
|
|
3
|
+
Each submodule exports a ``register(reg)`` function that attaches its nodes
|
|
4
|
+
to a ``conductor.NodeRegistry``. Pick categories individually, or call
|
|
5
|
+
``register_all()`` for everything.
|
|
6
|
+
|
|
7
|
+
Example:
|
|
8
|
+
|
|
9
|
+
from conductor import NodeRegistry
|
|
10
|
+
from conductor_nodes import register_all
|
|
11
|
+
|
|
12
|
+
reg = NodeRegistry()
|
|
13
|
+
register_all(reg)
|
|
14
|
+
|
|
15
|
+
# …or just what you need:
|
|
16
|
+
from conductor_nodes import text, math
|
|
17
|
+
reg = NodeRegistry()
|
|
18
|
+
text.register(reg)
|
|
19
|
+
math.register(reg)
|
|
20
|
+
|
|
21
|
+
Node IDs are prefixed by category (``text-uppercase``, ``math-add``, …) to
|
|
22
|
+
minimize collisions with application-level node IDs. The canonical for-each
|
|
23
|
+
markers — ``for-each-start`` and ``for-each-end`` — are kept unprefixed to
|
|
24
|
+
match the conductor core's compound-region discovery.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
from __future__ import annotations
|
|
28
|
+
|
|
29
|
+
from typing import TYPE_CHECKING
|
|
30
|
+
|
|
31
|
+
from conductor_nodes import (
|
|
32
|
+
decision,
|
|
33
|
+
json_ops,
|
|
34
|
+
logic,
|
|
35
|
+
loop,
|
|
36
|
+
math,
|
|
37
|
+
regex_ops,
|
|
38
|
+
signal,
|
|
39
|
+
subprocess,
|
|
40
|
+
text,
|
|
41
|
+
while_loop,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
if TYPE_CHECKING:
|
|
45
|
+
from conductor import NodeRegistry
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
CATEGORIES: dict[str, object] = {
|
|
49
|
+
"text": text,
|
|
50
|
+
"math": math,
|
|
51
|
+
"logic": logic,
|
|
52
|
+
"loop": loop,
|
|
53
|
+
"json": json_ops,
|
|
54
|
+
"regex": regex_ops,
|
|
55
|
+
"decision": decision,
|
|
56
|
+
"while": while_loop,
|
|
57
|
+
"subprocess": subprocess,
|
|
58
|
+
"signal": signal,
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def register_all(registry: "NodeRegistry", *, categories: list[str] | None = None) -> None:
|
|
63
|
+
"""Register every (or a filtered subset of) category's nodes.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
registry: The target ``NodeRegistry``.
|
|
67
|
+
categories: If provided, only these category names register. Unknown
|
|
68
|
+
names raise ``KeyError``. If None, every category registers.
|
|
69
|
+
"""
|
|
70
|
+
names = list(CATEGORIES) if categories is None else categories
|
|
71
|
+
for name in names:
|
|
72
|
+
if name not in CATEGORIES:
|
|
73
|
+
raise KeyError(
|
|
74
|
+
f"Unknown category '{name}'. Known: {sorted(CATEGORIES)}"
|
|
75
|
+
)
|
|
76
|
+
CATEGORIES[name].register(registry) # type: ignore[attr-defined]
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def get_default_registry(*, categories: list[str] | None = None) -> "NodeRegistry":
|
|
80
|
+
"""Return a fresh ``NodeRegistry`` pre-populated with standard-library nodes.
|
|
81
|
+
|
|
82
|
+
Useful when you want to compose with your own registry via
|
|
83
|
+
``my_reg.merge(get_default_registry())``. A new registry is built on
|
|
84
|
+
every call — no hidden shared state, mutating the result is safe.
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
categories: Optional subset of category names (same list as
|
|
88
|
+
``register_all``). ``None`` means all categories.
|
|
89
|
+
"""
|
|
90
|
+
from conductor import NodeRegistry
|
|
91
|
+
|
|
92
|
+
reg = NodeRegistry()
|
|
93
|
+
register_all(reg, categories=categories)
|
|
94
|
+
return reg
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
__all__ = [
|
|
98
|
+
"CATEGORIES",
|
|
99
|
+
"register_all",
|
|
100
|
+
"get_default_registry",
|
|
101
|
+
"text",
|
|
102
|
+
"math",
|
|
103
|
+
"logic",
|
|
104
|
+
"loop",
|
|
105
|
+
"json_ops",
|
|
106
|
+
"regex_ops",
|
|
107
|
+
"decision",
|
|
108
|
+
"while_loop",
|
|
109
|
+
"subprocess",
|
|
110
|
+
"signal",
|
|
111
|
+
]
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""Built-in decision node.
|
|
2
|
+
|
|
3
|
+
A decision node evaluates CEL ``when`` expressions on its outgoing edges
|
|
4
|
+
and selectively marks branches as SKIPPED. Unlike an ``if-else`` node
|
|
5
|
+
whose logic lives inside Python, the decision node makes branching
|
|
6
|
+
visible on the diagram as data on the edges — the same pattern as BPMN
|
|
7
|
+
gateways, Step Functions ``Choice``, and Temporal's continue-as.
|
|
8
|
+
|
|
9
|
+
Register via :func:`register`; the runtime magic is in
|
|
10
|
+
``conductor/execution/engine.py`` which detects ``is_decision=True`` nodes
|
|
11
|
+
and post-processes their guards.
|
|
12
|
+
|
|
13
|
+
The node's output is the ``value`` input passed through unchanged, so
|
|
14
|
+
downstream consumers can still read the data that drove the decision.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
from typing import TYPE_CHECKING, Annotated, Any
|
|
20
|
+
|
|
21
|
+
from conductor.types import NodeCategory
|
|
22
|
+
from conductor.widgets import Output, Text
|
|
23
|
+
|
|
24
|
+
if TYPE_CHECKING:
|
|
25
|
+
from conductor import NodeRegistry
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def register(registry: "NodeRegistry") -> None:
|
|
29
|
+
"""Register the canonical ``decision`` node."""
|
|
30
|
+
|
|
31
|
+
@registry.node(
|
|
32
|
+
"decision",
|
|
33
|
+
version=1,
|
|
34
|
+
name="Decision",
|
|
35
|
+
description=(
|
|
36
|
+
"Branching gateway. Evaluates `when` CEL expressions on outgoing "
|
|
37
|
+
"edges — exactly one branch is taken, the others are marked "
|
|
38
|
+
"SKIPPED."
|
|
39
|
+
),
|
|
40
|
+
category=NodeCategory.DECISION,
|
|
41
|
+
is_decision=True,
|
|
42
|
+
)
|
|
43
|
+
def decision(
|
|
44
|
+
value: Annotated[Any, Text(label="Value")] = None,
|
|
45
|
+
) -> Annotated[Any, Output(label="Pass-through")]:
|
|
46
|
+
"""Pass the input through so downstream readers still see the value."""
|
|
47
|
+
return value
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""JSON nodes (``json-parse``, ``json-stringify``, ``json-get``)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
from typing import TYPE_CHECKING, Annotated, Any
|
|
7
|
+
|
|
8
|
+
from conductor.widgets import Checkbox, Output, Range, Text, Textarea
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from conductor import NodeRegistry
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def register(registry: "NodeRegistry") -> None:
|
|
15
|
+
"""Register every JSON node on the supplied registry."""
|
|
16
|
+
|
|
17
|
+
@registry.node("json-parse", version=1, name="JSON Parse", description="Parses a JSON string into an object")
|
|
18
|
+
def parse(
|
|
19
|
+
text: Annotated[str, Textarea(label="JSON text")],
|
|
20
|
+
) -> Annotated[object, Output(label="Parsed")]:
|
|
21
|
+
return json.loads(text)
|
|
22
|
+
|
|
23
|
+
@registry.node(
|
|
24
|
+
"json-stringify", version=1, name="JSON Stringify",
|
|
25
|
+
description="Serializes a value to a JSON string",
|
|
26
|
+
)
|
|
27
|
+
def stringify(
|
|
28
|
+
value: Annotated[object, Text(label="Value")],
|
|
29
|
+
indent: Annotated[int, Range(label="Indent", min_val=0, max_val=8, step=1)] = 0,
|
|
30
|
+
sort_keys: Annotated[bool, Checkbox(label="Sort keys")] = False,
|
|
31
|
+
) -> Annotated[str, Output(label="JSON")]:
|
|
32
|
+
return json.dumps(value, indent=indent or None, sort_keys=sort_keys)
|
|
33
|
+
|
|
34
|
+
@registry.node(
|
|
35
|
+
"json-get", version=1, name="JSON Get",
|
|
36
|
+
description="Reads a dotted path from a JSON-like value (e.g. 'user.name', 'items.0.id')",
|
|
37
|
+
)
|
|
38
|
+
def get_path(
|
|
39
|
+
value: Annotated[object, Text(label="Value")],
|
|
40
|
+
path: Annotated[str, Text(label="Path")],
|
|
41
|
+
) -> Annotated[object, Output(label="Extracted")]:
|
|
42
|
+
return _get_path(value, path)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _get_path(value: Any, path: str) -> Any:
|
|
46
|
+
"""Walk a dotted path — each segment indexes a dict by key or a list by integer."""
|
|
47
|
+
if not path:
|
|
48
|
+
return value
|
|
49
|
+
current = value
|
|
50
|
+
for raw in path.split("."):
|
|
51
|
+
segment = raw.strip()
|
|
52
|
+
if isinstance(current, dict):
|
|
53
|
+
current = current.get(segment)
|
|
54
|
+
elif isinstance(current, list):
|
|
55
|
+
try:
|
|
56
|
+
current = current[int(segment)]
|
|
57
|
+
except (ValueError, IndexError):
|
|
58
|
+
return None
|
|
59
|
+
else:
|
|
60
|
+
return None
|
|
61
|
+
return current
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""Control-flow / logic nodes that produce the SKIPPED sentinel to branch."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING, Annotated
|
|
6
|
+
|
|
7
|
+
from conductor._sentinel import SKIPPED
|
|
8
|
+
from conductor.types import NodeCategory
|
|
9
|
+
from conductor.widgets import Checkbox, Output, Text, Textarea
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from conductor import NodeRegistry
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def register(registry: "NodeRegistry") -> None:
|
|
16
|
+
"""Register every logic node on the supplied registry."""
|
|
17
|
+
|
|
18
|
+
@registry.node(
|
|
19
|
+
"logic-if-empty", version=1, name="If Empty",
|
|
20
|
+
description="Routes text based on whether it is empty (after strip)",
|
|
21
|
+
category=NodeCategory.CONTROL,
|
|
22
|
+
)
|
|
23
|
+
def if_empty(
|
|
24
|
+
text: Annotated[str, Textarea(label="Text")],
|
|
25
|
+
) -> tuple[
|
|
26
|
+
Annotated[str, Output(label="Not empty")],
|
|
27
|
+
Annotated[str, Output(label="Empty")],
|
|
28
|
+
]:
|
|
29
|
+
if text.strip():
|
|
30
|
+
return (text, SKIPPED)
|
|
31
|
+
return (SKIPPED, text)
|
|
32
|
+
|
|
33
|
+
@registry.node(
|
|
34
|
+
"logic-if-equals", version=1, name="If Equals",
|
|
35
|
+
description="Routes based on whether two strings are equal",
|
|
36
|
+
category=NodeCategory.CONTROL,
|
|
37
|
+
)
|
|
38
|
+
def if_equals(
|
|
39
|
+
a: Annotated[str, Text(label="A")],
|
|
40
|
+
b: Annotated[str, Text(label="B")],
|
|
41
|
+
case_sensitive: Annotated[bool, Checkbox(label="Case sensitive")] = True,
|
|
42
|
+
) -> tuple[
|
|
43
|
+
Annotated[str, Output(label="Equal")],
|
|
44
|
+
Annotated[str, Output(label="Not equal")],
|
|
45
|
+
]:
|
|
46
|
+
left = a if case_sensitive else a.lower()
|
|
47
|
+
right = b if case_sensitive else b.lower()
|
|
48
|
+
if left == right:
|
|
49
|
+
return (a, SKIPPED)
|
|
50
|
+
return (SKIPPED, a)
|
|
51
|
+
|
|
52
|
+
@registry.node(
|
|
53
|
+
"logic-not", version=1, name="Not",
|
|
54
|
+
description="Logical negation of a boolean",
|
|
55
|
+
)
|
|
56
|
+
def not_(
|
|
57
|
+
value: Annotated[bool, Checkbox(label="Value")],
|
|
58
|
+
) -> Annotated[bool, Output(label="Negated")]:
|
|
59
|
+
return not value
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""Canonical for-each loop markers.
|
|
2
|
+
|
|
3
|
+
The engine's ``FOR_EACH`` compound node type discovers regions by looking
|
|
4
|
+
for nodes whose registered ``base_id`` starts with ``for-each-start`` /
|
|
5
|
+
``for-each-end``. These are the canonical implementations.
|
|
6
|
+
|
|
7
|
+
To use the markers you must pass the ``FOR_EACH`` compound type to
|
|
8
|
+
``compile()`` — nothing in this module wires that up for you:
|
|
9
|
+
|
|
10
|
+
from conductor import compile
|
|
11
|
+
from conductor.compound.for_each import FOR_EACH
|
|
12
|
+
from conductor_nodes import loop
|
|
13
|
+
|
|
14
|
+
loop.register(registry)
|
|
15
|
+
compiled = compile(nodes, edges, registry, compound_types=[FOR_EACH])
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
from typing import TYPE_CHECKING, Annotated
|
|
21
|
+
|
|
22
|
+
from conductor.types import NodeCategory
|
|
23
|
+
from conductor.widgets import ConnectionList, Dropdown, Output, Text
|
|
24
|
+
|
|
25
|
+
if TYPE_CHECKING:
|
|
26
|
+
from conductor import NodeRegistry
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def register(registry: "NodeRegistry") -> None:
|
|
30
|
+
"""Register the for-each-start / for-each-end marker nodes."""
|
|
31
|
+
|
|
32
|
+
@registry.node(
|
|
33
|
+
"for-each-start", version=1, name="For Each (Start)",
|
|
34
|
+
description="Iterates over a list of items. Must be paired with for-each-end.",
|
|
35
|
+
category=NodeCategory.CONTROL,
|
|
36
|
+
)
|
|
37
|
+
def for_each_start(
|
|
38
|
+
items: Annotated[list, ConnectionList(label="Items")],
|
|
39
|
+
execution_mode: Annotated[
|
|
40
|
+
str,
|
|
41
|
+
Dropdown(label="Execution", choices=["Sequential", "Parallel"]),
|
|
42
|
+
] = "Sequential",
|
|
43
|
+
) -> tuple[
|
|
44
|
+
Annotated[object, Output(label="Item")],
|
|
45
|
+
Annotated[int, Output(label="Index")],
|
|
46
|
+
]:
|
|
47
|
+
raise NotImplementedError("Handled by the FOR_EACH compound node")
|
|
48
|
+
|
|
49
|
+
@registry.node(
|
|
50
|
+
"for-each-end", version=1, name="For Each (End)",
|
|
51
|
+
description="Collects loop body results into a list",
|
|
52
|
+
category=NodeCategory.CONTROL,
|
|
53
|
+
)
|
|
54
|
+
def for_each_end(
|
|
55
|
+
item: Annotated[object, Text(label="Item")],
|
|
56
|
+
) -> Annotated[list, Output(label="Collected")]:
|
|
57
|
+
raise NotImplementedError("Handled by the FOR_EACH compound node")
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""Arithmetic nodes (``math-add``, ``math-subtract``, etc.)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING, Annotated
|
|
6
|
+
|
|
7
|
+
from conductor.widgets import Output, Range, Text
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from conductor import NodeRegistry
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def register(registry: "NodeRegistry") -> None:
|
|
14
|
+
"""Register every math node on the supplied registry."""
|
|
15
|
+
|
|
16
|
+
@registry.node("math-add", version=1, name="Add", description="a + b")
|
|
17
|
+
def add(
|
|
18
|
+
a: Annotated[float, Text(label="A")],
|
|
19
|
+
b: Annotated[float, Text(label="B")],
|
|
20
|
+
) -> Annotated[float, Output(label="Sum")]:
|
|
21
|
+
return a + b
|
|
22
|
+
|
|
23
|
+
@registry.node("math-subtract", version=1, name="Subtract", description="a - b")
|
|
24
|
+
def subtract(
|
|
25
|
+
a: Annotated[float, Text(label="A")],
|
|
26
|
+
b: Annotated[float, Text(label="B")],
|
|
27
|
+
) -> Annotated[float, Output(label="Difference")]:
|
|
28
|
+
return a - b
|
|
29
|
+
|
|
30
|
+
@registry.node("math-multiply", version=1, name="Multiply", description="a * b")
|
|
31
|
+
def multiply(
|
|
32
|
+
a: Annotated[float, Text(label="A")],
|
|
33
|
+
b: Annotated[float, Text(label="B")],
|
|
34
|
+
) -> Annotated[float, Output(label="Product")]:
|
|
35
|
+
return a * b
|
|
36
|
+
|
|
37
|
+
@registry.node(
|
|
38
|
+
"math-divide", version=1, name="Divide",
|
|
39
|
+
description="a / b — raises on b == 0",
|
|
40
|
+
)
|
|
41
|
+
def divide(
|
|
42
|
+
a: Annotated[float, Text(label="A")],
|
|
43
|
+
b: Annotated[float, Text(label="B")],
|
|
44
|
+
) -> Annotated[float, Output(label="Quotient")]:
|
|
45
|
+
if b == 0:
|
|
46
|
+
raise ValueError("Division by zero")
|
|
47
|
+
return a / b
|
|
48
|
+
|
|
49
|
+
@registry.node("math-modulo", version=1, name="Modulo", description="a % b")
|
|
50
|
+
def modulo(
|
|
51
|
+
a: Annotated[float, Text(label="A")],
|
|
52
|
+
b: Annotated[float, Text(label="B")],
|
|
53
|
+
) -> Annotated[float, Output(label="Remainder")]:
|
|
54
|
+
if b == 0:
|
|
55
|
+
raise ValueError("Modulo by zero")
|
|
56
|
+
return a % b
|
|
57
|
+
|
|
58
|
+
@registry.node(
|
|
59
|
+
"math-round", version=1, name="Round",
|
|
60
|
+
description="Rounds to the given number of decimals",
|
|
61
|
+
)
|
|
62
|
+
def round_(
|
|
63
|
+
value: Annotated[float, Text(label="Value")],
|
|
64
|
+
decimals: Annotated[int, Range(label="Decimals", min_val=0, max_val=10, step=1)] = 0,
|
|
65
|
+
) -> Annotated[float, Output(label="Rounded")]:
|
|
66
|
+
return round(value, decimals)
|
|
67
|
+
|
|
68
|
+
@registry.node(
|
|
69
|
+
"math-min", version=1, name="Min",
|
|
70
|
+
description="Minimum of a list of numbers",
|
|
71
|
+
)
|
|
72
|
+
def min_(
|
|
73
|
+
values: Annotated[list[float], Text(label="Values")],
|
|
74
|
+
) -> Annotated[float, Output(label="Min")]:
|
|
75
|
+
if not values:
|
|
76
|
+
raise ValueError("min requires at least one value")
|
|
77
|
+
return min(values)
|
|
78
|
+
|
|
79
|
+
@registry.node(
|
|
80
|
+
"math-max", version=1, name="Max",
|
|
81
|
+
description="Maximum of a list of numbers",
|
|
82
|
+
)
|
|
83
|
+
def max_(
|
|
84
|
+
values: Annotated[list[float], Text(label="Values")],
|
|
85
|
+
) -> Annotated[float, Output(label="Max")]:
|
|
86
|
+
if not values:
|
|
87
|
+
raise ValueError("max requires at least one value")
|
|
88
|
+
return max(values)
|
|
89
|
+
|
|
90
|
+
@registry.node("math-abs", version=1, name="Absolute", description="|value|")
|
|
91
|
+
def abs_(
|
|
92
|
+
value: Annotated[float, Text(label="Value")],
|
|
93
|
+
) -> Annotated[float, Output(label="Absolute")]:
|
|
94
|
+
return abs(value)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""Regex nodes (``regex-match``, ``regex-replace``, ``regex-extract``)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
from typing import TYPE_CHECKING, Annotated
|
|
7
|
+
|
|
8
|
+
from conductor.widgets import Checkbox, Output, Text, Textarea
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from conductor import NodeRegistry
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def register(registry: "NodeRegistry") -> None:
|
|
15
|
+
"""Register every regex node on the supplied registry."""
|
|
16
|
+
|
|
17
|
+
@registry.node(
|
|
18
|
+
"regex-match", version=1, name="Regex Match",
|
|
19
|
+
description="True if the pattern matches anywhere in the text",
|
|
20
|
+
)
|
|
21
|
+
def match(
|
|
22
|
+
text: Annotated[str, Textarea(label="Text")],
|
|
23
|
+
pattern: Annotated[str, Text(label="Pattern")],
|
|
24
|
+
ignore_case: Annotated[bool, Checkbox(label="Ignore case")] = False,
|
|
25
|
+
) -> Annotated[bool, Output(label="Matched")]:
|
|
26
|
+
flags = re.IGNORECASE if ignore_case else 0
|
|
27
|
+
return re.search(pattern, text, flags=flags) is not None
|
|
28
|
+
|
|
29
|
+
@registry.node(
|
|
30
|
+
"regex-replace", version=1, name="Regex Replace",
|
|
31
|
+
description="Replaces all pattern matches with `replacement`",
|
|
32
|
+
)
|
|
33
|
+
def replace(
|
|
34
|
+
text: Annotated[str, Textarea(label="Text")],
|
|
35
|
+
pattern: Annotated[str, Text(label="Pattern")],
|
|
36
|
+
replacement: Annotated[str, Text(label="Replace with")] = "",
|
|
37
|
+
ignore_case: Annotated[bool, Checkbox(label="Ignore case")] = False,
|
|
38
|
+
) -> Annotated[str, Output(label="Result")]:
|
|
39
|
+
flags = re.IGNORECASE if ignore_case else 0
|
|
40
|
+
return re.sub(pattern, replacement, text, flags=flags)
|
|
41
|
+
|
|
42
|
+
@registry.node(
|
|
43
|
+
"regex-extract", version=1, name="Regex Extract",
|
|
44
|
+
description="Returns a list of all matches (or the first group of each, if present)",
|
|
45
|
+
)
|
|
46
|
+
def extract(
|
|
47
|
+
text: Annotated[str, Textarea(label="Text")],
|
|
48
|
+
pattern: Annotated[str, Text(label="Pattern")],
|
|
49
|
+
ignore_case: Annotated[bool, Checkbox(label="Ignore case")] = False,
|
|
50
|
+
) -> Annotated[list[str], Output(label="Matches")]:
|
|
51
|
+
flags = re.IGNORECASE if ignore_case else 0
|
|
52
|
+
compiled = re.compile(pattern, flags=flags)
|
|
53
|
+
if compiled.groups:
|
|
54
|
+
return [m.group(1) for m in compiled.finditer(text)]
|
|
55
|
+
return compiled.findall(text)
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""Signal / event nodes — pause until an external event arrives.
|
|
2
|
+
|
|
3
|
+
Signal nodes are the general-purpose cousin of HITL: they pause the
|
|
4
|
+
flow, checkpoint state, and hand off to the host. The host inspects the
|
|
5
|
+
checkpoint's ``signal_name`` / ``correlation`` / timeout fields and
|
|
6
|
+
wires those into its own message bus / webhook endpoint / timer daemon.
|
|
7
|
+
When the signal fires, the host calls ``resume_sync(compiled,
|
|
8
|
+
checkpoint, payload)`` to continue.
|
|
9
|
+
|
|
10
|
+
Two kinds are registered:
|
|
11
|
+
|
|
12
|
+
* ``signal-wait`` — waits for an explicit named event (``kind="event"``)
|
|
13
|
+
or a timer (``kind="timer"``). One node type, a ``kind`` discriminator.
|
|
14
|
+
* ``signal-timer`` — convenience alias that only does time-based waits.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
from typing import TYPE_CHECKING, Annotated, Any
|
|
20
|
+
|
|
21
|
+
from conductor.errors import SignalRequired
|
|
22
|
+
from conductor.types import NodeCategory
|
|
23
|
+
from conductor.widgets import CodeEditor, Dropdown, Number, Output, Text
|
|
24
|
+
|
|
25
|
+
if TYPE_CHECKING:
|
|
26
|
+
from conductor import NodeRegistry
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def register(registry: "NodeRegistry") -> None:
|
|
30
|
+
"""Register the signal / timer / event nodes."""
|
|
31
|
+
|
|
32
|
+
@registry.node(
|
|
33
|
+
"signal-wait", version=1, name="Wait for Signal",
|
|
34
|
+
description=(
|
|
35
|
+
"Pauses the flow until an external signal arrives. The host "
|
|
36
|
+
"reads (signal_name, correlation, timeout_seconds) from the "
|
|
37
|
+
"checkpoint and resumes the flow when the signal fires."
|
|
38
|
+
),
|
|
39
|
+
category=NodeCategory.EVENT,
|
|
40
|
+
is_signal=True,
|
|
41
|
+
)
|
|
42
|
+
def signal_wait(
|
|
43
|
+
kind: Annotated[
|
|
44
|
+
str,
|
|
45
|
+
Dropdown(label="Kind", choices=["event", "timer"]),
|
|
46
|
+
] = "event",
|
|
47
|
+
signal_name: Annotated[str, Text(label="Signal name")] = "",
|
|
48
|
+
correlation: Annotated[
|
|
49
|
+
str, CodeEditor(label="Correlation (CEL)", description="Optional CEL expression")
|
|
50
|
+
] = "",
|
|
51
|
+
timeout_seconds: Annotated[
|
|
52
|
+
float, Number(label="Timeout (seconds)")
|
|
53
|
+
] = 0,
|
|
54
|
+
) -> Annotated[Any, Output(label="Payload")]:
|
|
55
|
+
# If already resumed with a payload, surface it here. The engine
|
|
56
|
+
# injects the payload by pre-seeding results, so this function is
|
|
57
|
+
# only called on the initial pause.
|
|
58
|
+
raise SignalRequired(
|
|
59
|
+
signal_name or kind,
|
|
60
|
+
correlation=correlation or None,
|
|
61
|
+
timeout_seconds=timeout_seconds or None,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
@registry.node(
|
|
65
|
+
"signal-timer", version=1, name="Timer",
|
|
66
|
+
description="Wait for a duration, then continue. Host fires the timer.",
|
|
67
|
+
category=NodeCategory.EVENT,
|
|
68
|
+
is_signal=True,
|
|
69
|
+
)
|
|
70
|
+
def signal_timer(
|
|
71
|
+
seconds: Annotated[float, Number(label="Seconds")] = 60,
|
|
72
|
+
) -> Annotated[Any, Output(label="Fired at")]:
|
|
73
|
+
raise SignalRequired(
|
|
74
|
+
"timer",
|
|
75
|
+
correlation=None,
|
|
76
|
+
timeout_seconds=float(seconds),
|
|
77
|
+
)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""Subprocess-call marker node.
|
|
2
|
+
|
|
3
|
+
See :mod:`conductor.compound.subprocess` for the runtime. Bind a
|
|
4
|
+
``SubprocessRegistry`` when compiling:
|
|
5
|
+
|
|
6
|
+
from conductor import compile
|
|
7
|
+
from conductor.compound.subprocess import SUBPROCESS, SubprocessRegistry
|
|
8
|
+
from conductor_nodes import subprocess
|
|
9
|
+
|
|
10
|
+
subprocess.register(registry)
|
|
11
|
+
sub_registry = SubprocessRegistry()
|
|
12
|
+
sub_registry.register(other_flow)
|
|
13
|
+
compiled = compile(
|
|
14
|
+
flow=caller_flow, registry=registry,
|
|
15
|
+
compound_types=[SUBPROCESS],
|
|
16
|
+
subprocess_registry=sub_registry,
|
|
17
|
+
)
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
from typing import TYPE_CHECKING, Annotated, Any
|
|
23
|
+
|
|
24
|
+
from conductor.types import NodeCategory
|
|
25
|
+
from conductor.widgets import Number, Output, SchemaBuilder, Text
|
|
26
|
+
|
|
27
|
+
if TYPE_CHECKING:
|
|
28
|
+
from conductor import NodeRegistry
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def register(registry: "NodeRegistry") -> None:
|
|
32
|
+
"""Register the subprocess-call marker node."""
|
|
33
|
+
|
|
34
|
+
@registry.node(
|
|
35
|
+
"subprocess-call", version=1, name="Subprocess",
|
|
36
|
+
description=(
|
|
37
|
+
"Calls another flow by id and version. The sub-flow runs "
|
|
38
|
+
"synchronously; its results are returned as this node's output."
|
|
39
|
+
),
|
|
40
|
+
category=NodeCategory.CONTROL,
|
|
41
|
+
)
|
|
42
|
+
def subprocess_call(
|
|
43
|
+
flow_id: Annotated[str, Text(label="Flow id")] = "",
|
|
44
|
+
flow_version: Annotated[int, Number(label="Flow version", integer_only=True)] = 1,
|
|
45
|
+
inputs: Annotated[dict, SchemaBuilder(label="Input mapping")] = None, # type: ignore[assignment]
|
|
46
|
+
) -> Annotated[Any, Output(label="Sub-flow results")]:
|
|
47
|
+
raise NotImplementedError("Handled by the SUBPROCESS compound node")
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"""Text-manipulation nodes (``text-uppercase``, ``text-lowercase``, etc.)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING, Annotated
|
|
6
|
+
|
|
7
|
+
from conductor.widgets import Checkbox, Output, Text, Textarea
|
|
8
|
+
from conductor.widgets import List as ListWidget
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from conductor import NodeRegistry
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def register(registry: "NodeRegistry") -> None:
|
|
15
|
+
"""Register every text node on the supplied registry."""
|
|
16
|
+
|
|
17
|
+
@registry.node("text-uppercase", version=1, name="Uppercase", description="Returns the text in uppercase")
|
|
18
|
+
def uppercase(
|
|
19
|
+
text: Annotated[str, Textarea(label="Text")],
|
|
20
|
+
) -> Annotated[str, Output(label="Uppercased")]:
|
|
21
|
+
return text.upper()
|
|
22
|
+
|
|
23
|
+
@registry.node("text-lowercase", version=1, name="Lowercase", description="Returns the text in lowercase")
|
|
24
|
+
def lowercase(
|
|
25
|
+
text: Annotated[str, Textarea(label="Text")],
|
|
26
|
+
) -> Annotated[str, Output(label="Lowercased")]:
|
|
27
|
+
return text.lower()
|
|
28
|
+
|
|
29
|
+
@registry.node("text-trim", version=1, name="Trim", description="Strips leading/trailing whitespace")
|
|
30
|
+
def trim(
|
|
31
|
+
text: Annotated[str, Textarea(label="Text")],
|
|
32
|
+
) -> Annotated[str, Output(label="Trimmed")]:
|
|
33
|
+
return text.strip()
|
|
34
|
+
|
|
35
|
+
@registry.node("text-length", version=1, name="Length", description="Character count of the text")
|
|
36
|
+
def length(
|
|
37
|
+
text: Annotated[str, Textarea(label="Text")],
|
|
38
|
+
) -> Annotated[int, Output(label="Length")]:
|
|
39
|
+
return len(text)
|
|
40
|
+
|
|
41
|
+
@registry.node("text-concat", version=1, name="Concat", description="Concatenates two strings with an optional separator")
|
|
42
|
+
def concat(
|
|
43
|
+
a: Annotated[str, Text(label="A")],
|
|
44
|
+
b: Annotated[str, Text(label="B")],
|
|
45
|
+
separator: Annotated[str, Text(label="Separator")] = "",
|
|
46
|
+
) -> Annotated[str, Output(label="Result")]:
|
|
47
|
+
return f"{a}{separator}{b}"
|
|
48
|
+
|
|
49
|
+
@registry.node(
|
|
50
|
+
"text-replace", version=1, name="Replace",
|
|
51
|
+
description="Replaces every occurrence of a substring with another",
|
|
52
|
+
)
|
|
53
|
+
def replace(
|
|
54
|
+
text: Annotated[str, Textarea(label="Text")],
|
|
55
|
+
needle: Annotated[str, Text(label="Find")],
|
|
56
|
+
replacement: Annotated[str, Text(label="Replace with")] = "",
|
|
57
|
+
) -> Annotated[str, Output(label="Result")]:
|
|
58
|
+
return text.replace(needle, replacement)
|
|
59
|
+
|
|
60
|
+
@registry.node("text-contains", version=1, name="Contains", description="True if `needle` appears in `text`")
|
|
61
|
+
def contains(
|
|
62
|
+
text: Annotated[str, Textarea(label="Text")],
|
|
63
|
+
needle: Annotated[str, Text(label="Needle")],
|
|
64
|
+
case_sensitive: Annotated[bool, Checkbox(label="Case sensitive")] = True,
|
|
65
|
+
) -> Annotated[bool, Output(label="Contains")]:
|
|
66
|
+
if case_sensitive:
|
|
67
|
+
return needle in text
|
|
68
|
+
return needle.lower() in text.lower()
|
|
69
|
+
|
|
70
|
+
@registry.node("text-split", version=1, name="Split", description="Splits text on a separator into a list")
|
|
71
|
+
def split(
|
|
72
|
+
text: Annotated[str, Textarea(label="Text")],
|
|
73
|
+
separator: Annotated[str, Text(label="Separator")] = ",",
|
|
74
|
+
) -> Annotated[list[str], Output(label="Parts")]:
|
|
75
|
+
return text.split(separator)
|
|
76
|
+
|
|
77
|
+
@registry.node(
|
|
78
|
+
"text-join", version=1, name="Join",
|
|
79
|
+
description="Joins a list of strings with a separator",
|
|
80
|
+
)
|
|
81
|
+
def join(
|
|
82
|
+
parts: Annotated[list[str], ListWidget(label="Parts", item_widget=Text(label="Part"))],
|
|
83
|
+
separator: Annotated[str, Text(label="Separator")] = ", ",
|
|
84
|
+
) -> Annotated[str, Output(label="Joined")]:
|
|
85
|
+
return separator.join(str(p) for p in parts)
|
|
86
|
+
|
|
87
|
+
@registry.node("text-reverse", version=1, name="Reverse", description="Returns the text reversed")
|
|
88
|
+
def reverse(
|
|
89
|
+
text: Annotated[str, Textarea(label="Text")],
|
|
90
|
+
) -> Annotated[str, Output(label="Reversed")]:
|
|
91
|
+
return text[::-1]
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""While-loop markers — canonical node ids the ``WHILE`` compound discovers.
|
|
2
|
+
|
|
3
|
+
See :mod:`conductor.compound.while_loop` for the runtime behavior. To
|
|
4
|
+
actually run a while-loop you must pass the ``WHILE`` compound type to
|
|
5
|
+
``compile()``:
|
|
6
|
+
|
|
7
|
+
from conductor import compile
|
|
8
|
+
from conductor.compound.while_loop import WHILE
|
|
9
|
+
from conductor_nodes import while_loop
|
|
10
|
+
|
|
11
|
+
while_loop.register(registry)
|
|
12
|
+
compiled = compile(nodes, edges, registry, compound_types=[WHILE])
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
from typing import TYPE_CHECKING, Annotated
|
|
18
|
+
|
|
19
|
+
from conductor.types import NodeCategory
|
|
20
|
+
from conductor.widgets import Checkbox, CodeEditor, Number, Output, Text
|
|
21
|
+
|
|
22
|
+
if TYPE_CHECKING:
|
|
23
|
+
from conductor import NodeRegistry
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def register(registry: "NodeRegistry") -> None:
|
|
27
|
+
"""Register the while-start / while-end marker nodes."""
|
|
28
|
+
|
|
29
|
+
@registry.node(
|
|
30
|
+
"while-start", version=1, name="While (Start)",
|
|
31
|
+
description=(
|
|
32
|
+
"Loops while a CEL condition is true. The condition has access to "
|
|
33
|
+
"`iteration` (the current 1-based count) and `last` (the body's "
|
|
34
|
+
"most recent return value). Must be paired with while-end."
|
|
35
|
+
),
|
|
36
|
+
category=NodeCategory.CONTROL,
|
|
37
|
+
)
|
|
38
|
+
def while_start(
|
|
39
|
+
condition: Annotated[str, CodeEditor(label="Condition (CEL)")] = "iteration < 5",
|
|
40
|
+
max_iterations: Annotated[int, Number(label="Max iterations", integer_only=True)] = 1000,
|
|
41
|
+
negate: Annotated[bool, Checkbox(label="Until (negate condition)")] = False,
|
|
42
|
+
) -> tuple[
|
|
43
|
+
Annotated[int, Output(label="Iteration")],
|
|
44
|
+
Annotated[object, Output(label="Last")],
|
|
45
|
+
]:
|
|
46
|
+
raise NotImplementedError("Handled by the WHILE compound node")
|
|
47
|
+
|
|
48
|
+
@registry.node(
|
|
49
|
+
"while-end", version=1, name="While (End)",
|
|
50
|
+
description="Captures the body's last return value as the loop's result.",
|
|
51
|
+
category=NodeCategory.CONTROL,
|
|
52
|
+
)
|
|
53
|
+
def while_end(
|
|
54
|
+
item: Annotated[object, Text(label="Item")],
|
|
55
|
+
) -> Annotated[object, Output(label="Last value")]:
|
|
56
|
+
raise NotImplementedError("Handled by the WHILE compound node")
|