Files
agent-radar 2ed3415fb7
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
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

68 lines
1.9 KiB
Go

package cli
import (
"context"
"errors"
"strings"
)
// HostRouteContext is fixed by daemon wiring. Untrusted connector input never
// receives an InvokeContext and therefore cannot impersonate another
// workspace/session/source or disable capability filters.
type HostRouteContext struct {
AppID string
WorkspaceID string
AgentSessionID string
ParentCommandID string
Source string
}
type HostInvokeRequest struct {
CommandID string
Input map[string]any
OutputMode OutputMode
}
type HostRoute struct {
registry *Registry
invokeContext InvokeContext
}
func NewHostRoute(registry *Registry, hostContext HostRouteContext) (*HostRoute, error) {
if registry == nil {
return nil, errors.New("host CLI route registry is required")
}
source := strings.TrimSpace(hostContext.Source)
if source == "" {
return nil, errors.New("host CLI route source is required")
}
return &HostRoute{
registry: registry,
invokeContext: InvokeContext{
AppID: strings.TrimSpace(hostContext.AppID),
Source: source,
WorkspaceID: strings.TrimSpace(hostContext.WorkspaceID),
ParentCommandID: strings.TrimSpace(hostContext.ParentCommandID),
AgentSessionID: strings.TrimSpace(hostContext.AgentSessionID),
// SkipCapabilityFilters and IncludeIntegrationCapabilities are
// intentionally impossible to set through HostRouteContext.
},
}, nil
}
func (route *HostRoute) Invoke(ctx context.Context, request HostInvokeRequest) (CommandOutput, error) {
if route == nil || route.registry == nil {
return CommandOutput{}, ErrServiceUnavailable
}
input := make(map[string]any, len(request.Input))
for key, value := range request.Input {
input[key] = value
}
return route.registry.Invoke(ctx, InvokeRequest{
CommandID: strings.TrimSpace(request.CommandID),
Input: input,
OutputMode: request.OutputMode,
Context: route.invokeContext,
})
}