trigix-node-sdk 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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 北京祺智科技有限公司
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,90 @@
1
+ Metadata-Version: 2.4
2
+ Name: trigix-node-sdk
3
+ Version: 0.1.0
4
+ Summary: Write and serve custom Trigix workflow nodes over HTTP.
5
+ Author-email: 北京祺智科技有限公司 <managecode@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/bj-qizhi/trigix
8
+ Project-URL: Repository, https://github.com/bj-qizhi/trigix
9
+ Project-URL: Documentation, https://github.com/bj-qizhi/trigix/tree/master/sdk/python
10
+ Keywords: trigix,workflow,automation,nodes,sdk,ai
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
18
+ Requires-Python: >=3.11
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: fastapi>=0.115.0
22
+ Requires-Dist: pydantic>=2.0.0
23
+ Requires-Dist: uvicorn[standard]>=0.30.0
24
+ Provides-Extra: test
25
+ Requires-Dist: pytest>=8.0.0; extra == "test"
26
+ Requires-Dist: httpx>=0.27.0; extra == "test"
27
+ Dynamic: license-file
28
+
29
+ # Trigix Node SDK (Python)
30
+
31
+ Write a custom Trigix workflow node as a Python function and serve it over HTTP.
32
+ No changes to the Trigix executor are required — the executor calls your node
33
+ like any other.
34
+
35
+ ## Quick start
36
+
37
+ ```bash
38
+ pip install trigix-node-sdk
39
+ # or from this repo: pip install -e sdk/python
40
+ uvicorn examples.greeter:app --port 9000
41
+ ```
42
+
43
+ ```python
44
+ from trigix_node_sdk import node, create_app
45
+
46
+ @node(slug="greet", label="Greeter",
47
+ config_schema={"type": "object",
48
+ "properties": {"name": {"type": "string"}}})
49
+ def greet(config, input, node_outputs):
50
+ name = config.get("name") or input.get("name", "world")
51
+ return {"greeting": f"Hello, {name}!"}
52
+
53
+ app = create_app()
54
+ ```
55
+
56
+ Then in Trigix → **Custom Nodes**, register:
57
+ - **slug**: `greet`
58
+ - **endpoint**: `http://your-host:9000/nodes/greet`
59
+ - **config schema**: copy from `GET /manifest`
60
+
61
+ Add a **Custom** node to a workflow, pick `greet`, and it runs your code.
62
+
63
+ ## The contract
64
+
65
+ The executor POSTs to `/nodes/<slug>`:
66
+
67
+ ```json
68
+ { "node_id": "n1", "config": { "name": "Ada" },
69
+ "input_json": "{\"...\":\"...\"}", "node_outputs": { "prev": "{...}" } }
70
+ ```
71
+
72
+ Your handler `def handler(config, input, node_outputs) -> dict` receives the
73
+ parsed `input` and returns a JSON-serializable dict. The server wraps it as:
74
+
75
+ ```json
76
+ { "output_json": "{\"greeting\":\"Hello, Ada!\"}" }
77
+ ```
78
+
79
+ Downstream nodes reference your output via `{{node_id.field}}`.
80
+
81
+ ## Discovery
82
+
83
+ `GET /manifest` lists every registered node (slug, label, description,
84
+ config schema, endpoint) so it can be registered in Trigix in one step.
85
+
86
+ ## Security
87
+
88
+ Custom nodes run in your own process, isolated from the Trigix core. Run the
89
+ node service on a trusted network; the executor reaches it by URL. (WASM-based
90
+ in-process isolation for untrusted nodes is a planned future option.)
@@ -0,0 +1,62 @@
1
+ # Trigix Node SDK (Python)
2
+
3
+ Write a custom Trigix workflow node as a Python function and serve it over HTTP.
4
+ No changes to the Trigix executor are required — the executor calls your node
5
+ like any other.
6
+
7
+ ## Quick start
8
+
9
+ ```bash
10
+ pip install trigix-node-sdk
11
+ # or from this repo: pip install -e sdk/python
12
+ uvicorn examples.greeter:app --port 9000
13
+ ```
14
+
15
+ ```python
16
+ from trigix_node_sdk import node, create_app
17
+
18
+ @node(slug="greet", label="Greeter",
19
+ config_schema={"type": "object",
20
+ "properties": {"name": {"type": "string"}}})
21
+ def greet(config, input, node_outputs):
22
+ name = config.get("name") or input.get("name", "world")
23
+ return {"greeting": f"Hello, {name}!"}
24
+
25
+ app = create_app()
26
+ ```
27
+
28
+ Then in Trigix → **Custom Nodes**, register:
29
+ - **slug**: `greet`
30
+ - **endpoint**: `http://your-host:9000/nodes/greet`
31
+ - **config schema**: copy from `GET /manifest`
32
+
33
+ Add a **Custom** node to a workflow, pick `greet`, and it runs your code.
34
+
35
+ ## The contract
36
+
37
+ The executor POSTs to `/nodes/<slug>`:
38
+
39
+ ```json
40
+ { "node_id": "n1", "config": { "name": "Ada" },
41
+ "input_json": "{\"...\":\"...\"}", "node_outputs": { "prev": "{...}" } }
42
+ ```
43
+
44
+ Your handler `def handler(config, input, node_outputs) -> dict` receives the
45
+ parsed `input` and returns a JSON-serializable dict. The server wraps it as:
46
+
47
+ ```json
48
+ { "output_json": "{\"greeting\":\"Hello, Ada!\"}" }
49
+ ```
50
+
51
+ Downstream nodes reference your output via `{{node_id.field}}`.
52
+
53
+ ## Discovery
54
+
55
+ `GET /manifest` lists every registered node (slug, label, description,
56
+ config schema, endpoint) so it can be registered in Trigix in one step.
57
+
58
+ ## Security
59
+
60
+ Custom nodes run in your own process, isolated from the Trigix core. Run the
61
+ node service on a trusted network; the executor reaches it by URL. (WASM-based
62
+ in-process isolation for untrusted nodes is a planned future option.)
@@ -0,0 +1,41 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "trigix-node-sdk"
7
+ version = "0.1.0"
8
+ description = "Write and serve custom Trigix workflow nodes over HTTP."
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "北京祺智科技有限公司", email = "managecode@gmail.com" }]
13
+ keywords = ["trigix", "workflow", "automation", "nodes", "sdk", "ai"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Topic :: Software Development :: Libraries :: Application Frameworks",
22
+ ]
23
+ dependencies = [
24
+ "fastapi>=0.115.0",
25
+ "pydantic>=2.0.0",
26
+ "uvicorn[standard]>=0.30.0",
27
+ ]
28
+
29
+ [project.optional-dependencies]
30
+ test = ["pytest>=8.0.0", "httpx>=0.27.0"]
31
+
32
+ [project.urls]
33
+ Homepage = "https://github.com/bj-qizhi/trigix"
34
+ Repository = "https://github.com/bj-qizhi/trigix"
35
+ Documentation = "https://github.com/bj-qizhi/trigix/tree/master/sdk/python"
36
+
37
+ [tool.setuptools]
38
+ packages = ["trigix_node_sdk"]
39
+
40
+ [tool.pytest.ini_options]
41
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,58 @@
1
+ # Copyright © 2026 北京祺智科技有限公司. All rights reserved.
2
+ # https://www.qzso.com/ · managecode@gmail.com
3
+
4
+ import json
5
+
6
+ from fastapi.testclient import TestClient
7
+
8
+ from trigix_node_sdk import create_app, node, run_node
9
+
10
+
11
+ @node(slug="upper", label="Uppercase", config_schema={"type": "object"})
12
+ def upper(config, input, node_outputs):
13
+ return {"out": str(input.get("text", "")).upper()}
14
+
15
+
16
+ def test_run_node_parses_input_and_returns_output_json():
17
+ out = run_node("upper", {}, json.dumps({"text": "hi"}), {})
18
+ assert json.loads(out) == {"out": "HI"}
19
+
20
+
21
+ def test_run_node_tolerates_bad_input_json():
22
+ out = run_node("upper", {}, "not json", {})
23
+ assert json.loads(out) == {"out": ""}
24
+
25
+
26
+ def test_http_contract_matches_executor():
27
+ client = TestClient(create_app("http://node:9000"))
28
+
29
+ # manifest lists the node with its endpoint
30
+ manifest = client.get("/manifest").json()
31
+ slugs = {n["slug"]: n for n in manifest["nodes"]}
32
+ assert "upper" in slugs
33
+ assert slugs["upper"]["endpoint"] == "http://node:9000/nodes/upper"
34
+
35
+ # the executor contract: {node_id, config, input_json, node_outputs} -> {output_json}
36
+ resp = client.post(
37
+ "/nodes/upper",
38
+ json={"node_id": "n1", "config": {}, "input_json": json.dumps({"text": "abc"}), "node_outputs": {}},
39
+ )
40
+ assert resp.status_code == 200
41
+ assert json.loads(resp.json()["output_json"]) == {"out": "ABC"}
42
+
43
+
44
+ def test_unknown_node_returns_404():
45
+ client = TestClient(create_app())
46
+ resp = client.post("/nodes/ghost", json={"input_json": "{}"})
47
+ assert resp.status_code == 404
48
+
49
+
50
+ def test_handler_error_returns_500():
51
+ @node(slug="boom")
52
+ def boom(config, input, node_outputs):
53
+ raise ValueError("kaboom")
54
+
55
+ client = TestClient(create_app())
56
+ resp = client.post("/nodes/boom", json={"input_json": "{}"})
57
+ assert resp.status_code == 500
58
+ assert "kaboom" in resp.json()["detail"]
@@ -0,0 +1,129 @@
1
+ # Copyright © 2026 北京祺智科技有限公司. All rights reserved.
2
+ # https://www.qzso.com/ · managecode@gmail.com
3
+
4
+ """Trigix custom node SDK.
5
+
6
+ Write a workflow node as a plain Python function and serve it over HTTP — no
7
+ changes to the Trigix executor required. Register the node's endpoint in Trigix
8
+ (Custom Nodes settings) and it appears in the workflow editor.
9
+
10
+ from trigix_node_sdk import node, create_app
11
+
12
+ @node(slug="greet", label="Greeter",
13
+ config_schema={"type": "object",
14
+ "properties": {"name": {"type": "string"}}})
15
+ def greet(config, input, node_outputs):
16
+ name = config.get("name") or input.get("name", "world")
17
+ return {"greeting": f"Hello, {name}!"}
18
+
19
+ app = create_app() # uvicorn module:app --port 9000
20
+
21
+ The node contract (matches the executor): the runtime POSTs
22
+ ``{node_id, config, input_json, node_outputs}`` to ``/nodes/<slug>`` and expects
23
+ ``{output_json}``. Your handler receives the parsed ``input`` dict and returns a
24
+ JSON-serializable dict.
25
+ """
26
+
27
+ from __future__ import annotations
28
+
29
+ import json
30
+ from dataclasses import dataclass
31
+ from typing import Any, Callable
32
+
33
+ from pydantic import BaseModel
34
+
35
+ Handler = Callable[[dict, dict, dict], Any]
36
+
37
+
38
+ class NodeRequest(BaseModel):
39
+ node_id: str = ""
40
+ config: dict = {}
41
+ input_json: str = "{}"
42
+ node_outputs: dict = {}
43
+
44
+
45
+ @dataclass
46
+ class NodeDef:
47
+ slug: str
48
+ label: str
49
+ description: str
50
+ config_schema: dict
51
+ handler: Handler
52
+
53
+
54
+ _REGISTRY: dict[str, NodeDef] = {}
55
+
56
+
57
+ def node(
58
+ slug: str,
59
+ label: str | None = None,
60
+ description: str = "",
61
+ config_schema: dict | None = None,
62
+ ) -> Callable[[Handler], Handler]:
63
+ """Register a function as a Trigix custom node."""
64
+
65
+ def decorator(fn: Handler) -> Handler:
66
+ _REGISTRY[slug] = NodeDef(
67
+ slug=slug,
68
+ label=label or slug,
69
+ description=description,
70
+ config_schema=config_schema or {"type": "object"},
71
+ handler=fn,
72
+ )
73
+ return fn
74
+
75
+ return decorator
76
+
77
+
78
+ def registry() -> dict[str, NodeDef]:
79
+ return dict(_REGISTRY)
80
+
81
+
82
+ def run_node(slug: str, config: dict, input_json: str, node_outputs: dict) -> str:
83
+ """Execute a registered node and return its ``output_json``. Raises
84
+ KeyError for an unknown slug."""
85
+ nd = _REGISTRY[slug]
86
+ try:
87
+ input_data = json.loads(input_json or "{}")
88
+ except (json.JSONDecodeError, TypeError):
89
+ input_data = {}
90
+ result = nd.handler(config or {}, input_data, node_outputs or {})
91
+ return json.dumps(result)
92
+
93
+
94
+ def create_app(base_url: str = ""):
95
+ """Build a FastAPI app serving every registered node plus a discovery
96
+ manifest. `base_url` is prefixed to the endpoint URLs in the manifest."""
97
+ from fastapi import FastAPI, HTTPException
98
+
99
+ app = FastAPI(title="Trigix Custom Nodes")
100
+
101
+ @app.get("/healthz")
102
+ def healthz() -> dict[str, str]:
103
+ return {"status": "ok"}
104
+
105
+ @app.get("/manifest")
106
+ def manifest() -> dict[str, list[dict]]:
107
+ return {
108
+ "nodes": [
109
+ {
110
+ "slug": d.slug,
111
+ "label": d.label,
112
+ "description": d.description,
113
+ "config_schema": d.config_schema,
114
+ "endpoint": f"{base_url}/nodes/{d.slug}",
115
+ }
116
+ for d in _REGISTRY.values()
117
+ ]
118
+ }
119
+
120
+ @app.post("/nodes/{slug}")
121
+ def run(slug: str, req: NodeRequest) -> dict[str, str]:
122
+ if slug not in _REGISTRY:
123
+ raise HTTPException(status_code=404, detail=f"unknown node '{slug}'")
124
+ try:
125
+ return {"output_json": run_node(slug, req.config, req.input_json, req.node_outputs)}
126
+ except Exception as exc: # surface handler errors as 500
127
+ raise HTTPException(status_code=500, detail=f"node '{slug}' failed: {exc}") from exc
128
+
129
+ return app
@@ -0,0 +1,90 @@
1
+ Metadata-Version: 2.4
2
+ Name: trigix-node-sdk
3
+ Version: 0.1.0
4
+ Summary: Write and serve custom Trigix workflow nodes over HTTP.
5
+ Author-email: 北京祺智科技有限公司 <managecode@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/bj-qizhi/trigix
8
+ Project-URL: Repository, https://github.com/bj-qizhi/trigix
9
+ Project-URL: Documentation, https://github.com/bj-qizhi/trigix/tree/master/sdk/python
10
+ Keywords: trigix,workflow,automation,nodes,sdk,ai
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
18
+ Requires-Python: >=3.11
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: fastapi>=0.115.0
22
+ Requires-Dist: pydantic>=2.0.0
23
+ Requires-Dist: uvicorn[standard]>=0.30.0
24
+ Provides-Extra: test
25
+ Requires-Dist: pytest>=8.0.0; extra == "test"
26
+ Requires-Dist: httpx>=0.27.0; extra == "test"
27
+ Dynamic: license-file
28
+
29
+ # Trigix Node SDK (Python)
30
+
31
+ Write a custom Trigix workflow node as a Python function and serve it over HTTP.
32
+ No changes to the Trigix executor are required — the executor calls your node
33
+ like any other.
34
+
35
+ ## Quick start
36
+
37
+ ```bash
38
+ pip install trigix-node-sdk
39
+ # or from this repo: pip install -e sdk/python
40
+ uvicorn examples.greeter:app --port 9000
41
+ ```
42
+
43
+ ```python
44
+ from trigix_node_sdk import node, create_app
45
+
46
+ @node(slug="greet", label="Greeter",
47
+ config_schema={"type": "object",
48
+ "properties": {"name": {"type": "string"}}})
49
+ def greet(config, input, node_outputs):
50
+ name = config.get("name") or input.get("name", "world")
51
+ return {"greeting": f"Hello, {name}!"}
52
+
53
+ app = create_app()
54
+ ```
55
+
56
+ Then in Trigix → **Custom Nodes**, register:
57
+ - **slug**: `greet`
58
+ - **endpoint**: `http://your-host:9000/nodes/greet`
59
+ - **config schema**: copy from `GET /manifest`
60
+
61
+ Add a **Custom** node to a workflow, pick `greet`, and it runs your code.
62
+
63
+ ## The contract
64
+
65
+ The executor POSTs to `/nodes/<slug>`:
66
+
67
+ ```json
68
+ { "node_id": "n1", "config": { "name": "Ada" },
69
+ "input_json": "{\"...\":\"...\"}", "node_outputs": { "prev": "{...}" } }
70
+ ```
71
+
72
+ Your handler `def handler(config, input, node_outputs) -> dict` receives the
73
+ parsed `input` and returns a JSON-serializable dict. The server wraps it as:
74
+
75
+ ```json
76
+ { "output_json": "{\"greeting\":\"Hello, Ada!\"}" }
77
+ ```
78
+
79
+ Downstream nodes reference your output via `{{node_id.field}}`.
80
+
81
+ ## Discovery
82
+
83
+ `GET /manifest` lists every registered node (slug, label, description,
84
+ config schema, endpoint) so it can be registered in Trigix in one step.
85
+
86
+ ## Security
87
+
88
+ Custom nodes run in your own process, isolated from the Trigix core. Run the
89
+ node service on a trusted network; the executor reaches it by URL. (WASM-based
90
+ in-process isolation for untrusted nodes is a planned future option.)
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ tests/test_sdk.py
5
+ trigix_node_sdk/__init__.py
6
+ trigix_node_sdk.egg-info/PKG-INFO
7
+ trigix_node_sdk.egg-info/SOURCES.txt
8
+ trigix_node_sdk.egg-info/dependency_links.txt
9
+ trigix_node_sdk.egg-info/requires.txt
10
+ trigix_node_sdk.egg-info/top_level.txt
@@ -0,0 +1,7 @@
1
+ fastapi>=0.115.0
2
+ pydantic>=2.0.0
3
+ uvicorn[standard]>=0.30.0
4
+
5
+ [test]
6
+ pytest>=8.0.0
7
+ httpx>=0.27.0
@@ -0,0 +1 @@
1
+ trigix_node_sdk