Appearance
Function: plan()
ts
function plan(config: PlanConfig): ChatPlanReturn;Defined in: packages/sdk/src/renderer/templates/plan.ts:84
Propose an editable, runnable plan from a tool's run. The user can edit each step's text, add/remove rows, then press Run — which executes the step functions (in order) and appends the finished plan.
Steps map to the edited rows by position: editing a row's text passes the new text to that step's run; removing trailing rows skips those steps. (Rows added in the UI beyond the defined steps are shown but have no action.)
Parameters
| Parameter | Type |
|---|---|
config | PlanConfig |
Returns
ChatPlanReturn
Example
ts
import {tool, plan, step, reply, agent} from '@matterway/sdk/UI';
import {z} from 'zod';
const refactor = tool({
description: 'Plan and run a refactor',
input: z.object({goal: z.string()}),
run: async ({goal}) => plan({
title: `Refactor: ${goal}`,
steps: [
step('Locate the slow path', async () => agent(ctx, {prompt: '…'})), // non-deterministic
step('Extract the function', async () => reply('Extracted walkTree().')),
],
}),
});