60 lines
1.6 KiB
Go
60 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"chat-agent-system/internal/bizdev"
|
|
"chat-agent-system/internal/config"
|
|
)
|
|
|
|
func main() {
|
|
taskKey := flag.String("task", "intake", "任务标识 (intake, research, cdo_quote 等)")
|
|
backend := flag.String("backend", "stub", "智能体后端 (stub, pi-agent, cursor-cli)")
|
|
project := flag.String("project", "医疗器械研发演示项目", "项目名称")
|
|
customer := flag.String("customer", "北京水木东方", "客户名称")
|
|
envPath := flag.String("env", ".env", "环境配置文件路径")
|
|
flag.Parse()
|
|
|
|
cfg, err := config.Load(*envPath)
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "加载配置失败: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
if *backend != "" {
|
|
cfg.AgentBackend = *backend
|
|
}
|
|
|
|
svc := bizdev.NewService(cfg)
|
|
res, err := svc.ExecuteTask(context.Background(), bizdev.TaskRunRequest{
|
|
TaskKey: *taskKey,
|
|
ProjectName: *project,
|
|
CustomerName: *customer,
|
|
Backend: *backend,
|
|
})
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "任务执行失败: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
if !res.Success {
|
|
fmt.Fprintf(os.Stderr, "警告: 后端执行未完全成功 [%s]: %s\n", res.TaskKey, res.ErrorReason)
|
|
}
|
|
|
|
fmt.Printf("=== 任务执行成功 [%s] ===\n", res.TaskKey)
|
|
fmt.Printf("耗时: %v\n", res.Duration)
|
|
fmt.Printf("工作区: %s\n", res.WorkDir)
|
|
fmt.Printf("使用的后端: %s\n", res.BackendUsed)
|
|
if len(res.Attachments) > 0 {
|
|
fmt.Printf("附加产物:\n")
|
|
for _, a := range res.Attachments {
|
|
p := filepath.Join(res.WorkDir, a.Filename)
|
|
fmt.Printf(" - %s (%d bytes) -> %s\n", a.Filename, len(a.Data), p)
|
|
}
|
|
}
|
|
}
|