Skip to content

Export resolveTemplate from @workflowbuilder/temporal #281

Open

Description

@levyshachar2LR

Problem

The SDK's VariableText / VariableTextArea picker stores references as {{nodes.<id>.<path>}}, and the reference worker resolves them at run time with resolveTemplate. A consumer of the published packages has no way to call that resolver.

execution-core is private and isn't published. @workflowbuilder/temporal bundles it, but packages/temporal/src/core-contract.ts re-exports only the error classes, classifyNodeError, resolveExecutor and some types. resolveTemplate isn't among them, so the build drops it.

Use case

We run Workflow Builder diagrams on Temporal through @workflowbuilder/temporal, with our worker inside our own backend rather than inside this monorepo, so we can't import @workflow-builder/execution-core the way apps/execution-worker does. We register many custom node types, and we resolve each node's whole config against the ExecutionContext in one place before calling its executor. Any consumer outside this repo that uses the variable picker needs the same resolver at runtime.

Proposal

Add resolveTemplate to the re-exports in packages/temporal/src/core-contract.ts and export it from packages/temporal/src/index.ts:

import { resolveTemplate } from '@workflowbuilder/temporal';

const prompt = resolveTemplate(node.config.systemPrompt, context);

It has no side effects and doesn't touch Temporal, so it's safe in the activity entry point. Its failures are already PermanentNodeExecutionError (template_malformed, template_unresolved), which matches how executors are expected to report errors.

Workarounds considered

  1. Copy resolve-template.ts into our code. This is what we do for now, but our copy drifts from the picker's syntax every time it changes upstream (namespaces, ?, default:, error codes).
  2. Install @workflow-builder/execution-core from git. Not workable: the package is private, its exports point at raw .ts source, and it depends on @workflow-builder/types as workspace:*, which isn't on npm.

Nice to have

  • A helper that resolves every string inside a config object (objects and arrays), so executors don't each write their own loop.
  • A smaller point: getNestedValue uses a plain property lookup, so a path like {{nodes.x.constructor}} reaches inherited properties of the object instead of failing as unresolved. Checking each step with Object.hasOwn would close that.

Environment

  • @workflowbuilder/temporal 0.3.0 and 0.3.1 (latest on npm): neither exports resolveTemplate
  • @workflowbuilder/sdk 3.0.0

Happy to open a PR if this direction works for you.

Activity

  1. piotrblaszczyk commented on Nov 23, 2026

    @piotrblaszczyk
    Contributor

    Thanks for the report. Everything in it checks out, and the direction works for us. A PR is welcome.

    You are right about the gap. Our own reference worker imports resolveTemplate from the private core package, so a consumer of the published package cannot do what our worker does.

    Scope for the PR

    Required

    1. Re-export resolveTemplate in packages/temporal/src/core-contract.ts and export it from packages/temporal/src/index.ts. Root entry only, not /workflow.

    2. Add the name to the pinned list in packages/temporal/test/api-surface.test.ts. That test fails on purpose until the list is updated.

    3. Add a short section to packages/temporal/README.md, next to "Failures and retries". Show the call and name the two error codes (template_malformed, template_unresolved).

    4. Add a changeset file, for example .changeset/export-resolve-template.md:

      ---
      '@workflowbuilder/temporal': minor
      ---
      
      `resolveTemplate` is now exported, so executors outside this repository can resolve `{{namespace.path}}` references the same way the reference worker does.

    Welcome in the same PR, as a separate commit

    The Object.hasOwn check in getNestedValue. Good catch. Please add tests in packages/execution-core/src/templates/resolve-template.test.ts for constructor, toString and __proto__. Array indices and length should keep resolving. If you include it, mention it in the changeset, because it changes execution behaviour.

    Not in this PR

    The helper that resolves a whole config object. It needs an API decision on our side first: non-string values, object keys, and how a failure names the field it came from. A separate issue for it is fine.

    One note on the grammar

    Please document only the form the variable picker stores: {{namespace.path}} with no whitespace inside the braces, plus the ? and | default:'…' modifiers. The parser on main also tolerates whitespace inside the braces. #76 removes that tolerance, so we do not want to promise it.

    Practical

    • Commits and the PR title follow Conventional Commits. A hook rejects anything else. Example: feat(temporal): export resolveTemplate.
    • pnpm check and pnpm test should pass before you open the PR.
    • Target branch is main.
  2. levyshachar2LR commented on Nov 23, 2026

    @levyshachar2LR
    Author

    @piotrblaszczyk thanks for the reply. if you accept LLM assisted PR then sure, #286

  3. piotrblaszczyk commented on Nov 24, 2026

    @piotrblaszczyk
    Contributor

    Thanks for the PR. Yes, we accept LLM-assisted contributions.

    It looks very good, so I don't expect any problems. We will close #76 first and merge this one right after.

    We will let you know here when the new version of the package is out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions