SDK Overview
@thyme-labs/sdk 0.8.0 defines the TypeScript task contract for Thyme Flow. Write a task, use CLI 0.10.0 to run and upload it, then configure an executable through the Console or management API.
A task reads data and returns a decision plus EVM call descriptors. The executable supplies its profile, chain, arguments, secrets, trigger, and gas settings.
import { defineTask, z } from '@thyme-labs/sdk'
export default defineTask({
schema: z.object({ label: z.string().default('monitor') }),
async run(ctx) {
ctx.logger.info(`${ctx.args.label}: execution account ${ctx.account}`)
return { canExec: false, message: 'Monitoring only' }
},
onSkip(ctx, info) {
ctx.logger.info(info.message)
},
})defineTask validates and transforms arguments before entering each handler. For local execution, set SIMULATE_ACCOUNT to a valid EVM address even when the task does not read the chain. See the quickstart.
Authoring exports
All names in this table are exported from @thyme-labs/sdk.
| Export | Purpose |
|---|---|
defineTask, TaskDefinition | Define a schema, async run, and optional outcome callbacks. |
z, InferSchema | Zod 3 with checksummed z.address() and schema output type inference. |
ThymeContext | Execution account, parsed args, public client, logger, secrets, storage. |
TaskResult, SuccessResult, FailResult, Call | Execute or skip decisions and { to, data } call descriptors. |
SuccessPayload, SkipPayload, ErrorPayload, FailPayload | Typed callback payloads. |
Logger, createLogger, LogEntry | Structured logs. |
JsonValue, JsonObject | JSON data accepted by persistent storage. |
Tooling and runtime exports
These exports serve bundlers, upload tools, and runtime integrations. Ordinary tasks use the authoring API above.
| Export | Purpose |
|---|---|
compressTask, decompressTask, CompressResult, DecompressResult | Source/bundle archives with optional permission manifests. |
LifecycleCallbackName, LIFECYCLE_CALLBACK_NAMES, isLifecycleCallbackName, normalizeLifecycleCallbackNames | Shared callback names and metadata filtering. |
extractSchemaFromTask | Extract form metadata from TypeScript source. |
CLOUD_TASK_RUNNER_SOURCE, TASK_RUNTIME_OUTPUT_PREFIXES | Shared Deno wrapper and output markers. |
The package also exposes /archive-reader, /lifecycle, /schema-extractor, and /task-runtime subpaths. See runtime integrations for when to use them.
Next steps
- Define a task and encode calls.
- React to execution outcomes.
- Declare function permissions.
- Upgrade from earlier SDK versions.