Developer docs SDK

Workflow module

Everything the workflow module exposes to your script — tasks, MCP, project status, memories, knowledge, and reactive state. Import from `workflow` (Python) or `@allybuild/sdk` (TypeScript).

Python

The platform materializes two files next to your script: workflow.py — pure bindings built from the SDK — and starter.py, the entry that loads task_script.py and dispatches run / on_change. Import the bindings as plain module-level names:

from workflow import (
    params, reporter, client,
    create_task, wait_task, feedback, flush_tasks,
    list_tasks, get_task, memories, okf,
    mcp, project_status, fetch_statuses,
    TASK_ID, PROJECT_ID, TASK_JWT,
)
NameKindPurpose
paramsdictTASK_PARAMS parsed from JSON
reporterReporterset_phase / set_progress
clientAllyBuildClientPre-configured platform client
create_task / wait_taskTasksApiSpawn and await project tasks
feedbackcallableAnswer a sub-task waiting in pending_approval
flush_taskscallableJoin background on_complete threads before exit
list_tasks / get_taskTasksApiInspect task instances
list_agents / list_workspacesAgentsApiRoster and workspace reads
memoriesMemoriesApiTask-type and per-run memories
list_task_type_memories / get_task_memoriescallableDirect memory reads
okfOkfApiKnowledge-base search and lint
okf_search / okf_lintcallableDirect knowledge-base calls
mcp / mcp_call / async_mcp_callMCPProject MCP tools
project_statusProjectStatusProxyReactive shared project state
fetch_statusescallableFetch every status store in the project
project_tokensdictALLYBUILD_PROJECT_TOKENS parsed from JSON
defineStore / create_reactive / field / getter / actionreactiveDeclare reactive stores and wire the registry
TASK_ID / PROJECT_ID / TASK_JWTstrInjected identifiers
ALLYBUILD_API_URLstrPlatform API base URL, including /api
BG_SERVICE_ID / SERVICE_WORKSPACE_IDstrBackground-service context (service id / bound workspace)

TypeScript

The platform copies two files next to your script: workflow.ts — pure bindings built from the SDK — and starter.ts, the entry that loads task_script.ts and dispatches run / on_change. Import the bindings straight from the package root:

import {
    params, reporter,
    create_task, wait_task, flush_tasks,
    mcp, project_status,
    TASK_ID, PROJECT_ID, TASK_JWT,
} from '@allybuild/sdk'
NameKindPurpose
paramsobjectTASK_PARAMS parsed from JSON
reporterReporterset_phase / set_progress
create_task / wait_taskTasksApiSpawn and await project tasks
flush_taskscallableJoin background on_complete callbacks before exit
mcp / mcp_callMCPProject MCP tools
project_statusProjectStatusProxyReactive shared project state
project_tokensobjectALLYBUILD_PROJECT_TOKENS parsed from JSON (read-only secrets)
defineStore / createReactive / HttpBackendreactiveRe-exported from @allybuild/sdk — declare stores and wire the registry
TASK_ID / PROJECT_ID / TASK_JWTstringInjected identifiers
ALLYBUILD_API_URLstringPlatform API base URL, including /api
BG_SERVICE_ID / SERVICE_WORKSPACE_IDstringSet when the script runs as a background service

Calling conventions

  • Function-based (recommended) — export run(params, reporter); the starter entry calls it and prints the returned dict as the result.
  • Module-level — top-level side effects run at import time; background-service scripts define on_change(mutation, state) instead.