( ctx context.Context, scope toolspkg.Scope, req toolspkg.CallRequest, )
| 48 | } |
| 49 | |
| 50 | func (n *daemonNativeTools) networkChannelCreate( |
| 51 | ctx context.Context, |
| 52 | scope toolspkg.Scope, |
| 53 | req toolspkg.CallRequest, |
| 54 | ) (toolspkg.ToolResult, error) { |
| 55 | var input networkChannelCreateInput |
| 56 | if err := decodeNativeInput(req, &input); err != nil { |
| 57 | return toolspkg.ToolResult{}, err |
| 58 | } |
| 59 | channel, err := nativeNetworkChannel(req.ToolID, input.Channel) |
| 60 | if err != nil { |
| 61 | return toolspkg.ToolResult{}, err |
| 62 | } |
| 63 | purpose := strings.TrimSpace(input.Purpose) |
| 64 | if purpose == "" { |
| 65 | return toolspkg.ToolResult{}, nativeRequiredInputError(req.ToolID, "purpose") |
| 66 | } |
| 67 | fanoutPolicy := store.NormalizeNetworkFanoutPolicy(input.FanoutPolicy) |
| 68 | coordinatorPeerID := strings.TrimSpace(input.CoordinatorPeerID) |
| 69 | if err := store.ValidateNetworkChannelFanoutConfiguration(fanoutPolicy, coordinatorPeerID); err != nil { |
| 70 | return toolspkg.ToolResult{}, nativeNetworkInputError(req.ToolID, err) |
| 71 | } |
| 72 | workspaceID, err := n.nativeNetworkWorkspaceID(ctx, req.ToolID, input.WorkspaceID, scope) |
| 73 | if err != nil { |
| 74 | return toolspkg.ToolResult{}, err |
| 75 | } |
| 76 | entry := store.NetworkChannelEntry{ |
| 77 | Channel: channel, |
| 78 | WorkspaceID: workspaceID, |
| 79 | Purpose: purpose, |
| 80 | FanoutPolicy: fanoutPolicy, |
| 81 | CoordinatorPeerID: coordinatorPeerID, |
| 82 | CreatedBy: strings.TrimSpace(scope.AgentName), |
| 83 | } |
| 84 | if err := n.deps.NetworkStore.WriteNetworkChannel(ctx, entry); err != nil { |
| 85 | return toolspkg.ToolResult{}, nativeNetworkInputError(req.ToolID, err) |
| 86 | } |
| 87 | return structuredNetworkResult( |
| 88 | nativeNetworkChannelPayload(entry), |
| 89 | "channel "+channel, |
| 90 | ) |
| 91 | } |
| 92 | |
| 93 | func nativeNetworkChannelPayload(entry store.NetworkChannelEntry) map[string]any { |
| 94 | return map[string]any{ |
nothing calls this directly
no test coverage detected