Skip to content

step-location

Step-location markers.

Skill authors can tag a 'use step' function with cloud(fn) or local(fn) to declare where it should execute when the skill runs in cloud-workflow mode. Default (unwrapped) is local — the step runs on the assistant.

The wrapper does two things at runtime when the bundle loads:

  1. Stamps the function with a Symbol so a direct fn reference reveals the location.
  2. Records the function's name in a global registry. The cloud step dispatcher reads this registry to decide whether to run a step in- process (cloud) or forward to the assistant via the event-bus (local).

Both sides (cloud and assistant) load the same steps.js bundle, so both have the same registry populated and disagree only on which side actually invokes the step body.

Example

ts
import {cloud, local} from '@matterway/sdk';

// default → local
export async function showMessage(ctx) {
  'use step';
  await message(ctx, { ... });
}

// explicit cloud
export const fetchUser = cloud(async function fetchUser(id) {
  'use step';
  return await fetch(`/api/users/${id}`).then(r => r.json());
});

Functions

Matterway Assistant SDK Documentation