Skip to content

Project State & Tokens

project_status

project_status is a reactive proxy providing read/write access to the project's shared statuses. Each Status corresponds to a named object whose field values are shared in real time via Redis.

python
# Read a field
current = project_status.pipeline.current_stage

# Write a field (immediately synced to Redis)
project_status.pipeline.current_stage = "embedding"
project_status.metrics.processed_count += 1

Note: Status fields are declared in the TaskFlow UI under Project Statuses. Scripts can only read/write declared fields.


Reactive state (defineStore)

For in-script transient reactive state:

python
from workflow import defineStore, action, getter, field

CartStore = defineStore("cart", {
    "state": lambda: {"items": field(default_factory=list), "total": 0.0},
    "actions": {
        "add_item": action(lambda self, item: (
            self.items.append(item),
            setattr(self, "total", self.total + item["price"]),
        )),
    },
    "getters": {
        "item_count": getter(lambda self: len(self.items)),
    },
})

cart = CartStore()
cart.add_item({"name": "book", "price": 12.99})
print(cart.item_count)  # 1

project_tokens

Read-only dict of tokens configured in Project Settings → Tokens.

python
api_key = project_tokens["openai_key"]
token = project_tokens.get("github_pat", "")

Built with VitePress