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

Function main

examples/asteros/basic/main.go:23–170  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21)
22
23func main() {
24 fmt.Println("=== AsterOS 基本示例 ===")
25 fmt.Println("AsterOS 是 Aster 框架的统一运行时系统")
26 fmt.Println()
27
28 ctx := context.Background()
29
30 // 1. 创建依赖
31 deps := createDependencies()
32
33 // 2. 创建 Pool
34 fmt.Println("1. 创建 Pool...")
35 pool := core.NewPool(&core.PoolOptions{
36 Dependencies: deps,
37 MaxAgents: 10,
38 })
39
40 // 3. 创建 AsterOS
41 fmt.Println("2. 创建 AsterOS...")
42 aster, err := asteros.New(&asteros.Options{
43 Name: "MyAsterOS",
44 Port: 8080,
45 Pool: pool,
46 EnableLogging: true,
47 EnableCORS: true,
48 EnableMetrics: true,
49 EnableHealth: true,
50 })
51 if err != nil {
52 log.Fatalf("Failed to create AsterOS: %v", err)
53 }
54
55 // 4. 创建并注册 Agents
56 fmt.Println("3. 创建并注册 Agents...")
57
58 // Leader Agent
59 apiKey := os.Getenv("ANTHROPIC_API_KEY")
60 if apiKey == "" {
61 apiKey = "sk-test-key-for-demo" // 测试用的密钥
62 }
63
64 leaderConfig := &types.AgentConfig{
65 AgentID: "leader-1",
66 TemplateID: "leader",
67 ModelConfig: &types.ModelConfig{
68 Provider: "anthropic",
69 Model: "claude-sonnet-4-5",
70 APIKey: apiKey,
71 },
72 Sandbox: &types.SandboxConfig{
73 Kind: types.SandboxKindMock,
74 },
75 }
76
77 leaderAgent, err := agent.Create(ctx, leaderConfig, deps)
78 if err != nil {
79 log.Fatalf("Failed to create leader agent: %v", err)
80 }

Callers

nothing calls this directly

Calls 11

JoinMethod · 0.95
ShutdownMethod · 0.95
NewPoolFunction · 0.92
NewFunction · 0.92
CreateFunction · 0.92
NewRoomFunction · 0.92
ServeMethod · 0.80
PrintfMethod · 0.80
createDependenciesFunction · 0.70
RegisterAgentMethod · 0.65
RegisterRoomMethod · 0.45

Tested by

no test coverage detected