Refactor runtime around world core

This commit is contained in:
lpf
2026-03-15 23:46:06 +08:00
parent ba95aeed35
commit afae9076df
79 changed files with 6526 additions and 6960 deletions

View File

@@ -6,17 +6,16 @@ import (
"time"
)
func TestSubagentManagerRuntimeSnapshot(t *testing.T) {
func TestAgentManagerRuntimeSnapshot(t *testing.T) {
workspace := t.TempDir()
manager := NewSubagentManager(nil, workspace, nil)
manager.SetRunFunc(func(ctx context.Context, task *SubagentTask) (string, error) {
manager := NewAgentManager(nil, workspace, nil)
manager.SetRunFunc(func(ctx context.Context, task *AgentTask) (string, error) {
return "snapshot-result", nil
})
task, err := manager.SpawnTask(context.Background(), SubagentSpawnOptions{
task, err := manager.SpawnTask(context.Background(), AgentSpawnOptions{
Task: "implement snapshot support",
AgentID: "coder",
OriginChannel: "cli",
OriginChatID: "direct",
Origin: &OriginRef{Channel: "cli", ChatID: "direct"},
})
if err != nil {
t.Fatalf("spawn task failed: %v", err)
@@ -29,14 +28,7 @@ func TestSubagentManagerRuntimeSnapshot(t *testing.T) {
if len(snapshot.Tasks) == 0 || len(snapshot.Runs) == 0 {
t.Fatalf("expected runtime snapshot to include task and run records: %+v", snapshot)
}
if len(snapshot.Threads) == 0 || len(snapshot.Artifacts) == 0 {
t.Fatalf("expected runtime snapshot to include thread and artifact records: %+v", snapshot)
}
msgArtifact := snapshot.Artifacts[0]
if msgArtifact.SourceType != "agent_message" {
t.Fatalf("expected agent message artifact source type, got %+v", msgArtifact)
}
if msgArtifact.FromAgent == "" || msgArtifact.ToAgent == "" || msgArtifact.Name == "" {
t.Fatalf("expected runtime snapshot artifact to preserve message metadata, got %+v", msgArtifact)
if len(snapshot.Events) == 0 {
t.Fatalf("expected runtime snapshot to include events: %+v", snapshot)
}
}