Documentation
¶
Index ¶
- Constants
- func BuildNodeFormJSON(dagDefinitionRaw string, ioSchema map[string]interface{}, script *types.Script, ...) ([]interface{}, error)
- func BuildParseAnalysisResult(ctx context.Context, dataService interfaces.DataService, ...) (map[string]interface{}, error)
- func NewAnalysisNodeFromCommand(spec CommandNodeSpec) (*types.AnalysisNode, error)
- type AnalysisNodeBuildResult
- type AnalysisNodeSpec
- type CommandNodeSpec
Constants ¶
const ( // NodeCreationSourceAgent 是 Agent 会话(create_agent_analysis)直接创建的命令节点。 NodeCreationSourceAgent = types.AnalysisNodeCreationSourceAgent // NodeCreationSourceScript 是由脚本契约创建的节点(前端独立节点 / create_script_analysis)。 NodeCreationSourceScript = types.AnalysisNodeCreationSourceScript // NodeCreationSourceScheduler 是 DAG 调度器物化的节点。 NodeCreationSourceScheduler = types.AnalysisNodeCreationSourceScheduler )
NodeCreationSource 是分析节点的来源标记(analysis_nodes.creation_source)。
节点类型只有三种,统一引用 types 中的规范取值,避免各处再写字面量:
- agent:Agent 会话直接创建的命令节点(无脚本);
- script:由脚本契约创建的节点(前端独立节点 / create_script_analysis);
- scheduler:由 DAG 调度器按流程物化的节点。
const ( // CollectedAssaySelect is the table picker over upstream results that projects // one form field per collected column. FileSelect = "FileSelect" )
Form component type identifiers.
These mirror the `type` field written by the frontend form builder (go-brave-ui, COMPONENT_IMPLEMENTATIONS / COMPONENT_META) and are used server side to branch on a form item's component kind. Keeping them as constants avoids typo-prone string literals being duplicated across packages.
Variables ¶
This section is empty.
Functions ¶
func BuildNodeFormJSON ¶
func BuildNodeFormJSON(dagDefinitionRaw string, ioSchema map[string]interface{}, script *types.Script, scriptID string) ([]interface{}, error)
BuildNodeFormJSON 根据 DAG 节点定义与 io_schema 构造节点表单。 io_schema 由调用方从脚本目录的 io_schema.json 读取后传入(不再来自 script 字段)。
func BuildParseAnalysisResult ¶
func BuildParseAnalysisResult(ctx context.Context, dataService interfaces.DataService, requestParam map[string]interface{}, formJSONWrap []interface{}) (map[string]interface{}, error)
BuildParseAnalysisResult 把 request_param 依据表单定义解析成结构化配方。
func NewAnalysisNodeFromCommand ¶ added in v0.2.0
func NewAnalysisNodeFromCommand(spec CommandNodeSpec) (*types.AnalysisNode, error)
NewAnalysisNodeFromCommand 由 Agent 会话的「容器模板 + 命令」构建一个尚未落库的命令节点。
与脚本节点共用同一套派生口径:工作目录仍为 joinNodeWorkspace(...),其余路径由它派生, 状态 ready、executor container,运行 / 停止完全复用通用节点链路。
Types ¶
type AnalysisNodeBuildResult ¶ added in v0.2.0
type AnalysisNodeBuildResult struct {
Node *types.AnalysisNode
// ScriptFormJSON 是脚本表单(io_schema.json 的 inputs),用于 BuildParseAnalysisResult。
ScriptFormJSON []any
// ScriptIOSchema 是完整的 io_schema.json。
ScriptIOSchema map[string]any
}
AnalysisNodeBuildResult 是「由脚本构建分析节点」的产物。
除节点本身外,把构建时用到的脚本表单一并回传:调用方通常还要用它做参数校验提示 (如缺必填项 / 出现 io_schema 未声明的键),避免再查一次脚本表单。
func NewAnalysisNodeFromScript ¶ added in v0.2.0
func NewAnalysisNodeFromScript( ctx context.Context, dataService interfaces.DataService, workflowService interfaces.WorkflowService, script *types.Script, spec AnalysisNodeSpec, ) (AnalysisNodeBuildResult, error)
NewAnalysisNodeFromScript 由脚本对象 + 请求参数构建一个尚未落库的独立分析节点。
与「保存独立节点」同一口径:
- 节点工作目录为 <base_dir>/data/<project>/analysis_node/<script_id>/<node_id>,其余路径由它派生;
- inputs_patterns / output_patterns 取自脚本最新 io_schema.json;
- request_param 非空时按脚本表单解析出 resolved_inputs,并写入 request_param(含 analysis_node_id), 使得节点落库后即可被 NodeRuntimePreparer 生成 params.json。
脚本表单由内部调用 workflowService.GetScriptFormJSONByScript 读取(调用方手上已有脚本对象, 无需再按 ID 查一次库)。
type AnalysisNodeSpec ¶ added in v0.2.0
type AnalysisNodeSpec struct {
// ProjectID 是节点所属项目(必须为正数)。
ProjectID int64
// Script 是节点绑定的脚本;只有 ID / ProjectID / ScriptID / NodeName 会被读取。
Script *types.Script
// RequestParam 是请求参数;为空时只按脚本 io_schema 刷新 patterns,不解析 resolved_inputs。
RequestParam map[string]any
// NodeName 为空时回落到脚本名称。
NodeName string
// Executor 为空时为 local。
Executor string
// CreationSource 是节点来源(agent / script / scheduler),为空时按 script。
CreationSource string
// BaseDir 是存储根目录,用于推导节点工作目录(为空时用 ".")。
BaseDir string
}
AnalysisNodeSpec 描述「由脚本契约构建一个独立运行的分析节点」所需的事实。
只承载入参事实,路径 / 主键 / 状态等派生字段由 NewAnalysisNodeFromScript 统一生成, 保证前端保存、Agent 创建与工具运行三处口径一致。
type CommandNodeSpec ¶ added in v0.2.0
type CommandNodeSpec struct {
// ProjectID 是节点所属项目(必须为正数)。
ProjectID int64
// ContainerTemplateID 是该节点使用的容器模板(go_container_template_definition 主键)。
ContainerTemplateID int64
// Command 是待写入 run.sh 的 shell 命令(仅用于校验)。
Command string
// NodeName 是节点名称,为空时回落到 "agent-analysis"。
NodeName string
// BaseDir 是存储根目录(为空时用 ".")。
BaseDir string
}
CommandNodeSpec 描述「由 Agent 会话构建一个命令型分析节点」所需的事实。
命令节点没有脚本:容器模板与 run.sh 正文都由节点自身承载,因此不需要 io_schema。 注意:Command 不再落库(AnalysisNode 没有 Command 字段),这里只做非空校验; 调用方拿到节点后需自行调用 prepare.WriteCommandRunScript 写入 run.sh。