init
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// Copyright (C) 2024 veypi <i@veypi.com>
|
||||
// 2025-02-27 19:32:09
|
||||
// Distributed under terms of the MIT license.
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"app/cfg"
|
||||
|
||||
"github.com/veypi/utils/flags"
|
||||
"github.com/veypi/utils/logv"
|
||||
)
|
||||
|
||||
var CMD = flags.New("app", "the backend server of app")
|
||||
var CfgDump = CMD.SubCommand("cfg", "generate cfg file")
|
||||
|
||||
var configFile = CMD.String("f", "./dev.yaml", "the config file")
|
||||
|
||||
func init() {
|
||||
CMD.StringVar(&cfg.Config.Host, "host", "0.0.0.0", "host")
|
||||
CMD.IntVar(&cfg.Config.Port, "p", 4000, "port")
|
||||
CMD.StringVar(&cfg.Config.LoggerLevel, "l", "info", "log level")
|
||||
CMD.StringVar(&cfg.Config.DSN, "dsn", "root:123456@tcp(127.0.0.1:3306)/test?charset=utf8&parseTime=True&loc=Local", "data source name")
|
||||
CMD.StringVar(&cfg.Config.DB, "db", "mysql", "data source type: mysql/postgre/sqlite")
|
||||
CMD.Before = func() error {
|
||||
flags.LoadCfg(*configFile, cfg.Config)
|
||||
CMD.Parse()
|
||||
logv.SetLevel(logv.AssertFuncErr(logv.ParseLevel(cfg.Config.LoggerLevel)))
|
||||
return nil
|
||||
}
|
||||
CfgDump.Command = func() error {
|
||||
flags.DumpCfg(*configFile, cfg.Config)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// cfg.go
|
||||
// Copyright (C) 2024 veypi <i@veypi.com>
|
||||
// 2025-02-27 19:32:09
|
||||
// Distributed under terms of the MIT license.
|
||||
//
|
||||
|
||||
package cfg
|
||||
|
||||
type config struct {
|
||||
Host string `json:"host"`
|
||||
Port int `json:"port"`
|
||||
LoggerPath string `json:"logger_path,omitempty"`
|
||||
LoggerLevel string `json:"logger_level,omitempty"`
|
||||
DSN string `json:"dsn"`
|
||||
DB string `json:"db"`
|
||||
}
|
||||
|
||||
var Config = &config{
|
||||
Host: "0.0.0.0",
|
||||
Port: 5002,
|
||||
LoggerPath: "",
|
||||
LoggerLevel: "debug",
|
||||
DSN: "dev:20240309@tcp(127.0.0.1:3306)/testb?charset=utf8&parseTime=True&loc=Local",
|
||||
DB: "mysql",
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// db.go
|
||||
// Copyright (C) 2024 veypi <i@veypi.com>
|
||||
// 2025-02-27 19:32:09
|
||||
// Distributed under terms of the MIT license.
|
||||
//
|
||||
|
||||
package cfg
|
||||
|
||||
import (
|
||||
"github.com/glebarez/sqlite"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/logger"
|
||||
)
|
||||
|
||||
var db *gorm.DB
|
||||
var ObjList = make([]any, 0, 10)
|
||||
|
||||
func DB() *gorm.DB {
|
||||
if db == nil {
|
||||
var err error
|
||||
var conn gorm.Dialector
|
||||
if Config.DB == "mysql" {
|
||||
conn = mysql.Open(Config.DSN)
|
||||
} else if Config.DB == "postgres" {
|
||||
conn = postgres.Open(Config.DSN)
|
||||
} else {
|
||||
conn = sqlite.Open(Config.DSN)
|
||||
}
|
||||
db, err = gorm.Open(conn,
|
||||
&gorm.Config{
|
||||
Logger: logger.Default.LogMode(logger.Silent),
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
return db
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
restconf:
|
||||
host: 0.0.0.0
|
||||
port: 5000
|
||||
loggerpath: ""
|
||||
loggerlevel: debug
|
||||
prettylog: false
|
||||
timeformat: ""
|
||||
postmaxmemory: 0
|
||||
tlscfg: null
|
||||
maxconnections: 0
|
||||
dsn: dev:20240309@tcp(127.0.0.1:3306)/testb?charset=utf8&parseTime=True&loc=Local
|
||||
repo: /Users/zpc01/workspace/v/test_front/
|
||||
dev: true
|
||||
@@ -0,0 +1,707 @@
|
||||
{
|
||||
"demand": {
|
||||
"name": "需求节点",
|
||||
"category": "demand",
|
||||
"color": "#1890ff",
|
||||
"icon": "demand-icon",
|
||||
"icon_path": "/assets/icons/demand.svg",
|
||||
"shape": "rect",
|
||||
"width": 180,
|
||||
"height": 50,
|
||||
"ports": [
|
||||
"top",
|
||||
"right",
|
||||
"bottom",
|
||||
"left"
|
||||
],
|
||||
"metaFields": [
|
||||
{
|
||||
"name": "description",
|
||||
"type": "string",
|
||||
"label": "描述"
|
||||
},
|
||||
{
|
||||
"name": "priority",
|
||||
"type": "select",
|
||||
"label": "优先级",
|
||||
"options": [
|
||||
"高",
|
||||
"中",
|
||||
"低"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"start": {
|
||||
"name": "开始",
|
||||
"category": "logic",
|
||||
"color": "#722ed1",
|
||||
"icon": "play-circle",
|
||||
"shape": "circle",
|
||||
"width": 60,
|
||||
"height": 60,
|
||||
"ports": [
|
||||
"right",
|
||||
"bottom",
|
||||
"top",
|
||||
"left"
|
||||
],
|
||||
"metaFields": [
|
||||
{
|
||||
"name": "description",
|
||||
"type": "string",
|
||||
"label": "描述"
|
||||
}
|
||||
]
|
||||
},
|
||||
"end": {
|
||||
"name": "结束",
|
||||
"category": "logic",
|
||||
"color": "#722ed1",
|
||||
"icon": "stop-circle",
|
||||
"shape": "circle",
|
||||
"width": 60,
|
||||
"height": 60,
|
||||
"ports": [
|
||||
"left",
|
||||
"top",
|
||||
"right",
|
||||
"bottom"
|
||||
],
|
||||
"metaFields": [
|
||||
{
|
||||
"name": "description",
|
||||
"type": "string",
|
||||
"label": "描述"
|
||||
}
|
||||
]
|
||||
},
|
||||
"condition": {
|
||||
"name": "条件",
|
||||
"category": "logic",
|
||||
"color": "#fa8c16",
|
||||
"icon": "question-circle",
|
||||
"shape": "diamond",
|
||||
"width": 80,
|
||||
"height": 80,
|
||||
"ports": [
|
||||
"top",
|
||||
"right",
|
||||
"bottom",
|
||||
"left"
|
||||
],
|
||||
"metaFields": [
|
||||
{
|
||||
"name": "condition",
|
||||
"type": "code",
|
||||
"label": "条件表达式"
|
||||
}
|
||||
]
|
||||
},
|
||||
"and": {
|
||||
"name": "AND",
|
||||
"category": "logic",
|
||||
"color": "#722ed1",
|
||||
"icon": "and-icon",
|
||||
"shape": "diamond",
|
||||
"width": 80,
|
||||
"height": 80,
|
||||
"ports": [
|
||||
"top",
|
||||
"right",
|
||||
"bottom",
|
||||
"left"
|
||||
],
|
||||
"metaFields": [
|
||||
{
|
||||
"name": "operation",
|
||||
"type": "hidden",
|
||||
"defaultValue": "AND"
|
||||
}
|
||||
]
|
||||
},
|
||||
"or": {
|
||||
"name": "OR",
|
||||
"category": "logic",
|
||||
"color": "#eb2f96",
|
||||
"icon": "or-icon",
|
||||
"shape": "diamond",
|
||||
"width": 80,
|
||||
"height": 80,
|
||||
"ports": [
|
||||
"top",
|
||||
"right",
|
||||
"bottom",
|
||||
"left"
|
||||
],
|
||||
"metaFields": [
|
||||
{
|
||||
"name": "operation",
|
||||
"type": "hidden",
|
||||
"defaultValue": "OR"
|
||||
}
|
||||
]
|
||||
},
|
||||
"httpRequest": {
|
||||
"name": "HTTP验证",
|
||||
"category": "request",
|
||||
"color": "#52c41a",
|
||||
"icon": "api",
|
||||
"icon_path": "/assets/icons/httpFlow.svg",
|
||||
"shape": "rect",
|
||||
"width": 150,
|
||||
"height": 50,
|
||||
"ports": [
|
||||
"top",
|
||||
"right",
|
||||
"bottom",
|
||||
"left"
|
||||
],
|
||||
"metaFields": [
|
||||
{
|
||||
"name": "method",
|
||||
"type": "select",
|
||||
"label": "请求方法",
|
||||
"options": [
|
||||
"GET",
|
||||
"POST",
|
||||
"PUT",
|
||||
"DELETE",
|
||||
"PATCH"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"type": "string",
|
||||
"label": "请求路径"
|
||||
},
|
||||
{
|
||||
"name": "params",
|
||||
"type": "json",
|
||||
"label": "查询参数",
|
||||
"defaultValue": "{}"
|
||||
},
|
||||
{
|
||||
"name": "headers",
|
||||
"type": "json",
|
||||
"label": "请求头",
|
||||
"defaultValue": "{\"Content-Type\": \"application/json\"}"
|
||||
},
|
||||
{
|
||||
"name": "body",
|
||||
"type": "json",
|
||||
"label": "请求体",
|
||||
"defaultValue": "{\"type\": \"json\", \"content\": \"{}\"}"
|
||||
},
|
||||
{
|
||||
"name": "response",
|
||||
"type": "hidden",
|
||||
"defaultValue": null
|
||||
},
|
||||
{
|
||||
"name": "endpointId",
|
||||
"type": "hidden",
|
||||
"defaultValue": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
"loadTestHttpRequest": {
|
||||
"name": "HTTP 负载测试",
|
||||
"category": "perform",
|
||||
"color": "#722ed1",
|
||||
"icon_path": "/assets/icons/load-test.svg",
|
||||
"shape": "rect",
|
||||
"width": 180,
|
||||
"height": 50,
|
||||
"ports": [
|
||||
"top",
|
||||
"right",
|
||||
"bottom",
|
||||
"left"
|
||||
],
|
||||
"metaFields": [
|
||||
{
|
||||
"name": "endpointId",
|
||||
"type": "hidden",
|
||||
"defaultValue": ""
|
||||
},
|
||||
{
|
||||
"name": "method",
|
||||
"type": "select",
|
||||
"label": "请求方法",
|
||||
"options": [
|
||||
"GET",
|
||||
"POST",
|
||||
"PUT",
|
||||
"DELETE",
|
||||
"PATCH"
|
||||
],
|
||||
"defaultValue": "GET"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"type": "string",
|
||||
"label": "请求路径"
|
||||
},
|
||||
{
|
||||
"name": "params",
|
||||
"type": "json",
|
||||
"label": "查询参数",
|
||||
"defaultValue": "{}"
|
||||
},
|
||||
{
|
||||
"name": "headers",
|
||||
"type": "json",
|
||||
"label": "请求头",
|
||||
"defaultValue": "{\"Content-Type\": \"application/json\"}"
|
||||
},
|
||||
{
|
||||
"name": "body",
|
||||
"type": "json",
|
||||
"label": "请求体",
|
||||
"defaultValue": "{\"type\": \"json\", \"content\": \"{}\"}"
|
||||
},
|
||||
{
|
||||
"name": "concurrentUsers",
|
||||
"type": "number",
|
||||
"label": "并发用户数",
|
||||
"defaultValue": 10
|
||||
},
|
||||
{
|
||||
"name": "testDurationSec",
|
||||
"type": "number",
|
||||
"label": "测试时长(秒)",
|
||||
"defaultValue": 30
|
||||
},
|
||||
{
|
||||
"name": "rampUpTimeSec",
|
||||
"type": "number",
|
||||
"label": "启动时长(秒)",
|
||||
"defaultValue": 0,
|
||||
"optional": true
|
||||
},
|
||||
{
|
||||
"name": "resultsSummary",
|
||||
"type": "textarea",
|
||||
"label": "测试结果摘要",
|
||||
"readonly": true,
|
||||
"rows": 4
|
||||
},
|
||||
{
|
||||
"name": "detailedResults",
|
||||
"type": "hidden",
|
||||
"defaultValue": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"httpLatencyTest": {
|
||||
"name": "HTTP 延迟测试",
|
||||
"category": "perform",
|
||||
"color": "#b37feb",
|
||||
"icon_path": "/assets/icons/latency.svg",
|
||||
"shape": "rect",
|
||||
"width": 180,
|
||||
"height": 50,
|
||||
"ports": [
|
||||
"top",
|
||||
"right",
|
||||
"bottom",
|
||||
"left"
|
||||
],
|
||||
"metaFields": [
|
||||
{
|
||||
"name": "endpointId",
|
||||
"type": "hidden",
|
||||
"defaultValue": ""
|
||||
},
|
||||
{
|
||||
"name": "method",
|
||||
"type": "select",
|
||||
"label": "请求方法",
|
||||
"options": [
|
||||
"GET",
|
||||
"POST",
|
||||
"PUT",
|
||||
"DELETE",
|
||||
"PATCH"
|
||||
],
|
||||
"defaultValue": "GET"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"type": "string",
|
||||
"label": "请求路径"
|
||||
},
|
||||
{
|
||||
"name": "params",
|
||||
"type": "json",
|
||||
"label": "查询参数",
|
||||
"defaultValue": "{}"
|
||||
},
|
||||
{
|
||||
"name": "headers",
|
||||
"type": "json",
|
||||
"label": "请求头",
|
||||
"defaultValue": "{\"Content-Type\": \"application/json\"}"
|
||||
},
|
||||
{
|
||||
"name": "body",
|
||||
"type": "json",
|
||||
"label": "请求体",
|
||||
"defaultValue": "{\"type\": \"json\", \"content\": \"{}\"}"
|
||||
},
|
||||
{
|
||||
"name": "iterations",
|
||||
"type": "number",
|
||||
"label": "迭代次数",
|
||||
"defaultValue": 10,
|
||||
"description": "连续发送请求的次数"
|
||||
},
|
||||
{
|
||||
"name": "delayBetweenMs",
|
||||
"type": "number",
|
||||
"label": "迭代间隔(ms)",
|
||||
"defaultValue": 0,
|
||||
"optional": true,
|
||||
"description": "每次请求之间的等待时间"
|
||||
},
|
||||
{
|
||||
"name": "latencyStats",
|
||||
"type": "textarea",
|
||||
"label": "延迟统计",
|
||||
"readonly": true,
|
||||
"rows": 4,
|
||||
"description": "例如: Min, Max, Avg, P95, P99, Errors"
|
||||
},
|
||||
{
|
||||
"name": "detailedLatencies",
|
||||
"type": "hidden",
|
||||
"defaultValue": null
|
||||
}
|
||||
]
|
||||
},
|
||||
"securityScanTrigger": {
|
||||
"name": "安全扫描",
|
||||
"category": "safety",
|
||||
"color": "#f5222d",
|
||||
"icon_path": "/assets/icons/safety.svg",
|
||||
"shape": "rect",
|
||||
"width": 180,
|
||||
"height": 50,
|
||||
"ports": [
|
||||
"top",
|
||||
"right",
|
||||
"bottom",
|
||||
"left"
|
||||
],
|
||||
"metaFields": [
|
||||
{
|
||||
"name": "scanTarget",
|
||||
"type": "string",
|
||||
"label": "扫描目标",
|
||||
"description": "例如 URL, IP, 服务名"
|
||||
},
|
||||
{
|
||||
"name": "scanProfile",
|
||||
"type": "select",
|
||||
"label": "扫描配置/策略",
|
||||
"options": [
|
||||
"快速扫描",
|
||||
"全面扫描",
|
||||
"OWASP Top10"
|
||||
],
|
||||
"defaultValue": "快速扫描"
|
||||
},
|
||||
{
|
||||
"name": "apiKeyRef",
|
||||
"type": "string",
|
||||
"label": "扫描工具API密钥引用",
|
||||
"optional": true,
|
||||
"description": "引用环境变量或配置"
|
||||
},
|
||||
{
|
||||
"name": "waitForResult",
|
||||
"type": "boolean",
|
||||
"label": "等待扫描结果",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"name": "scanId",
|
||||
"type": "string",
|
||||
"label": "扫描任务ID",
|
||||
"readonly": true
|
||||
},
|
||||
{
|
||||
"name": "scanStatus",
|
||||
"type": "string",
|
||||
"label": "扫描状态",
|
||||
"readonly": true
|
||||
},
|
||||
{
|
||||
"name": "scanResultSummary",
|
||||
"type": "textarea",
|
||||
"label": "扫描结果摘要",
|
||||
"readonly": true,
|
||||
"rows": 3
|
||||
},
|
||||
{
|
||||
"name": "detailedScanResult",
|
||||
"type": "hidden"
|
||||
}
|
||||
]
|
||||
},
|
||||
"authCheck": {
|
||||
"name": "认证授权检查",
|
||||
"category": "safety",
|
||||
"color": "#faad14",
|
||||
"icon_path": "/assets/icons/auth-check.svg",
|
||||
"shape": "rect",
|
||||
"width": 170,
|
||||
"height": 50,
|
||||
"ports": [
|
||||
"top",
|
||||
"right",
|
||||
"bottom",
|
||||
"left"
|
||||
],
|
||||
"metaFields": [
|
||||
{
|
||||
"name": "endpointInfo",
|
||||
"type": "json",
|
||||
"label": "目标接口信息",
|
||||
"defaultValue": "{\"method\":\"GET\", \"path\":\"/api/resource\"}"
|
||||
},
|
||||
{
|
||||
"name": "credentials",
|
||||
"type": "json",
|
||||
"label": "使用的凭证",
|
||||
"defaultValue": "{\"type\":\"token\", \"value\":\"{input.token}\"}",
|
||||
"description": "支持从输入引用值"
|
||||
},
|
||||
{
|
||||
"name": "expectedStatus",
|
||||
"type": "select",
|
||||
"label": "预期HTTP状态",
|
||||
"options": [
|
||||
"2xx (成功)",
|
||||
"401 (未授权)",
|
||||
"403 (禁止访问)",
|
||||
"其他"
|
||||
],
|
||||
"defaultValue": "2xx (成功)"
|
||||
},
|
||||
{
|
||||
"name": "customExpectedStatus",
|
||||
"type": "number",
|
||||
"label": "预期状态码(其他)",
|
||||
"optional": true
|
||||
},
|
||||
{
|
||||
"name": "checkResult",
|
||||
"type": "string",
|
||||
"label": "检查结果",
|
||||
"readonly": true
|
||||
},
|
||||
{
|
||||
"name": "responseDetails",
|
||||
"type": "hidden"
|
||||
}
|
||||
]
|
||||
},
|
||||
"dataMaskingCheck": {
|
||||
"name": "数据脱敏检查",
|
||||
"category": "compliance",
|
||||
"color": "#595959",
|
||||
"icon_path": "/assets/icons/masking-check.svg",
|
||||
"shape": "rect",
|
||||
"width": 160,
|
||||
"height": 50,
|
||||
"ports": [
|
||||
"top",
|
||||
"right",
|
||||
"bottom",
|
||||
"left"
|
||||
],
|
||||
"metaFields": [
|
||||
{
|
||||
"name": "dataFieldPath",
|
||||
"type": "string",
|
||||
"label": "检查字段路径",
|
||||
"defaultValue": "body.creditCard",
|
||||
"description": "使用点标记法指定字段"
|
||||
},
|
||||
{
|
||||
"name": "expectedFormat",
|
||||
"type": "string",
|
||||
"label": "预期脱敏格式",
|
||||
"defaultValue": "**** **** **** 1234",
|
||||
"description": "用*表示脱敏位"
|
||||
},
|
||||
{
|
||||
"name": "checkResult",
|
||||
"type": "string",
|
||||
"label": "检查结果",
|
||||
"readonly": true
|
||||
},
|
||||
{
|
||||
"name": "actualValue",
|
||||
"type": "hidden"
|
||||
}
|
||||
]
|
||||
},
|
||||
"failureInjection": {
|
||||
"name": "故障注入",
|
||||
"category": "reliability",
|
||||
"color": "#cf1322",
|
||||
"icon_path": "/assets/icons/chaos.svg",
|
||||
"shape": "rect",
|
||||
"width": 160,
|
||||
"height": 50,
|
||||
"ports": [
|
||||
"top",
|
||||
"right",
|
||||
"bottom",
|
||||
"left"
|
||||
],
|
||||
"metaFields": [
|
||||
{
|
||||
"name": "targetResource",
|
||||
"type": "string",
|
||||
"label": "注入目标资源",
|
||||
"description": "e.g., service:my-app, pod:app-*, db:orders"
|
||||
},
|
||||
{
|
||||
"name": "failureType",
|
||||
"type": "select",
|
||||
"label": "故障类型",
|
||||
"options": [
|
||||
"latency",
|
||||
"error",
|
||||
"crash",
|
||||
"network_loss",
|
||||
"resource_limit"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "magnitude",
|
||||
"type": "string",
|
||||
"label": "故障程度",
|
||||
"description": "e.g., latency: 500ms, error: 503, network_loss: 80%"
|
||||
},
|
||||
{
|
||||
"name": "durationSec",
|
||||
"type": "number",
|
||||
"label": "持续时间(秒)",
|
||||
"defaultValue": 60
|
||||
},
|
||||
{
|
||||
"name": "injectionStatus",
|
||||
"type": "string",
|
||||
"label": "注入状态",
|
||||
"readonly": true
|
||||
},
|
||||
{
|
||||
"name": "details",
|
||||
"type": "hidden"
|
||||
}
|
||||
]
|
||||
},
|
||||
"agentBrowserTask": {
|
||||
"name": "Agent UI任务",
|
||||
"category": "ui",
|
||||
"color": "#08979c",
|
||||
"icon_path": "/assets/icons/agent.svg",
|
||||
"shape": "rect",
|
||||
"width": 180,
|
||||
"height": 60,
|
||||
"ports": [
|
||||
"top",
|
||||
"right",
|
||||
"bottom",
|
||||
"left"
|
||||
],
|
||||
"metaFields": [
|
||||
{
|
||||
"name": "targetUrl",
|
||||
"type": "string",
|
||||
"label": "目标页面URL"
|
||||
},
|
||||
{
|
||||
"name": "taskPrompt",
|
||||
"type": "textarea",
|
||||
"label": "任务指令 (Prompt)",
|
||||
"rows": 5,
|
||||
"description": "给 Agent 的详细操作指令"
|
||||
},
|
||||
{
|
||||
"name": "agentModel",
|
||||
"type": "string",
|
||||
"label": "Agent模型/配置",
|
||||
"optional": true,
|
||||
"defaultValue": "default_browser_agent"
|
||||
},
|
||||
{
|
||||
"name": "inputDataUsage",
|
||||
"type": "json",
|
||||
"label": "输入数据使用方式",
|
||||
"optional": true,
|
||||
"defaultValue": "{\"map\": [{\"from\": \"input.username\", \"to\": \"form.user\"}, {\"from\": \"input.password\", \"to\": \"form.pass\"}]}",
|
||||
"description": "定义如何将输入映射到表单或Prompt"
|
||||
},
|
||||
{
|
||||
"name": "validationCriteria",
|
||||
"type": "textarea",
|
||||
"label": "成功/失败标准",
|
||||
"optional": true,
|
||||
"description": "如何判断 Agent 执行结果是否符合预期"
|
||||
},
|
||||
{
|
||||
"name": "executionResult",
|
||||
"type": "string",
|
||||
"label": "执行结果",
|
||||
"readonly": true
|
||||
},
|
||||
{
|
||||
"name": "agentLog",
|
||||
"type": "textarea",
|
||||
"label": "Agent 执行日志",
|
||||
"readonly": true,
|
||||
"rows": 4
|
||||
},
|
||||
{
|
||||
"name": "screenshotUrl",
|
||||
"type": "string",
|
||||
"label": "截图链接",
|
||||
"readonly": true,
|
||||
"optional": true
|
||||
},
|
||||
{
|
||||
"name": "extractedData",
|
||||
"type": "hidden"
|
||||
}
|
||||
]
|
||||
},
|
||||
"delayNode": {
|
||||
"name": "延迟等待",
|
||||
"category": "logic",
|
||||
"color": "#bfbfbf",
|
||||
"icon_path": "/assets/icons/delay.svg",
|
||||
"shape": "circle",
|
||||
"width": 60,
|
||||
"height": 60,
|
||||
"ports": [
|
||||
"top",
|
||||
"right",
|
||||
"bottom",
|
||||
"left"
|
||||
],
|
||||
"metaFields": [
|
||||
{
|
||||
"name": "delayMs",
|
||||
"type": "number",
|
||||
"label": "延迟时间 (ms)",
|
||||
"defaultValue": 1000
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// Copyright (C) 2024 veypi <i@veypi.com>
|
||||
// 2025-02-27 19:32:09
|
||||
// Distributed under terms of the MIT license.
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
import "app/cfg"
|
||||
|
||||
var cmdDB = CMD.SubCommand("db", "database operations")
|
||||
var cmdMigrate = cmdDB.SubCommand("migrate", "migrate database")
|
||||
|
||||
func init() {
|
||||
cmdMigrate.Command = func() error {
|
||||
// create table without constraints
|
||||
cfg.DB().DisableForeignKeyConstraintWhenMigrating = true
|
||||
err := cfg.DB().AutoMigrate(cfg.ObjList...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// create constraints
|
||||
cfg.DB().DisableForeignKeyConstraintWhenMigrating = false
|
||||
return cfg.DB().AutoMigrate(cfg.ObjList...)
|
||||
}
|
||||
cmdDB.SubCommand("drop", "drop database").Command = func() error {
|
||||
return cfg.DB().Migrator().DropTable(cfg.ObjList...)
|
||||
}
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
//
|
||||
// main.go
|
||||
// Copyright (C) 2024 veypi <i@veypi.com>
|
||||
// 2025-02-27 19:32:09
|
||||
// Distributed under terms of the MIT license.
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"app/api"
|
||||
"app/api/project/stage"
|
||||
"app/cfg"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/nats-io/nats-server/v2/server"
|
||||
"github.com/nats-io/nats.go"
|
||||
"github.com/veypi/OneBD/rest"
|
||||
"github.com/veypi/utils/flags"
|
||||
"github.com/veypi/utils/logv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
opts := &server.Options{
|
||||
Host: "127.0.0.1",
|
||||
Port: 4222,
|
||||
NoLog: false,
|
||||
NoSigs: false,
|
||||
HTTPPort: 8222, // 监控端口
|
||||
Websocket: server.WebsocketOpts{
|
||||
Port: 9222, // 使用相同的端口
|
||||
Host: "127.0.0.1", // WebSocket 主机
|
||||
NoTLS: true, // 非 TLS WebSocket
|
||||
},
|
||||
}
|
||||
|
||||
// 创建并启动服务器
|
||||
natsServer, err := server.NewServer(opts)
|
||||
if err != nil {
|
||||
log.Fatalf("无法创建 NATS 服务器: %v", err)
|
||||
}
|
||||
|
||||
// 启动服务器 (以 goroutine 方式运行)
|
||||
go natsServer.Start()
|
||||
|
||||
// 等待服务器启动
|
||||
if !natsServer.ReadyForConnections(5 * time.Second) {
|
||||
log.Fatal("NATS 服务器无法在指定时间内启动")
|
||||
}
|
||||
|
||||
fmt.Println("NATS 服务器已启动")
|
||||
|
||||
// 示例:连接到刚刚启动的 NATS 服务器
|
||||
nc, err := nats.Connect("nats://127.0.0.1:4222")
|
||||
if err != nil {
|
||||
log.Fatalf("无法连接到 NATS: %v", err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
nc1, err := nats.Connect("ws://127.0.0.1:9222")
|
||||
if err != nil {
|
||||
log.Fatalf("无法连接到 ws: %v", err)
|
||||
}
|
||||
defer nc1.Close()
|
||||
|
||||
// 现在可以使用 nc 发布和订阅消息
|
||||
fmt.Println("已成功连接到 NATS 服务器")
|
||||
|
||||
if err := stage.InitGraphProcessor(); err != nil {
|
||||
log.Fatalf("Stage 图生成处理器初始化失败: %v", err)
|
||||
}
|
||||
log.Println("Stage 图生成处理器初始化成功.")
|
||||
|
||||
var CMD = flags.New("app", "the backend server of app")
|
||||
|
||||
CMD.Command = runWeb
|
||||
|
||||
CMD.Parse()
|
||||
err = CMD.Run()
|
||||
if err != nil {
|
||||
logv.Warn().Msg(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func runWeb() error {
|
||||
server, err := rest.New(rest.WithHost(cfg.Config.Host), rest.WithPort(cfg.Config.Port))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// server.SetRouter(app.Router)
|
||||
// server.Router().Print()
|
||||
// return server.Run()
|
||||
|
||||
server.Router().Extend("api", api.Router)
|
||||
|
||||
server.Router().Print()
|
||||
return server.Run()
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"app/cfg"
|
||||
"app/models"
|
||||
"app/models/project"
|
||||
"app/models/project/stage"
|
||||
"app/models/project/stage/tools"
|
||||
)
|
||||
|
||||
// Run executes all pending migrations
|
||||
func main() {
|
||||
// 初始化数据库连接
|
||||
var db = cfg.DB()
|
||||
|
||||
// 在这里添加所有的迁移
|
||||
migrations := []interface{}{
|
||||
models.Stage{},
|
||||
models.GraphLink{},
|
||||
models.GraphNode{},
|
||||
models.Tree{},
|
||||
models.Endpoint{},
|
||||
models.Doc{},
|
||||
models.Project{},
|
||||
models.Response{},
|
||||
models.Demand{},
|
||||
project.Demand{},
|
||||
project.Stage{},
|
||||
stage.GraphLink{},
|
||||
stage.GraphNode{},
|
||||
tools.Endpoint{},
|
||||
}
|
||||
|
||||
// 执行迁移
|
||||
var _ = db.AutoMigrate(migrations...)
|
||||
}
|
||||
Reference in New Issue
Block a user