Metadata-Version: 2.4
Name: trigix-node-sdk
Version: 0.1.0
Summary: Write and serve custom Trigix workflow nodes over HTTP.
Author-email: 北京祺智科技有限公司 <managecode@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/bj-qizhi/trigix
Project-URL: Repository, https://github.com/bj-qizhi/trigix
Project-URL: Documentation, https://github.com/bj-qizhi/trigix/tree/master/sdk/python
Keywords: trigix,workflow,automation,nodes,sdk,ai
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastapi>=0.115.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: uvicorn[standard]>=0.30.0
Provides-Extra: test
Requires-Dist: pytest>=8.0.0; extra == "test"
Requires-Dist: httpx>=0.27.0; extra == "test"
Dynamic: license-file

# Trigix Node SDK (Python)

Write a custom Trigix workflow node as a Python function and serve it over HTTP.
No changes to the Trigix executor are required — the executor calls your node
like any other.

## Quick start

```bash
pip install trigix-node-sdk
# or from this repo: pip install -e sdk/python
uvicorn examples.greeter:app --port 9000
```

```python
from trigix_node_sdk import node, create_app

@node(slug="greet", label="Greeter",
      config_schema={"type": "object",
                     "properties": {"name": {"type": "string"}}})
def greet(config, input, node_outputs):
    name = config.get("name") or input.get("name", "world")
    return {"greeting": f"Hello, {name}!"}

app = create_app()
```

Then in Trigix → **Custom Nodes**, register:
- **slug**: `greet`
- **endpoint**: `http://your-host:9000/nodes/greet`
- **config schema**: copy from `GET /manifest`

Add a **Custom** node to a workflow, pick `greet`, and it runs your code.

## The contract

The executor POSTs to `/nodes/<slug>`:

```json
{ "node_id": "n1", "config": { "name": "Ada" },
  "input_json": "{\"...\":\"...\"}", "node_outputs": { "prev": "{...}" } }
```

Your handler `def handler(config, input, node_outputs) -> dict` receives the
parsed `input` and returns a JSON-serializable dict. The server wraps it as:

```json
{ "output_json": "{\"greeting\":\"Hello, Ada!\"}" }
```

Downstream nodes reference your output via `{{node_id.field}}`.

## Discovery

`GET /manifest` lists every registered node (slug, label, description,
config schema, endpoint) so it can be registered in Trigix in one step.

## Security

Custom nodes run in your own process, isolated from the Trigix core. Run the
node service on a trusted network; the executor reaches it by URL. (WASM-based
in-process isolation for untrusted nodes is a planned future option.)
