PluginProbe
Extendify / 3.1.6
Extendify v3.1.6
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / Agent / workflows / canvas / components / demo-form-tools.js

demo-form-tools.js in Extendify 3.1.6, at src/Agent/workflows/canvas/components/demo-form-tools.js

40 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { activeCanvasStep, useCanvasStore } from '@agent/state/canvas';
2 import { steps } from '@agent/workflows/canvas/components/DemoForm';
3 import { __ } from '@wordpress/i18n';
4
5 // Only the step on screen is live, so the fields it offers change per turn.
6 export const updateDemoForm = {
7 name: 'demo-form/update-fields',
8 label: __('Filling in the form', 'extendify-local'),
9 description:
10 'Fill in the fields of the form step the user is on. Its fields are this tool’s inputs.',
11 get inputSchema() {
12 return activeCanvasStep().inputSchema ?? { type: 'object', properties: {} };
13 },
14 annotations: { readonly: false },
15 execute: (input = {}) => {
16 useCanvasStore.getState().writeValues(input);
17 return { values: useCanvasStore.getState().values };
18 },
19 };
20
21 export const nextDemoFormStep = {
22 name: 'demo-form/next-step',
23 label: __('Moving to the next step', 'extendify-local'),
24 description:
25 'Move the form on to its next step. Run this only when the user has asked to move on in so many words, never because the step looks finished.',
26 inputSchema: { type: 'object', properties: {} },
27 annotations: { readonly: false },
28 execute: () => {
29 const { activeStep, goToStep } = useCanvasStore.getState();
30 if (activeStep >= steps.length - 1) {
31 return {
32 moved: false,
33 reason: 'This is the last step, so the user submits from here.',
34 };
35 }
36 goToStep(activeStep + 1);
37 return { moved: true, step: steps[activeStep + 1].title };
38 },
39 };
40