Skip to content
Thyme Docs

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.

functions/monitor/index.ts
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.

ExportPurpose
defineTask, TaskDefinitionDefine a schema, async run, and optional outcome callbacks.
z, InferSchemaZod 3 with checksummed z.address() and schema output type inference.
ThymeContextExecution account, parsed args, public client, logger, secrets, storage.
TaskResult, SuccessResult, FailResult, CallExecute or skip decisions and { to, data } call descriptors.
SuccessPayload, SkipPayload, ErrorPayload, FailPayloadTyped callback payloads.
Logger, createLogger, LogEntryStructured logs.
JsonValue, JsonObjectJSON 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.

ExportPurpose
compressTask, decompressTask, CompressResult, DecompressResultSource/bundle archives with optional permission manifests.
LifecycleCallbackName, LIFECYCLE_CALLBACK_NAMES, isLifecycleCallbackName, normalizeLifecycleCallbackNamesShared callback names and metadata filtering.
extractSchemaFromTaskExtract form metadata from TypeScript source.
CLOUD_TASK_RUNNER_SOURCE, TASK_RUNTIME_OUTPUT_PREFIXESShared 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