Files
openfang/crates/openfang-api/static/js/pages/workflows.js
jaberjaber23 5692c96494 Initial commit — OpenFang Agent Operating System
Open-source Agent OS built in Rust.

- 14 crates, 1,767+ tests, zero clippy warnings
- 7 autonomous Hands (Clip, Lead, Collector, Predictor, Researcher, Twitter, Browser)
- 16 security systems (WASM sandbox, Merkle audit trail, taint tracking, Ed25519 signing, SSRF protection, secret zeroization, HMAC-SHA256 mutual auth, and more)
- 30 pre-built agents across 4 performance tiers
- 40 channel adapters (Telegram, Discord, Slack, WhatsApp, Teams, and 35 more)
- 38 built-in tools + MCP client/server + A2A protocol
- 26 LLM providers with intelligent routing and cost tracking
- 60+ bundled skills with FangHub marketplace
- Tauri 2.0 native desktop app
- 140+ REST/WS/SSE API endpoints with Alpine.js dashboard
- OpenAI-compatible /v1/chat/completions endpoint
- One-command install, production-ready
2026-02-26 01:00:27 +03:00

80 lines
2.5 KiB
JavaScript

// OpenFang Workflows Page — Workflow builder + run history
'use strict';
function workflowsPage() {
return {
// -- Workflows state --
workflows: [],
showCreateModal: false,
runModal: null,
runInput: '',
runResult: '',
running: false,
loading: true,
loadError: '',
newWf: { name: '', description: '', steps: [{ name: '', agent_name: '', mode: 'sequential', prompt: '{{input}}' }] },
// -- Workflows methods --
async loadWorkflows() {
this.loading = true;
this.loadError = '';
try {
this.workflows = await OpenFangAPI.get('/api/workflows');
} catch(e) {
this.workflows = [];
this.loadError = e.message || 'Could not load workflows.';
}
this.loading = false;
},
async loadData() { return this.loadWorkflows(); },
async createWorkflow() {
var steps = this.newWf.steps.map(function(s) {
return { name: s.name || 'step', agent_name: s.agent_name, mode: s.mode, prompt: s.prompt || '{{input}}' };
});
try {
var wfName = this.newWf.name;
await OpenFangAPI.post('/api/workflows', { name: wfName, description: this.newWf.description, steps: steps });
this.showCreateModal = false;
this.newWf = { name: '', description: '', steps: [{ name: '', agent_name: '', mode: 'sequential', prompt: '{{input}}' }] };
OpenFangToast.success('Workflow "' + wfName + '" created');
await this.loadWorkflows();
} catch(e) {
OpenFangToast.error('Failed to create workflow: ' + e.message);
}
},
showRunModal(wf) {
this.runModal = wf;
this.runInput = '';
this.runResult = '';
},
async executeWorkflow() {
if (!this.runModal) return;
this.running = true;
this.runResult = '';
try {
var res = await OpenFangAPI.post('/api/workflows/' + this.runModal.id + '/run', { input: this.runInput });
this.runResult = res.output || JSON.stringify(res, null, 2);
OpenFangToast.success('Workflow completed');
} catch(e) {
this.runResult = 'Error: ' + e.message;
OpenFangToast.error('Workflow failed: ' + e.message);
}
this.running = false;
},
async viewRuns(wf) {
try {
var runs = await OpenFangAPI.get('/api/workflows/' + wf.id + '/runs');
this.runResult = JSON.stringify(runs, null, 2);
this.runModal = wf;
} catch(e) {
OpenFangToast.error('Failed to load run history: ' + e.message);
}
}
};
}