mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-01 16:44:23 +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,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
|
||||
Reference in new issue
Block a user