403Webshell
Server IP : 66.29.153.156  /  Your IP : 216.73.216.226
Web Server : LiteSpeed
System : Linux premium322.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User : lastyfjz ( 1521)
PHP Version : 8.1.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/lastyfjz/werepaircomputer.co.uk/wp-content/plugins/extendify/src/Agent/state/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/lastyfjz/werepaircomputer.co.uk/wp-content/plugins/extendify/src/Agent/state/workflows.js
import apiFetch from '@wordpress/api-fetch';
import { deepMerge } from '@shared/lib/utils';
import { create } from 'zustand';
import { persist, devtools } from 'zustand/middleware';
import { workflows } from '@agent/workflows/workflows';

const state = (set, get) => ({
	workflow: null,
	getWorkflow: () => {
		const curr = get().workflow;
		const currentWorkflow = workflows.find((w) => w.id === curr?.id);
		return deepMerge(curr, currentWorkflow || {});
	},
	workflowData: null,
	// This is the history of the results
	// { answerId: '', summary: '', canceled: false,  reason: '', error: false, completed: false, whenFinishedTool: null }[]
	workflowHistory: window.extAgentData?.workflowHistory || [],
	// Data for the tool component that shows up at the end of a workflow
	whenFinishedToolProps: null,
	getWhenFinishedToolProps: () => {
		const { whenFinishedToolProps } = get();
		if (!whenFinishedToolProps) return null;
		return {
			...whenFinishedToolProps,
			onConfirm: (props = {}) => {
				window.dispatchEvent(
					new CustomEvent('extendify-agent:workflow-confirm', {
						detail: { ...props, whenFinishedToolProps },
					}),
				);
			},
			onCancel: () => {
				window.dispatchEvent(
					new CustomEvent('extendify-agent:workflow-cancel', {
						detail: { whenFinishedToolProps },
					}),
				);
			},
		};
	},
	addWorkflowResult: async (data) => {
		set((state) => {
			const max = Math.max(0, state.workflowHistory.length - 10);
			return {
				workflowHistory: [data, ...state.workflowHistory.toSpliced(0, max)],
			};
		});
		// Persist it to the server
		const path = '/extendify/v1/agent/workflows';
		await apiFetch({
			method: 'POST',
			path,
			data: { workflowId: get().workflow.id, ...data },
		});
	},
	mergeWorkflowData: (data) => {
		set((state) => {
			if (!state.workflowData) return { workflowData: data };
			return {
				workflowData: { ...state.workflowData, ...data },
			};
		});
	},
	setWorkflow: (workflow) =>
		set({
			workflow: workflow
				? { ...workflow, startingPage: window.location.href }
				: null,
			workflowData: null,
			whenFinishedToolProps: null,
		}),
	setWhenFinishedToolProps: (whenFinishedToolProps) =>
		set({ whenFinishedToolProps }),
});

export const useWorkflowStore = create()(
	persist(devtools(state, { name: 'Extendify Agent Workflows' }), {
		name: `extendify-agent-workflows-${window.extSharedData.siteId}`,
	}),
);

Youez - 2016 - github.com/yon3zu
LinuXploit