mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-02 03:53:56 +08:00
🎄 Sync 2026-08-30 03:21:07
This commit is contained in:
1 parent
eea38c835c
commit
5093acfe28
30 files changed
+647
-93
No files matched your search
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# Copyright (C) 2008-2014 The LuCI Team <luci@lists.subsignal.org>
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=AgentFlow
|
||||
PKG_VERSION:=1.0.0
|
||||
PKG_RELEASE:=1
|
||||
LUCI_DEPENDS:=+agentflow +luci-compat
|
||||
LUCI_MINIFY_CSS:=0
|
||||
LUCI_MINIFY_JS:=0
|
||||
|
||||
define Package/luci-app-agentflow/conffiles
|
||||
/etc/config/agentflow
|
||||
endef
|
||||
|
||||
define Package/luci-app-agentflow/postrm
|
||||
#!/bin/sh
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
endef
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
@@ -0,0 +1,29 @@
|
||||
local http = require "luci.http"
|
||||
|
||||
module("luci.controller.agentflow", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/agentflow") then
|
||||
return
|
||||
end
|
||||
|
||||
local page = entry({"admin", "services", "agentflow"}, cbi("agentflow"), _("AgentFlow"), 100)
|
||||
page.dependent = true
|
||||
entry({"admin", "services", "agentflow_status"}, call("agentflow_status"))
|
||||
end
|
||||
|
||||
function agentflow_status()
|
||||
local sys = require "luci.sys"
|
||||
local uci = require "luci.model.uci".cursor()
|
||||
local port = tonumber(uci:get_first("agentflow", "agentflow", "port")) or 9000
|
||||
if port < 1 or port > 65535 then
|
||||
port = 9000
|
||||
end
|
||||
|
||||
local status = {
|
||||
running = (sys.call("pidof agentflow >/dev/null") == 0),
|
||||
port = port
|
||||
}
|
||||
http.prepare_content("application/json")
|
||||
http.write_json(status)
|
||||
end
|
||||
@@ -0,0 +1,48 @@
|
||||
local jsonc = require "luci.jsonc"
|
||||
|
||||
local agentflow = {}
|
||||
|
||||
agentflow.blocks = function()
|
||||
local f = io.popen("lsblk -s -f -b -o NAME,FSSIZE,MOUNTPOINT --json", "r")
|
||||
local vals = {}
|
||||
if f then
|
||||
local ret = f:read("*all")
|
||||
f:close()
|
||||
local obj = jsonc.parse(ret)
|
||||
for _, val in pairs(obj and obj["blockdevices"] or {}) do
|
||||
local fsize = val["fssize"]
|
||||
if fsize ~= nil and string.len(fsize) > 10 and val["mountpoint"] then
|
||||
vals[#vals + 1] = val["mountpoint"]
|
||||
end
|
||||
end
|
||||
end
|
||||
return vals
|
||||
end
|
||||
|
||||
agentflow.home = function()
|
||||
local uci = require "luci.model.uci".cursor()
|
||||
local home_dirs = {}
|
||||
home_dirs["main_dir"] = uci:get_first("quickstart", "main", "main_dir", "/root")
|
||||
home_dirs["Configs"] = uci:get_first("quickstart", "main", "conf_dir", home_dirs["main_dir"] .. "/Configs")
|
||||
return home_dirs
|
||||
end
|
||||
|
||||
agentflow.find_paths = function(blocks, home_dirs)
|
||||
local default_path = home_dirs["Configs"] .. "/AgentFlow"
|
||||
local paths = {}
|
||||
|
||||
if #blocks == 0 then
|
||||
table.insert(paths, default_path)
|
||||
else
|
||||
for _, val in pairs(blocks) do
|
||||
table.insert(paths, val .. "/Configs/AgentFlow")
|
||||
end
|
||||
if default_path == "/root/Configs/AgentFlow" then
|
||||
default_path = paths[1]
|
||||
end
|
||||
end
|
||||
|
||||
return paths, default_path
|
||||
end
|
||||
|
||||
return agentflow
|
||||
@@ -0,0 +1,32 @@
|
||||
local m, s
|
||||
|
||||
m = Map("agentflow", translate("AgentFlow"), translate("AgentFlow provides a Web UI for orchestrating coding agents and workflows."))
|
||||
m:section(SimpleSection).template = "agentflow/status"
|
||||
|
||||
s = m:section(TypedSection, "agentflow", translate("Global settings"))
|
||||
s.addremove = false
|
||||
s.anonymous = true
|
||||
|
||||
s:option(Flag, "enabled", translate("Enable")).rmempty = false
|
||||
|
||||
local agentflow_model = require "luci.model.agentflow"
|
||||
local blocks = agentflow_model.blocks()
|
||||
local home = agentflow_model.home()
|
||||
|
||||
local data_dir = s:option(Value, "data_dir", translate("Data directory"))
|
||||
data_dir.rmempty = false
|
||||
data_dir.description = translate("Required. AgentFlow stores its configuration, database and workspace data under this directory.")
|
||||
|
||||
local paths, default_path = agentflow_model.find_paths(blocks, home)
|
||||
for _, val in pairs(paths) do
|
||||
data_dir:value(val, val)
|
||||
end
|
||||
data_dir.default = default_path
|
||||
|
||||
local port = s:option(Value, "port", translate("Listen port"))
|
||||
port.default = "9000"
|
||||
port.rmempty = false
|
||||
port.datatype = "port"
|
||||
port.description = translate("Port for the AgentFlow HTTP server.")
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,20 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(5, '<%=url("admin/services/agentflow_status")%>', null, function(x, st) {
|
||||
var el = document.getElementById('agentflow_status');
|
||||
if (st && el) {
|
||||
if (!st.running) {
|
||||
el.innerHTML = '<br/><em style="color:red"><%:The AgentFlow service is not running.%></em>';
|
||||
} else {
|
||||
el.innerHTML = '<br/><em style="color:green"><%:The AgentFlow service is running.%></em>'
|
||||
+ "<br/><br/><input class=\"btn cbi-button cbi-button-apply\" type=\"button\" value=\" <%:Click to open AgentFlow%> \" onclick=\"window.open('http://" + window.location.hostname + ":" + st.port + "/')\"/>";
|
||||
}
|
||||
}
|
||||
});
|
||||
//]]></script>
|
||||
|
||||
<fieldset class="cbi-section">
|
||||
<legend><%:Status%></legend>
|
||||
<p id="agentflow_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
||||
@@ -0,0 +1,41 @@
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=UTF-8"
|
||||
|
||||
msgid "AgentFlow"
|
||||
msgstr "AgentFlow"
|
||||
|
||||
msgid "AgentFlow provides a Web UI for orchestrating coding agents and workflows."
|
||||
msgstr "AgentFlow 提供用于编排编码智能体和工作流的 Web 管理界面。"
|
||||
|
||||
msgid "Click to open AgentFlow"
|
||||
msgstr "点击打开 AgentFlow"
|
||||
|
||||
msgid "Collecting data..."
|
||||
msgstr "正在获取数据……"
|
||||
|
||||
msgid "Data directory"
|
||||
msgstr "数据目录"
|
||||
|
||||
msgid "Enable"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "Global settings"
|
||||
msgstr "全局设置"
|
||||
|
||||
msgid "Listen port"
|
||||
msgstr "监听端口"
|
||||
|
||||
msgid "Port for the AgentFlow HTTP server."
|
||||
msgstr "AgentFlow HTTP 服务的端口号。"
|
||||
|
||||
msgid "Required. AgentFlow stores its configuration, database and workspace data under this directory."
|
||||
msgstr "必需。AgentFlow 在此目录中保存配置、数据库和工作区数据。"
|
||||
|
||||
msgid "Status"
|
||||
msgstr "状态"
|
||||
|
||||
msgid "The AgentFlow service is not running."
|
||||
msgstr "AgentFlow 服务未运行。"
|
||||
|
||||
msgid "The AgentFlow service is running."
|
||||
msgstr "AgentFlow 服务运行中。"
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
zh-cn
|
||||
Reference in new issue
Block a user