Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
)
|
|
|
|
// CompositeDynamicCommandRegistry lets app and connector command authorities
|
|
// coexist without teaching the stable daemon CLI registry either domain.
|
|
type CompositeDynamicCommandRegistry struct {
|
|
Registries []DynamicCommandRegistry
|
|
}
|
|
|
|
func (composite CompositeDynamicCommandRegistry) Capabilities(ctx context.Context, invokeContext InvokeContext) []Capability {
|
|
result := []Capability{}
|
|
seen := map[string]struct{}{}
|
|
for _, registry := range composite.Registries {
|
|
if registry == nil {
|
|
continue
|
|
}
|
|
for _, capability := range registry.Capabilities(ctx, invokeContext) {
|
|
if _, duplicate := seen[capability.ID]; duplicate {
|
|
continue
|
|
}
|
|
seen[capability.ID] = struct{}{}
|
|
result = append(result, capability)
|
|
}
|
|
}
|
|
return result
|
|
}
|
|
|
|
func (composite CompositeDynamicCommandRegistry) Invoke(ctx context.Context, request InvokeRequest) (CommandOutput, error) {
|
|
for _, registry := range composite.Registries {
|
|
if registry == nil {
|
|
continue
|
|
}
|
|
output, err := registry.Invoke(ctx, request)
|
|
if err == nil {
|
|
return output, nil
|
|
}
|
|
if !errors.Is(err, ErrCommandNotFound) {
|
|
return CommandOutput{}, err
|
|
}
|
|
}
|
|
return CommandOutput{}, ErrCommandNotFound
|
|
}
|