Runtime Integrations
The SDK exposes smaller modules for tools that inspect releases or host tasks. Ordinary task code should use defineTask.
Package subpaths
| Import | Exports |
|---|---|
@thyme-labs/sdk/archive-reader | decompressTask, DecompressResult |
@thyme-labs/sdk/lifecycle | Callback names, type guard, metadata filter, LifecycleCallbackName |
@thyme-labs/sdk/schema-extractor | extractSchemaFromTask |
@thyme-labs/sdk/task-runtime | CLOUD_TASK_RUNNER_SOURCE, TASK_RUNTIME_OUTPUT_PREFIXES |
The package is ESM. These subpaths avoid pulling the root module's Node crypto archive writer into an isolate or browser integration.
Source-schema extraction
import { extractSchemaFromTask } from '@thyme-labs/sdk/schema-extractor'
const jsonSchema = extractSchemaFromTask(sourceText)
if (jsonSchema !== null) {
const metadata = JSON.parse(jsonSchema)
// Use metadata to build an argument form.
}Signature: extractSchemaFromTask(taskCode: string): string | null. It returns serialized JSON Schema metadata, not a Zod instance. It scans source without executing the task.
Supported declarations include schema: z.object({ ... }) and a reference to a locally declared const object schema. The scanner handles nested objects, arrays, comments, regex literals, and optional/default chains.
| Zod source | Extracted metadata |
|---|---|
z.string(), z.number(), z.boolean() | Corresponding primitive type. |
z.address() | String with a 40-hex-digit EVM-address pattern. |
z.bigint(), z.coerce.bigint() | Decimal string with an integer pattern. |
z.object, z.array, z.record | Nested properties, array items, or additional-properties schema. |
z.enum, z.literal, z.union, z.tuple | Enum, constant, alternatives, or positional items. |
z.coerce.number() | Number target type. |
.optional(), .default(), .nullish() | Field removed from the required list. |
.default(literal) | Representable default included in metadata. |
Extraction is best effort. It does not model every Zod method, refinement, transform, imported schema, dynamic expression, or computed field. Unknown base types may appear as strings; even a valid empty z.object({}) returns null. The CLI warns when a declared schema cannot be extracted. Runtime validation by defineTask remains authoritative.
Runtime protocol
import {
CLOUD_TASK_RUNNER_SOURCE,
TASK_RUNTIME_OUTPUT_PREFIXES,
} from '@thyme-labs/sdk/task-runtime'CLOUD_TASK_RUNNER_SOURCE is a Deno wrapper string that imports ./task.js. The Flow backend supplies arguments, secrets, account, RPC, and storage, and chooses the run or callback phase.
| Input | Purpose |
|---|---|
TASK_ARGS | JSON arguments, default {}. |
THYME_ACCOUNT | Required valid execution address. |
RPC_URL | Public-client transport. |
THYME_SECRETS_JSON | Injected secret map. |
THYME_STORAGE_INPUT_PATH / THYME_STORAGE_JSON | Storage file takes precedence over inline JSON. |
THYME_STORAGE_OUTPUT_PATH | Write produced storage to a file instead of stdout when supplied. |
THYME_PHASE | run by default, or callback. |
THYME_CALLBACK / THYME_CALLBACK_PAYLOAD | Callback name and JSON payload in callback phase. |
These are host integration inputs, not variables task authors configure in the Console.
| Prefix constant | Value |
|---|---|
namespace | __THYME_ |
log | __THYME_LOG__ |
result | __THYME_RESULT__ |
storage | __THYME_STORAGE__ |
stats | __THYME_STATS__ |
callbacks | __THYME_CALLBACKS__ |
The wrappers use the markers for JSON records on stdout. Not every phase emits every marker; a callback phase produces logs and storage, not a new task result. Hosts must validate results and storage and enforce their own permissions, isolation, size limits, and persistence semantics. Importing the wrapper string does not create a sandbox.