ACP / MCP

This commit is contained in:
2026-06-12 11:44:19 +08:00
parent 2a9661a6ef
commit 4ea4adfd8e
47 changed files with 2558 additions and 240 deletions
+28 -1
View File
@@ -21,10 +21,14 @@ import (
// (隔离单测,不引 testcontainers)。
type fakeAgentKindRepo struct {
store map[uuid.UUID]*acp.AgentKind
files map[string]*acp.ConfigFile // key: kindID/relPath
}
func newFakeAgentKindRepo() *fakeAgentKindRepo {
return &fakeAgentKindRepo{store: map[uuid.UUID]*acp.AgentKind{}}
return &fakeAgentKindRepo{
store: map[uuid.UUID]*acp.AgentKind{},
files: map[string]*acp.ConfigFile{},
}
}
func (f *fakeAgentKindRepo) CreateAgentKind(_ context.Context, k *acp.AgentKind) (*acp.AgentKind, error) {
@@ -81,6 +85,29 @@ func (f *fakeAgentKindRepo) DeleteAgentKind(_ context.Context, id uuid.UUID) err
func (f *fakeAgentKindRepo) CountAgentKindUsage(_ context.Context, _ uuid.UUID) (int64, error) {
return 0, nil
}
func (f *fakeAgentKindRepo) ListConfigFiles(_ context.Context, kindID uuid.UUID) ([]*acp.ConfigFile, error) {
out := make([]*acp.ConfigFile, 0)
for _, cf := range f.files {
if cf.AgentKindID == kindID {
cp := *cf
out = append(out, &cp)
}
}
return out, nil
}
func (f *fakeAgentKindRepo) UpsertConfigFile(_ context.Context, cf *acp.ConfigFile) (*acp.ConfigFile, error) {
cp := *cf
f.files[cf.AgentKindID.String()+"/"+cf.RelPath] = &cp
return &cp, nil
}
func (f *fakeAgentKindRepo) DeleteConfigFile(_ context.Context, kindID uuid.UUID, relPath string) (bool, error) {
key := kindID.String() + "/" + relPath
if _, ok := f.files[key]; !ok {
return false, nil
}
delete(f.files, key)
return true, nil
}
// 其他方法 panic(不该被 AgentKindService 调用)
func (f *fakeAgentKindRepo) InsertSession(context.Context, *acp.Session) (*acp.Session, error) {