• Returns the current workflow's execution context, providing access to the workflow ID, replay state, dimensional coordinates, connection info, and other runtime metadata.

    The context is populated by the worker's wrapWorkflowFunction and stored in AsyncLocalStorage, making it available to any code running within the workflow function's call stack.

    import { Durable } from '@hotmeshio/hotmesh';

    // Access the workflow ID and namespace
    export async function contextAwareWorkflow(): Promise<string> {
    const ctx = Durable.workflow.getContext();
    console.log(`Running workflow ${ctx.workflowId} in ${ctx.namespace}`);
    return ctx.workflowId;
    }
    // Check if the current execution is a replay
    export async function replayAwareWorkflow(): Promise<void> {
    const { counter, workflowDimension } = Durable.workflow.getContext();

    // Use context for logging/debugging
    console.log(`Execution counter: ${counter}, dimension: ${workflowDimension}`);
    }
    // Pass context info to child workflows
    export async function parentWorkflow(): Promise<void> {
    const { workflowId } = Durable.workflow.getContext();

    await Durable.workflow.execChild({
    taskQueue: 'children',
    workflowName: 'childWorkflow',
    args: [workflowId], // pass parent ID to child
    });
    }

    Returns WorkflowContext

    The current workflow context.