Skip to main content

Core API Overview

The Core API section documents the workflow.* runtime API available directly to business workflows. Its boundary is src/runtime-api.ts in the Core repository: local hosts and CLI inject these methods into globalThis.workflow, so a business workflow does not import them from "steamharness".

Entry boundary​

EntranceDescription
workflow.*Global API used by business workflows, sourced from src/runtime-api.ts in the Core repository.
steamharness package entryUtility entry used by CLI, Server, tests, and advanced hosts, sourced from src/index.ts in the Core repository.

Runtime API index​

APIDescription
defineProjectDefines a workflow and its main execution function.
defineEntrypointDefines an independently runnable Workflow entrypoint, including its parameters, tools, and registry.
defineExecutorDefines a Workflow project's entrypoints or a Conversation project's single execution configuration.
parseConversationDefaultInputArgsParses the serialized --message, --images, and --files values from the default conversation input.
createInputNodeCreates an input-parsing node.
createFileInputNodeCreates a file-input node and resolves a file parameter reference to a file object.
createUserInputNodeCreate a human input node that can be persisted, pausing workflow to waiting_for_input.
createToolApprovalGateCreate tool approval wrappers; combine executor tools registry entries and context.toolPermissions reuse user-input to wait for/resume protocol approval tool calls.
createLLMNodeCreate a non-streaming LLM call node.
createLLMStreamNodeCreate a streaming LLM call node.
createLLMProviderFromConfigCreate an LLM provider from the current project configuration snapshot.
createLLMProviderRefCreates a provider reference that can be deferred resolved.
createOutputNodeCreating a synchronous or streaming output node;createOutputItem, createOutputPayload, addOutputItem, and createOutputItemChunk are also described on this page.
createDetailsOutputNodeA convenient output node for creating independent, foldable output items.
createTimerNode / endTimerCreate a business timing node and write a timing card at the explicit end or workflow end.
createQuestionClassifierNodeCreate a problem classification node based on LLM.
runNodeExecute the normal node and trigger the node to execute the hook.
runStreamNodeExecute the streaming node, collect chunks, and produce finalize results.
runIfExecute the if / else-if / else branch and write the branch selection to the run report and Diagram.
runForExecute a traceable for loop and let Diagram display the loop body with the loop container.
runWhileExecute the traceable while loop and let Diagram display the loop body with the loop container.
runProjectCall another workflow in the current context, multiplexing KV, session, provider, token usage, and trace.
Knowledge DocumentsManage project Markdown Knowledge documents through an explicit local or server storage context.
getConfigRead a native JSON configuration value from the current run snapshot.
getRuntimePlatform / isCli / isDesktopDetermine whether the execution host for the current workflow is CLI or a local desktop host.
getRuntimeLocaleReads the Simplified Chinese or English language selected by the current host for localized visible output.
getLLMProviderResolves LLM provider by context, node name, and provider source.
HarnessErrorStandard workflow error type.

Core Run Object​

Most API runs around input, context, node, and payload.

ObjectTypeDescription
inputInput or node OutputThe input data for the current workflow or node.
contextRunContext / NodeContextContains provider, storage, conversation, files, metadata, hooks, and abortSignal.
payloadRunPayload subtypeNode payload should inherit RunPayload, errCode: 0, errMessage: "" on success.
providerLLMProviderSource / LLMProviderThe LLM node parses the actual provider by provider source.

NodeContext Core Fields​

FieldTypeDescription
configConfigurationValuesImmutable configuration values for this run.
providersProviderRegistryLLM provider the registry and binding tables.
storageStorageContextExplicit local and server locations, each with three-scope kv and persistentValue. The project dataStorage.mode strictly limits accessible locations. Core 0.2 no longer provides top-level context.kv or context.persistentValue.
conversationConversationContextSession state read/write entry. setTitle can safely suggest UI title; other reads and writes will throw errors when the session is not enabled.
tokenUsageTokenUsageContextToken-usage reporting context. When disabled, report() is a no-op; when enabled, it writes KV, run reports, and runtime events.
userInputUserInputContext | undefinedWait/resume entry for user input and tool approval. Local hosts will be injected according to the host capacity.
filesFileStore | undefinedFile reference resolution entry;createFile generates a server-backed run file.
metadataobject | undefinedCurrent execution meta information, such as workflow, runId, conversationId;Workflow run also contains entrypointId and entrypointTitle.
nodeHooksNodeExecutionHooks | undefinedNode start, chunk, complete, and other event callbacks.
timersTimerContext | undefinedBusiness timing node context;createTimerNode start timing,endTimer end timing.
toolPermissionsToolPermissionContext | undefinedThe tool permission context for the current run. Parses by executor tools default and host override values for createToolApprovalGate() or custom tool call logic to determine enablement, automatic approval, and manual approval.
abortSignalAbortSignal | undefinedInterrupt execution and provider calls.

Payload Constraint​

FieldDescription
errCodeBusiness error code. The success value is 0.
errMessageThe error description. Uniform empty string on success.