feat(capability/skills): 可复用工作流技能(Skill 模型 + Store + YAML Loader + Runner 展开 + 注册)
This commit is contained in:
1 parent
d947ec41a9
commit
915aa8a100
10 files changed
+1235
No files matched your search
@@ -0,0 +1,28 @@
|
||||
package skills
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/capability/registry"
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/pkg/plugins/sdk"
|
||||
)
|
||||
|
||||
// Register publishes list into reg as KindSkill capabilities so they become
|
||||
// globally available to every character and mode. It returns ErrNilRegistrar
|
||||
// when reg is nil, ErrInvalidSkill when a skill is nil, and the registry's error
|
||||
// (for example registry.ErrDuplicate) on the first failed registration; earlier
|
||||
// skills in list stay registered.
|
||||
func Register(reg *registry.Registry, list ...sdk.Skill) error {
|
||||
if reg == nil {
|
||||
return ErrNilRegistrar
|
||||
}
|
||||
for _, s := range list {
|
||||
if s == nil {
|
||||
return fmt.Errorf("skills: register: %w", ErrInvalidSkill)
|
||||
}
|
||||
if err := reg.RegisterSkill(s); err != nil {
|
||||
return fmt.Errorf("skills: register %q: %w", s.Name(), err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user