Author TypeScript workflows
The workflow’s authoritative definition is one TypeScript module. The browser offers a source editor, diagnostics, capability review, history, diffs, registry snippets, and a compiler-derived graph. AI agents are the primary authoring interface.
Browser edits remain local until you select Save. Invalid source remains in the editor, and txcast warns before navigation discards unsaved source.
Minimal program
Section titled “Minimal program”import { defineWorkflow, schema } from "@txcast/workflow-sdk"
export default defineWorkflow({ name: "Wait for approval", description: "Ask a member before continuing.", input: schema.object({ amount: schema.uint256() }), output: schema.object({ approvedAmount: schema.uint256() }), capabilities: { effects: ["human.confirm"], networks: [], controlledAccounts: [], transactionTargets: {}, httpHosts: [], notifications: false, }, async run(ctx, input) { const response = await ctx.human.confirm({ key: "approve-amount", title: "Approve the amount", description: `Approve ${input.amount.toString()} units`, audience: "any_seated_member", maxResultBytes: 4_096, })
if (!response.confirmed) throw new Error("Amount was not approved") return { approvedAmount: input.amount } },})Input and output schemas drive the start form and validate values at every trust
boundary. EVM integers arrive as native JavaScript bigint.
Declare authority
Section titled “Declare authority”The capability envelope must cover every effect kind the program can reach:
- EVM networks and controlled accounts;
- transaction targets per chain;
- HTTP host patterns;
- notification channels and audiences.
Prefer exact allowlists. An input-bound account or address should also have a
finite allow list when an agent credential has a restricted account grant.
Validate and save
Section titled “Validate and save”- Validate source for compiler diagnostics and capability errors.
- Review the complete source, capability envelope, and diagnostics.
- Select Save with the latest workflow CAS.
A changed save validates, compiles, prepares the backend artifact, and appends the next immutable revision. The new revision becomes current immediately. Invalid source creates no persisted state. Canonically unchanged source creates no revision.
A version conflict keeps the local source. Read the current workflow, compare the source, and save again only after resolving the conflict. Never overwrite a newer revision without review.
Undo appends the previous source as a new revision. Restore appends any selected historical source as a new revision. Existing runs remain pinned to their selected revisions.
Ownership
Section titled “Ownership”Only the owning seated member can change a workflow. Organisation owners and admins can inspect it but must fork to adapt it. A properly scoped agent acting for the owner may save. A fork creates a new owned workflow with its own valid Version 1. Losing the organisation seat archives the owned workflow without deleting its history or existing runs.