MCPcopy Create free account
hub / github.com/astercloud/aster / main

Function main

examples/plan-explore-ui/main.go:33–129  ·  view source on GitHub ↗

Plan(分析 builtin 工具测试需求) └─ Read(pkg/tools/builtin/edit.go) └─ Read(pkg/tools/builtin/utils.go) Explore(分析当前工具实现状态) └─ Read(pkg/tools/builtin/task.go) └─ Read(pkg/tools/builtin/subagent_manager.go)

()

Source from the content-addressed store, hash-verified

31// └─ Read(pkg/tools/builtin/task.go)
32// └─ Read(pkg/tools/builtin/subagent_manager.go)
33func main() {
34 mode := flag.String("mode", "web", "UI mode: web 或 cli")
35 addr := flag.String("addr", ":8080", "Web UI HTTP 监听地址")
36 flag.Parse()
37
38 // 读取 provider / model / api key, 支持通过环境变量切换模型厂商。
39 providerName := os.Getenv("PROVIDER")
40 if providerName == "" {
41 providerName = "anthropic"
42 }
43
44 modelName := os.Getenv("MODEL")
45 if modelName == "" {
46 switch providerName {
47 case "deepseek":
48 modelName = "deepseek-chat"
49 default:
50 modelName = "claude-sonnet-4-5"
51 }
52 }
53
54 var apiKeyEnv string
55 switch providerName {
56 case "deepseek":
57 apiKeyEnv = "DEEPSEEK_API_KEY"
58 case "anthropic":
59 apiKeyEnv = "ANTHROPIC_API_KEY"
60 default:
61 apiKeyEnv = "API_KEY"
62 }
63
64 apiKey := os.Getenv(apiKeyEnv)
65 if apiKey == "" {
66 log.Printf("[WARN] %s not set, provider=%s model calls may fail.", apiKeyEnv, providerName)
67 }
68
69 log.Printf("[plan-explore-ui] Using provider=%s model=%s apiKeyEnv=%s", providerName, modelName, apiKeyEnv)
70
71 ctx := context.Background()
72
73 // 1. 工具注册表 + 内置工具
74 toolRegistry := tools.NewRegistry()
75 builtin.RegisterAll(toolRegistry)
76
77 // 2. Sandbox 工厂
78 sbFactory := sandbox.NewFactory()
79
80 // 3. Provider 工厂 (支持多种模型厂商)
81 providerFactory := provider.NewMultiProviderFactory()
82
83 // 4. Store (JSON 文件存储,便于调试)
84 storePath := ".aster-plan-explore-ui"
85 jsonStore, err := store.NewJSONStore(storePath)
86 if err != nil {
87 log.Fatalf("Failed to create store: %v", err)
88 }
89
90 // 5. 模板注册表 + 专用模板

Callers

nothing calls this directly

Calls 12

RegisterMethod · 0.95
NewRegistryFunction · 0.92
RegisterAllFunction · 0.92
NewFactoryFunction · 0.92
NewMultiProviderFactoryFunction · 0.92
NewJSONStoreFunction · 0.92
NewTemplateRegistryFunction · 0.92
runCliDemoFunction · 0.85
runWebUIFunction · 0.85
PrintfMethod · 0.80
ParseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected